wip: inital set of shared actions
This commit is contained in:
parent
553786f000
commit
a09a422251
39 changed files with 1775 additions and 51 deletions
38
.github/actions/playwright-e2e/README.md
vendored
Normal file
38
.github/actions/playwright-e2e/README.md
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# playwright-e2e
|
||||
|
||||
Run Playwright E2E tests with optional sharding, upload results to S3.
|
||||
|
||||
## Inputs
|
||||
|
||||
| Input | Required | Default | Description |
|
||||
|-------|----------|---------|-------------|
|
||||
| `jfrog-token` | Yes | | JFrog npm auth token |
|
||||
| `s3-reports-bucket` | Yes | | S3 bucket for report upload |
|
||||
| `s3-reports-prefix` | Yes | | S3 path prefix |
|
||||
| `aws-role-arn` | Yes | | IAM role ARN for OIDC authentication |
|
||||
| `working-directory` | No | `e2e` | Directory containing Playwright config |
|
||||
| `playwright-version` | No | `v1.58.2` | Playwright version tag for browser cache key |
|
||||
| `pnpm-version` | No | `10.11` | pnpm version |
|
||||
| `shard-index` | No | `1` | Current shard (1-based) |
|
||||
| `shard-total` | No | `1` | Total shards. 1 = no sharding |
|
||||
| `aws-profile` | No | `stage` | AWS CLI profile name |
|
||||
| `extra-deps` | No | `""` | Space-separated apt packages to install |
|
||||
|
||||
## Usage
|
||||
|
||||
```yaml
|
||||
- uses: schmalz/shared-actions/.github/actions/playwright-e2e@v1
|
||||
with:
|
||||
jfrog-token: ${{ secrets.JFROG_TOKEN }}
|
||||
s3-reports-bucket: my-reports-bucket
|
||||
s3-reports-prefix: pr-${{ github.event.number }}
|
||||
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}
|
||||
shard-index: "1"
|
||||
shard-total: "4"
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- Playwright browsers are cached between runs using the `playwright-version` input as cache key.
|
||||
- Reports are uploaded to `s3://<bucket>/<prefix>/shard-<index>/`.
|
||||
- Uses JFrog Artifactory as the npm registry for dependency installation.
|
||||
109
.github/actions/playwright-e2e/action.yml
vendored
Normal file
109
.github/actions/playwright-e2e/action.yml
vendored
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
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 }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue