109 lines
3.4 KiB
YAML
109 lines
3.4 KiB
YAML
name: playwright-e2e
|
|
description: Run Playwright E2E tests with optional sharding, upload results to S3.
|
|
|
|
inputs:
|
|
working-directory:
|
|
description: Directory containing Playwright config
|
|
required: false
|
|
default: e2e
|
|
playwright-version:
|
|
description: Playwright version tag (browser cache key only — actual version comes from pnpm-lock.yaml)
|
|
required: false
|
|
default: v1.58.2
|
|
jfrog-token:
|
|
description: JFrog npm auth token
|
|
required: true
|
|
pnpm-version:
|
|
description: pnpm version
|
|
required: false
|
|
default: "10.11"
|
|
node-version:
|
|
description: Node.js version
|
|
required: false
|
|
default: "22"
|
|
shard-index:
|
|
description: Current shard (1-based)
|
|
required: false
|
|
default: "1"
|
|
shard-total:
|
|
description: Total shards. 1 = no sharding.
|
|
required: false
|
|
default: "1"
|
|
s3-reports-bucket:
|
|
description: S3 bucket for report upload
|
|
required: true
|
|
s3-reports-prefix:
|
|
description: S3 path prefix
|
|
required: true
|
|
aws-role-arn:
|
|
description: IAM role ARN for OIDC authentication
|
|
required: true
|
|
aws-profile:
|
|
description: AWS CLI profile name
|
|
required: false
|
|
default: stage
|
|
extra-deps:
|
|
description: Space-separated apt packages to install
|
|
required: false
|
|
default: ""
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Configure AWS
|
|
uses: schmalz/shared-actions/.github/actions/aws-configure@v1
|
|
with:
|
|
role-arn: ${{ inputs.aws-role-arn }}
|
|
aws-profile: ${{ inputs.aws-profile }}
|
|
|
|
- name: Restore Playwright browser cache
|
|
uses: https://data.forgejo.org/actions/cache/restore@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ inputs.playwright-version }}
|
|
|
|
- name: Setup Node.js
|
|
uses: https://code.forgejo.org/actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
|
|
- name: Run Playwright tests and upload results
|
|
shell: bash
|
|
env:
|
|
EXTRA_DEPS: ${{ inputs.extra-deps }}
|
|
PNPM_VERSION: ${{ inputs.pnpm-version }}
|
|
JFROG_TOKEN: ${{ inputs.jfrog-token }}
|
|
WORKING_DIR: ${{ inputs.working-directory }}
|
|
SHARD_INDEX: ${{ inputs.shard-index }}
|
|
SHARD_TOTAL: ${{ inputs.shard-total }}
|
|
BUCKET: ${{ inputs.s3-reports-bucket }}
|
|
PREFIX: ${{ inputs.s3-reports-prefix }}
|
|
AWS_PROFILE: ${{ inputs.aws-profile }}
|
|
run: |
|
|
if [ -n "${EXTRA_DEPS}" ]; then
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y ${EXTRA_DEPS}
|
|
fi
|
|
|
|
npm i -g "pnpm@${PNPM_VERSION}"
|
|
pnpm set registry https://schmalz.jfrog.io/artifactory/api/npm/default-npm/
|
|
pnpm set "//schmalz.jfrog.io/artifactory/api/npm/default-npm/:_authToken=${JFROG_TOKEN}"
|
|
|
|
pnpm --prefix="${WORKING_DIR}" install --frozen-lockfile
|
|
pnpm --prefix="${WORKING_DIR}" exec playwright install --with-deps
|
|
|
|
SHARD_ARG=""
|
|
if [ "${SHARD_TOTAL}" != "1" ]; then
|
|
SHARD_ARG="--shard=${SHARD_INDEX}/${SHARD_TOTAL}"
|
|
fi
|
|
pnpm --prefix="${WORKING_DIR}" exec playwright test ${SHARD_ARG}
|
|
|
|
aws s3 sync "${WORKING_DIR}/playwright-report/" \
|
|
"s3://${BUCKET}/${PREFIX}/shard-${SHARD_INDEX}/" \
|
|
--profile "${AWS_PROFILE}"
|
|
|
|
- name: Save Playwright browser cache
|
|
uses: https://data.forgejo.org/actions/cache/save@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ inputs.playwright-version }}
|