Skip to content

Commit d933435

Browse files
committed
♻️(CI) factorized E2E tests into a separate workflow
We had to maintains 2 jobs, test-e2e-chromium and test-e2e-other-browser, in the impress-frontend workflow. By factorising the E2E tests into a separate workflow, we can now maintain only one job for each browser, which is much simpler and easier to maintain.
1 parent d68d7ee commit d933435

2 files changed

Lines changed: 171 additions & 216 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: E2E Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
browser-name:
7+
description: 'Name used for cache keys and artifact names (e.g. chromium, other-browser)'
8+
required: true
9+
type: string
10+
projects:
11+
description: 'Playwright --project flags (e.g. --project=chromium)'
12+
required: true
13+
type: string
14+
timeout-minutes:
15+
description: 'Job timeout in minutes'
16+
required: false
17+
type: number
18+
default: 30
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
install-dependencies:
25+
uses: ./.github/workflows/dependencies.yml
26+
with:
27+
node_version: '22.x'
28+
with-front-dependencies-installation: true
29+
30+
prepare-e2e:
31+
runs-on: ubuntu-latest
32+
needs: install-dependencies
33+
timeout-minutes: 10
34+
permissions:
35+
contents: read
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v6
40+
41+
- name: Setup Node.js
42+
uses: actions/setup-node@v6
43+
with:
44+
node-version: "22.x"
45+
46+
- name: Restore the frontend cache
47+
uses: actions/cache@v5
48+
with:
49+
path: "src/frontend/**/node_modules"
50+
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
51+
fail-on-cache-miss: true
52+
53+
- name: Restore Playwright browsers cache
54+
id: playwright-cache
55+
uses: actions/cache/restore@v4
56+
with:
57+
path: ~/.cache/ms-playwright
58+
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
59+
restore-keys: |
60+
playwright-${{ runner.os }}-
61+
62+
- name: Install Playwright browsers
63+
if: steps.playwright-cache.outputs.cache-hit != 'true'
64+
run: |
65+
cd src/frontend/apps/e2e
66+
yarn install-playwright chromium firefox webkit
67+
68+
- name: Save Playwright browsers cache
69+
if: steps.playwright-cache.outputs.cache-hit != 'true'
70+
uses: actions/cache/save@v4
71+
with:
72+
path: ~/.cache/ms-playwright
73+
key: ${{ steps.playwright-cache.outputs.cache-primary-key }}
74+
75+
test-e2e:
76+
needs: prepare-e2e
77+
runs-on: ubuntu-latest
78+
timeout-minutes: ${{ inputs.timeout-minutes }}
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@v6
82+
83+
- name: Setup Node.js
84+
uses: actions/setup-node@v6
85+
with:
86+
node-version: "22.x"
87+
88+
- name: Restore the frontend cache
89+
uses: actions/cache@v5
90+
with:
91+
path: "src/frontend/**/node_modules"
92+
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
93+
fail-on-cache-miss: true
94+
95+
- name: Set e2e env variables
96+
run: cat env.d/development/common.e2e >> env.d/development/common.local
97+
98+
- name: Restore Playwright browsers cache
99+
uses: actions/cache@v5
100+
with:
101+
path: ~/.cache/ms-playwright
102+
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
103+
fail-on-cache-miss: true
104+
105+
- name: Free disk space before Docker
106+
uses: ./.github/actions/free-disk-space
107+
108+
- name: Start Docker services
109+
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
110+
111+
- name: Restore last-run cache
112+
if: ${{ github.run_attempt > 1 }}
113+
id: restore-last-run
114+
uses: actions/cache/restore@v4
115+
with:
116+
path: src/frontend/apps/e2e/test-results/.last-run.json
117+
key: playwright-last-run-${{ github.run_id }}-${{ inputs.browser-name }}
118+
119+
- name: Run e2e tests
120+
env:
121+
PLAYWRIGHT_LIST_PRINT_STEPS: true
122+
FORCE_COLOR: true
123+
run: |
124+
cd src/frontend/
125+
126+
LAST_FAILED_FLAG=""
127+
if [ "${{ github.run_attempt }}" != "1" ]; then
128+
LAST_RUN_FILE="apps/e2e/test-results/.last-run.json"
129+
if [ -f "$LAST_RUN_FILE" ]; then
130+
FAILED_COUNT=$(jq '.failedTests | length' "$LAST_RUN_FILE" 2>/dev/null || echo "0")
131+
if [ "${FAILED_COUNT:-0}" -gt "0" ]; then
132+
LAST_FAILED_FLAG="--last-failed"
133+
fi
134+
fi
135+
fi
136+
137+
yarn e2e:test ${{ inputs.projects }} $LAST_FAILED_FLAG
138+
139+
- name: Save last-run cache
140+
if: always()
141+
uses: actions/cache/save@v4
142+
with:
143+
path: src/frontend/apps/e2e/test-results/.last-run.json
144+
key: playwright-last-run-${{ github.run_id }}-${{ inputs.browser-name }}
145+
146+
- name: Upload last-run artifact
147+
if: always()
148+
uses: actions/upload-artifact@v6
149+
with:
150+
name: playwright-instance-last-run-${{ inputs.browser-name }}
151+
path: src/frontend/apps/e2e/test-results/.last-run.json
152+
include-hidden-files: true
153+
if-no-files-found: warn
154+
retention-days: 7
155+
156+
- uses: actions/upload-artifact@v6
157+
if: always()
158+
with:
159+
name: playwright-${{ inputs.browser-name }}-report
160+
path: src/frontend/apps/e2e/report/
161+
retention-days: 7

