👷 Improve Playwright CI speed: sharding (paralel runs), run in Docker to use cache, use env vars (#1405)
This commit is contained in:

committed by
GitHub

parent
d3d370cad0
commit
e684f3c8d6
86
.github/workflows/playwright.yml
vendored
86
.github/workflows/playwright.yml
vendored
@@ -16,10 +16,36 @@ on:
|
||||
default: 'false'
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
runs-on: ubuntu-latest
|
||||
# Set job outputs to values from filter step
|
||||
outputs:
|
||||
changed: ${{ steps.filter.outputs.changed }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# For pull requests it's not necessary to checkout the code but for the main branch it is
|
||||
- uses: dorny/paths-filter@v3
|
||||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
changed:
|
||||
- backend/**
|
||||
- frontend/**
|
||||
- .env
|
||||
- docker-compose*.yml
|
||||
- .github/workflows/playwright.yml
|
||||
|
||||
test:
|
||||
test-playwright:
|
||||
needs:
|
||||
- changes
|
||||
if: ${{ needs.changes.outputs.changed == 'true' }}
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
shardIndex: [1, 2, 3, 4]
|
||||
shardTotal: [4]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
@@ -33,35 +59,61 @@ jobs:
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
|
||||
with:
|
||||
limit-access-to-actor: true
|
||||
- run: docker compose build
|
||||
- run: docker compose down -v --remove-orphans
|
||||
- name: Run Playwright tests
|
||||
run: docker compose run --rm playwright npx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
||||
- run: docker compose down -v --remove-orphans
|
||||
- name: Upload blob report to GitHub Actions Artifacts
|
||||
if: ${{ !cancelled() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: blob-report-${{ matrix.shardIndex }}
|
||||
path: frontend/blob-report
|
||||
include-hidden-files: true
|
||||
retention-days: 1
|
||||
|
||||
merge-playwright-reports:
|
||||
needs:
|
||||
- test-playwright
|
||||
- changes
|
||||
# Merge reports after playwright-tests, even if some shards have failed
|
||||
if: ${{ !cancelled() && needs.changes.outputs.changed == 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
working-directory: frontend
|
||||
- name: Install Playwright Browsers
|
||||
run: npx playwright install --with-deps
|
||||
working-directory: frontend
|
||||
- run: docker compose build
|
||||
- run: docker compose down -v --remove-orphans
|
||||
- run: docker compose up -d --wait backend mailcatcher
|
||||
- name: Run Playwright tests
|
||||
run: npx playwright test --fail-on-flaky-tests --trace=retain-on-failure
|
||||
working-directory: frontend
|
||||
- run: docker compose down -v --remove-orphans
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
- name: Download blob reports from GitHub Actions Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: playwright-report
|
||||
path: frontend/playwright-report/
|
||||
path: frontend/all-blob-reports
|
||||
pattern: blob-report-*
|
||||
merge-multiple: true
|
||||
- name: Merge into HTML Report
|
||||
run: npx playwright merge-reports --reporter html ./all-blob-reports
|
||||
working-directory: frontend
|
||||
- name: Upload HTML report
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: html-report--attempt-${{ github.run_attempt }}
|
||||
path: frontend/playwright-report
|
||||
retention-days: 30
|
||||
include-hidden-files: true
|
||||
|
||||
# https://github.com/marketplace/actions/alls-green#why
|
||||
e2e-alls-green: # This job does nothing and is only used for the branch protection
|
||||
alls-green-playwright: # This job does nothing and is only used for the branch protection
|
||||
if: always()
|
||||
needs:
|
||||
- test
|
||||
- test-playwright
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Decide whether the needed jobs succeeded or failed
|
||||
uses: re-actors/alls-green@release/v1
|
||||
with:
|
||||
jobs: ${{ toJSON(needs) }}
|
||||
allowed-skips: test-playwright
|
||||
|
Reference in New Issue
Block a user