Skip to content

Commit 5440b3a

Browse files
committed
👷 Update Playwright workflow to use Docker Compose and shards
1 parent 0ffc452 commit 5440b3a

File tree

1 file changed

+69
-16
lines changed

1 file changed

+69
-16
lines changed

.github/workflows/playwright.yml

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,36 @@ on:
1616
default: 'false'
1717

1818
jobs:
19+
changes:
20+
runs-on: ubuntu-latest
21+
# Set job outputs to values from filter step
22+
outputs:
23+
changed: ${{ steps.filter.outputs.changed }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
# For pull requests it's not necessary to checkout the code but for the main branch it is
27+
- uses: dorny/paths-filter@v3
28+
id: filter
29+
with:
30+
filters: |
31+
changed:
32+
- backend/**
33+
- frontend/**
34+
- .env
35+
- docker-compose*.yml
36+
- .github/workflows/playwright.yml
1937
20-
test:
38+
test-playwright:
39+
needs:
40+
- changes
41+
if: ${{ needs.changes.outputs.changed == 'true' }}
2142
timeout-minutes: 60
2243
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
shardIndex: [1, 2, 3, 4]
47+
shardTotal: [4]
48+
fail-fast: false
2349
steps:
2450
- uses: actions/checkout@v4
2551
- uses: actions/setup-node@v4
@@ -33,35 +59,62 @@ jobs:
3359
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
3460
with:
3561
limit-access-to-actor: true
36-
- name: Install dependencies
37-
run: npm ci
38-
working-directory: frontend
39-
- name: Install Playwright Browsers
40-
run: npx playwright install --with-deps
41-
working-directory: frontend
4262
- run: docker compose build
4363
- run: docker compose down -v --remove-orphans
44-
- run: docker compose up -d --wait backend mailcatcher
64+
- run: docker compose up -d --wait backend
4565
- name: Run Playwright tests
46-
run: npx playwright test --fail-on-flaky-tests --trace=retain-on-failure
47-
working-directory: frontend
66+
run: docker compose run --rm playwright npx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
4867
- run: docker compose down -v --remove-orphans
49-
- uses: actions/upload-artifact@v4
50-
if: always()
68+
- name: Upload blob report to GitHub Actions Artifacts
69+
if: ${{ !cancelled() }}
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: blob-report-${{ matrix.shardIndex }}
73+
path: frontend/blob-report
74+
include-hidden-files: true
75+
retention-days: 1
76+
77+
merge-playwright-reports:
78+
needs:
79+
- test-playwright
80+
- changes
81+
# Merge reports after playwright-tests, even if some shards have failed
82+
if: ${{ !cancelled() && needs.changes.outputs.changed == 'true' }}
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v4
86+
- uses: actions/setup-node@v4
87+
with:
88+
node-version: 20
89+
- name: Install dependencies
90+
run: npm ci
91+
working-directory: frontend
92+
- name: Download blob reports from GitHub Actions Artifacts
93+
uses: actions/download-artifact@v4
94+
with:
95+
path: frontend/all-blob-reports
96+
pattern: blob-report-*
97+
merge-multiple: true
98+
- name: Merge into HTML Report
99+
run: npx playwright merge-reports --reporter html ./all-blob-reports
100+
working-directory: frontend
101+
- name: Upload HTML report
102+
uses: actions/upload-artifact@v4
51103
with:
52-
name: playwright-report
53-
path: frontend/playwright-report/
104+
name: html-report--attempt-${{ github.run_attempt }}
105+
path: frontend/playwright-report
54106
retention-days: 30
55107
include-hidden-files: true
56108

57109
# https://github.com/marketplace/actions/alls-green#why
58-
e2e-alls-green: # This job does nothing and is only used for the branch protection
110+
alls-green-playwright: # This job does nothing and is only used for the branch protection
59111
if: always()
60112
needs:
61-
- test
113+
- test-playwright
62114
runs-on: ubuntu-latest
63115
steps:
64116
- name: Decide whether the needed jobs succeeded or failed
65117
uses: re-actors/alls-green@release/v1
66118
with:
67119
jobs: ${{ toJSON(needs) }}
120+
allowed-skips: test-playwright

0 commit comments

Comments
 (0)