.github/workflows/impress-frontend.yml

Lines changed: 10 additions & 216 deletions
Original file line numberDiff line numberDiff line change
@@ -66,226 +66,20 @@ jobs:
6666
- name: Check linting
6767
run: cd src/frontend/ && yarn lint
6868

69-
prepare-e2e:
70-
runs-on: ubuntu-latest
71-
needs: install-dependencies
72-
timeout-minutes: 10
73-
permissions:
74-
contents: read
75-
76-
steps:
77-
- name: Checkout
78-
uses: actions/checkout@v6
79-
80-
- name: Setup Node.js
81-
uses: actions/setup-node@v6
82-
with:
83-
node-version: "22.x"
84-
85-
- name: Restore the frontend cache
86-
uses: actions/cache@v5
87-
with:
88-
path: "src/frontend/**/node_modules"
89-
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
90-
fail-on-cache-miss: true
91-
92-
- name: Restore Playwright browsers cache
93-
id: playwright-cache
94-
uses: actions/cache/restore@v4
95-
with:
96-
path: ~/.cache/ms-playwright
97-
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
98-
restore-keys: |
99-
playwright-${{ runner.os }}-
100-
101-
- name: Install Playwright browsers
102-
if: steps.playwright-cache.outputs.cache-hit != 'true'
103-
run: |
104-
cd src/frontend/apps/e2e
105-
yarn install-playwright chromium firefox webkit
106-
107-
- name: Save Playwright browsers cache
108-
if: steps.playwright-cache.outputs.cache-hit != 'true'
109-
uses: actions/cache/save@v4
110-
with:
111-
path: ~/.cache/ms-playwright
112-
key: ${{ steps.playwright-cache.outputs.cache-primary-key }}
113-
11469
test-e2e-chromium:
115-
runs-on: ubuntu-latest
116-
needs: prepare-e2e
117-
timeout-minutes: 20
118-
steps:
119-
- name: Checkout repository
120-
uses: actions/checkout@v6
121-
122-
- name: Setup Node.js
123-
uses: actions/setup-node@v6
124-
with:
125-
node-version: "22.x"
126-
127-
- name: Restore the frontend cache
128-
uses: actions/cache@v5
129-
with:
130-
path: "src/frontend/**/node_modules"
131-
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
132-
fail-on-cache-miss: true
133-
134-
- name: Set e2e env variables
135-
run: cat env.d/development/common.e2e >> env.d/development/common.local
136-
137-
- name: Restore Playwright browsers cache
138-
uses: actions/cache@v5
139-
with:
140-
path: ~/.cache/ms-playwright
141-
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
142-
fail-on-cache-miss: true
143-
144-
- name: Free disk space before Docker
145-
uses: ./.github/actions/free-disk-space
146-
147-
- name: Start Docker services
148-
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
149-
150-
- name: Restore last-run cache
151-
if: ${{ github.run_attempt > 1 }}
152-
id: restore-last-run
153-
uses: actions/cache/restore@v4
154-
with:
155-
path: src/frontend/apps/e2e/test-results/.last-run.json
156-
key: playwright-last-run-${{ github.run_id }}-chromium
157-
158-
- name: Run e2e tests
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_RUN_FILE="apps/e2e/test-results/.last-run.json"
168-
if [ -f "$LAST_RUN_FILE" ]; then
169-
FAILED_COUNT=$(jq '.failedTests | length' "$LAST_RUN_FILE" 2>/dev/null || echo "0")
170-
if [ "${FAILED_COUNT:-0}" -gt "0" ]; then
171-
LAST_FAILED_FLAG="--last-failed"
172-
fi
173-
fi
174-
fi
175-
176-
yarn e2e:test --project='chromium' $LAST_FAILED_FLAG
177-
178-
- name: Save last-run cache
179-
if: always()
180-
uses: actions/cache/save@v4
181-
with:
182-
path: src/frontend/apps/e2e/test-results/.last-run.json
183-
key: playwright-last-run-${{ github.run_id }}-chromium
184-
185-
- name: Upload last-run artifact
186-
if: always()
187-
uses: actions/upload-artifact@v6
188-
with:
189-
name: playwright-instance-last-run-chromium
190-
path: src/frontend/apps/e2e/test-results/.last-run.json
191-
include-hidden-files: true
192-
if-no-files-found: warn
193-
retention-days: 7
194-
195-
- uses: actions/upload-artifact@v6
196-
if: always()
197-
with:
198-
name: playwright-chromium-report
199-
path: src/frontend/apps/e2e/report/
200-
retention-days: 7
70+
uses: ./.github/workflows/e2e-tests.yml
71+
with:
72+
browser-name: chromium
73+
projects: --project=chromium
74+
timeout-minutes: 25
20175

