Skip to content

Commit 93e2c2b

Browse files
committed
⚡️(e2e) replay only failed tests when rerunning the test suite
We improved the test suite to only replay failed tests when rerunning the test suite. This allows us to focus on fixing the failed tests without having to wait for the entire test suite to run again. We add the Browser in cache to speed up the test execution and reduce the time it takes to run the tests.
1 parent d63550d commit 93e2c2b

1 file changed

Lines changed: 126 additions & 9 deletions

File tree

.github/workflows/impress-frontend.yml

Lines changed: 126 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,54 @@ jobs:
6363
- name: Check linting
6464
run: cd src/frontend/ && yarn lint
6565

66-
test-e2e-chromium:
66+
prepare-e2e:
6767
runs-on: ubuntu-latest
6868
needs: install-dependencies
69+
timeout-minutes: 10
70+
permissions:
71+
contents: read
72+
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v6
76+
77+
- name: Setup Node.js
78+
uses: actions/setup-node@v6
79+
with:
80+
node-version: "22.x"
81+
82+
- name: Restore the frontend cache
83+
uses: actions/cache@v5
84+
with:
85+
path: "src/frontend/**/node_modules"
86+
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
87+
fail-on-cache-miss: true
88+
89+
- name: Restore Playwright browsers cache
90+
id: playwright-cache
91+
uses: actions/cache/restore@v4
92+
with:
93+
path: ~/.cache/ms-playwright
94+
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
95+
restore-keys: |
96+
playwright-${{ runner.os }}-
97+
98+
- name: Install Playwright browsers
99+
if: steps.playwright-cache.outputs.cache-hit != 'true'
100+
run: |
101+
cd src/frontend/apps/e2e
102+
yarn install-playwright chromium firefox webkit
103+
104+
- name: Save Playwright browsers cache
105+
if: steps.playwright-cache.outputs.cache-hit != 'true'
106+
uses: actions/cache/save@v4
107+
with:
108+
path: ~/.cache/ms-playwright
109+
key: ${{ steps.playwright-cache.outputs.cache-primary-key }}
110+
111+
test-e2e-chromium:
112+
runs-on: ubuntu-latest
113+
needs: prepare-e2e
69114
timeout-minutes: 20
70115
steps:
71116
- name: Checkout repository
@@ -86,19 +131,55 @@ jobs:
86131
- name: Set e2e env variables
87132
run: cat env.d/development/common.e2e >> env.d/development/common.local
88133

89-
- name: Install Playwright Browsers
90-
run: cd src/frontend/apps/e2e && yarn install --frozen-lockfile && yarn install-playwright chromium
134+
- name: Restore Playwright browsers cache
135+
uses: actions/cache@v5
136+
with:
137+
path: ~/.cache/ms-playwright
138+
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
139+
fail-on-cache-miss: true
91140

92141
- name: Free disk space before Docker
93142
uses: ./.github/actions/free-disk-space
94143

95144
- name: Start Docker services
96145
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
97146

147+
- name: Restore last-run.json
148+
if: ${{ github.run_attempt > 1 }}
149+
uses: dawidd6/action-download-artifact@v6
150+
with:
151+
name: playwright-instance-last-run-chromium
152+
path: docs/src/frontend/apps/e2e/test-results
153+
workflow: docs-e2e-instance.yml
154+
workflow_conclusion: ""
155+
if_no_artifact_found: warn
156+
continue-on-error: true
157+
98158
- name: Run e2e tests
99-
run: cd src/frontend/ && yarn e2e:test --project='chromium'
159+
env:
160+
PLAYWRIGHT_LIST_PRINT_STEPS: true
161+
FORCE_COLOR: true
162+
run: |
163+
cd src/frontend/
164+
165+
LAST_FAILED_FLAG=""
166+
if [ "${{ github.run_attempt }}" != "1" ]; then
167+
LAST_FAILED_FLAG="--last-failed"
168+
fi
169+
170+
yarn e2e:test --project='chromium' $LAST_FAILED_FLAG
171+
172+
- name: Upload last-run artifact
173+
if: always()
174+
uses: actions/upload-artifact@v6
175+
with:
176+
name: playwright-instance-last-run-chromium
177+
path: src/frontend/apps/e2e/test-results/.last-run.json
178+
include-hidden-files: true
179+
if-no-files-found: warn
180+
retention-days: 7
100181

101-
- uses: actions/upload-artifact@v4
182+
- uses: actions/upload-artifact@v6
102183
if: always()
103184
with:
104185
name: playwright-chromium-report
@@ -128,19 +209,55 @@ jobs:
128209
- name: Set e2e env variables
129210
run: cat env.d/development/common.e2e >> env.d/development/common.local
130211

131-
- name: Install Playwright Browsers
132-
run: cd src/frontend/apps/e2e && yarn install --frozen-lockfile && yarn install-playwright firefox webkit chromium
212+
- name: Restore Playwright browsers cache
213+
uses: actions/cache@v5
214+
with:
215+
path: ~/.cache/ms-playwright
216+
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
217+
fail-on-cache-miss: true
133218

134219
- name: Free disk space before Docker
135220
uses: ./.github/actions/free-disk-space
136221

137222
- name: Start Docker services
138223
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
139224

225+
- name: Restore last-run.json
226+
if: ${{ github.run_attempt > 1 }}
227+
uses: dawidd6/action-download-artifact@v6
228+
with:
229+
name: playwright-instance-last-run-other-browser
230+
path: docs/src/frontend/apps/e2e/test-results
231+
workflow: docs-e2e-instance.yml
232+
workflow_conclusion: ""
233+
if_no_artifact_found: warn
234+
continue-on-error: true
235+
140236
- name: Run e2e tests
141-
run: cd src/frontend/ && yarn e2e:test --project=firefox --project=webkit
237+
env:
238+
PLAYWRIGHT_LIST_PRINT_STEPS: true
239+
FORCE_COLOR: true
240+
run: |
241+
cd src/frontend/
242+
243+
LAST_FAILED_FLAG=""
244+
if [ "${{ github.run_attempt }}" != "1" ]; then
245+
LAST_FAILED_FLAG="--last-failed"
246+
fi
247+
248+
yarn e2e:test --project=firefox --project=webkit $LAST_FAILED_FLAG
249+
250+
- name: Upload last-run artifact
251+
if: always()
252+
uses: actions/upload-artifact@v6
253+
with:
254+
name: playwright-instance-last-run-other-browser
255+
path: src/frontend/apps/e2e/test-results/.last-run.json
256+
include-hidden-files: true
257+
if-no-files-found: warn
258+
retention-days: 7
142259

143-
- uses: actions/upload-artifact@v4
260+
- uses: actions/upload-artifact@v6
144261
if: always()
145262
with:
146263
name: playwright-other-report

0 commit comments

Comments
 (0)