20276
test-e2e-other-browser:
203-
runs-on: ubuntu-latest
20477
needs: test-e2e-chromium
205-
timeout-minutes: 30
206-
steps:
207-
- name: Checkout repository
208-
uses: actions/checkout@v6
209-
210-
- name: Setup Node.js
211-
uses: actions/setup-node@v6
212-
with:
213-
node-version: "22.x"
214-
215-
- name: Restore the frontend cache
216-
uses: actions/cache@v5
217-
with:
218-
path: "src/frontend/**/node_modules"
219-
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
220-
fail-on-cache-miss: true
221-
222-
- name: Set e2e env variables
223-
run: cat env.d/development/common.e2e >> env.d/development/common.local
224-
225-
- name: Restore Playwright browsers cache
226-
uses: actions/cache@v5
227-
with:
228-
path: ~/.cache/ms-playwright
229-
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
230-
fail-on-cache-miss: true
231-
232-
- name: Free disk space before Docker
233-
uses: ./.github/actions/free-disk-space
234-
235-
- name: Start Docker services
236-
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
237-
238-
- name: Restore last-run cache
239-
if: ${{ github.run_attempt > 1 }}
240-
id: restore-last-run
241-
uses: actions/cache/restore@v4
242-
with:
243-
path: src/frontend/apps/e2e/test-results/.last-run.json
244-
key: playwright-last-run-${{ github.run_id }}-other-browser
245-
246-
- name: Run e2e tests
247-
env:
248-
PLAYWRIGHT_LIST_PRINT_STEPS: true
249-
FORCE_COLOR: true
250-
run: |
251-
cd src/frontend/
252-
253-
LAST_FAILED_FLAG=""
254-
if [ "${{ github.run_attempt }}" != "1" ]; then
255-
LAST_RUN_FILE="apps/e2e/test-results/.last-run.json"
256-
if [ -f "$LAST_RUN_FILE" ]; then
257-
FAILED_COUNT=$(jq '.failedTests | length' "$LAST_RUN_FILE" 2>/dev/null || echo "0")
258-
if [ "${FAILED_COUNT:-0}" -gt "0" ]; then
259-
LAST_FAILED_FLAG="--last-failed"
260-
fi
261-
fi
262-
fi
263-
264-
yarn e2e:test --project=firefox --project=webkit $LAST_FAILED_FLAG
265-
266-
- name: Save last-run cache
267-
if: always()
268-
uses: actions/cache/save@v4
269-
with:
270-
path: src/frontend/apps/e2e/test-results/.last-run.json
271-
key: playwright-last-run-${{ github.run_id }}-other-browser
272-
273-
- name: Upload last-run artifact
274-
if: always()
275-
uses: actions/upload-artifact@v6
276-
with:
277-
name: playwright-instance-last-run-other-browser
278-
path: src/frontend/apps/e2e/test-results/.last-run.json
279-
include-hidden-files: true
280-
if-no-files-found: warn
281-
retention-days: 7
282-
283-
- uses: actions/upload-artifact@v6
284-
if: always()
285-
with:
286-
name: playwright-other-report
287-
path: src/frontend/apps/e2e/report/
288-
retention-days: 7
78+
uses: ./.github/workflows/e2e-tests.yml
79+
with:
80+
browser-name: other-browser
81+
projects: --project=firefox --project=webkit
82+
timeout-minutes: 30
28983

29084
bundle-size-check:
29185
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)