Skip to content

Commit a3a7a88

Browse files
committed
Enhance speed of E2E testing workflow with blob report handling and timeout adjustments
1 parent 5fe8fbe commit a3a7a88

File tree

4 files changed

+93
-51
lines changed

4 files changed

+93
-51
lines changed

.github/workflows/.e2e-visual.yml

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
description: "Frontend URL of the application"
99
required: true
1010
type: string
11-
external-api-base-url :
11+
external-api-base-url:
1212
description: "Base URL to the external service API"
1313
required: true
1414
type: string
@@ -19,7 +19,7 @@ on:
1919
type: string
2020
timeout-minutes:
2121
description: 'Timeout minutes'
22-
default: 12
22+
default: 20
2323
required: false
2424
type: number
2525
workflow_call:
@@ -40,13 +40,13 @@ on:
4040
required: false
4141
default: dev
4242
type: string
43-
external-api-base-url :
43+
external-api-base-url:
4444
description: "Base URL to the external service API"
4545
required: true
4646
type: string
4747
timeout-minutes:
4848
description: 'Timeout minutes'
49-
default: 12
49+
default: 20
5050
required: false
5151
type: number
5252

@@ -59,11 +59,6 @@ jobs:
5959
working-directory: frontend
6060
runs-on: ubuntu-24.04
6161
timeout-minutes: ${{ fromJson(inputs.timeout-minutes) }}
62-
strategy:
63-
fail-fast: false # Don't fail fast - we need all browsers to generate screenshots
64-
max-parallel: 1 # Run all browsers in parallel for faster screenshot generation
65-
matrix:
66-
project: [chrome-visual, firefox-visual, safari-visual, edge-visual]
6762
steps:
6863
- uses: actions/checkout@v6
6964
name: Checkout
@@ -77,67 +72,89 @@ jobs:
7772
npm ci
7873
npx playwright install --with-deps
7974
80-
- name: Run Visual Regression Tests
81-
id: playwright-visual-tests
75+
- name: Create blob reports directory
76+
run: mkdir -p all-blob-reports
77+
78+
- name: Run Visual Tests - All Browsers
79+
id: visual-tests
8280
env:
8381
E2E_BASE_URL: ${{ inputs.frontend-url }}
8482
E2E_USERNAME: ${{ secrets.E2E_USERNAME }}
8583
E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }}
8684
EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY: ${{ secrets.EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY }}
8785
EXTERNAL_API_BASE_URL: ${{ inputs.external-api-base-url }}
8886
run: |
89-
npx playwright test --project="${{ matrix.project }}"
87+
for browser in chrome-visual firefox-visual safari-visual edge-visual; do
88+
echo "::group::Running tests for $browser"
89+
npx playwright test --project="$browser" || true
90+
if [ -d "blob-report" ] && [ -n "$(ls -A blob-report/*.zip 2>/dev/null)" ]; then
91+
cp blob-report/*.zip all-blob-reports/
92+
rm -rf blob-report
93+
fi
94+
echo "::endgroup::"
95+
done
9096
continue-on-error: true
9197

98+
- name: Merge blob reports and generate outputs
99+
if: always()
100+
env:
101+
PLAYWRIGHT_JSON_OUTPUT_NAME: test-results.json
102+
PLAYWRIGHT_HTML_OPEN: never
103+
run: |
104+
echo "Merging blob reports..."
105+
npx playwright merge-reports --reporter json ./all-blob-reports
106+
npx playwright merge-reports --reporter html ./all-blob-reports
107+
108+
# Rename HTML report directory
109+
if [ -d "playwright-report" ]; then
110+
mv playwright-report playwright-report-diffs
111+
fi
112+
92113
- name: Check for visual regression issues
93-
if: ${{ always() }}
114+
if: always()
94115
id: check-visual-regression
95116
run: |
96-
if [ -d "./test-results" ]; then
97-
mv ./test-results ./test-results-diffs
98-
fi
99-
if [ -d "./playwright-report" ]; then
100-
mv ./playwright-report ./playwright-report-diffs
101-
fi
102117
differences=false
103-
if [ -f "./test-results.json" ]; then
104-
unexpected=$(jq '.stats.unexpected' ./test-results.json)
118+
if [ -f "test-results.json" ]; then
119+
unexpected=$(jq '.stats.unexpected' test-results.json)
105120
if [ "$unexpected" -gt 0 ]; then
106121
differences=true
122+
echo "::warning::Found $unexpected unexpected visual regression(s)"
107123
fi
108124
fi
109125
echo "has_visual_issues=$differences" >> $GITHUB_OUTPUT
110126
111127
- name: Generate updated screenshots
112-
if: ${{ always() && steps.check-visual-regression.outputs.has_visual_issues == 'true' }}
113-
id: generate-updated-screenshots
128+
if: always() && steps.check-visual-regression.outputs.has_visual_issues == 'true'
114129
env:
115130
E2E_BASE_URL: ${{ inputs.frontend-url }}
116131
E2E_USERNAME: ${{ secrets.E2E_USERNAME }}
117132
E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }}
118133
EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY: ${{ secrets.EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY }}
119134
EXTERNAL_API_BASE_URL: ${{ inputs.external-api-base-url }}
120135
run: |
121-
echo "::notice::Generating updated screenshots for comparison..."
122-
npx playwright test --update-snapshots --project="${{ matrix.project }}"
136+
echo "::notice::Generating updated screenshots for all browsers..."
137+
npx playwright test --update-snapshots --project="chrome-visual"
138+
npx playwright test --update-snapshots --project="firefox-visual"
139+
npx playwright test --update-snapshots --project="safari-visual"
140+
npx playwright test --update-snapshots --project="edge-visual"
123141
124142
- uses: actions/upload-artifact@v6
125143
if: always()
126-
name: Upload Playwright visual test artifacts with screenshots
144+
name: Upload Playwright visual test artifacts
127145
with:
128-
name: playwright-visual-report-${{ matrix.project }}
146+
name: playwright-visual-report-all-browsers
129147
path: |
130148
./frontend/playwright-report-diffs
131-
./frontend/test-results-diffs
132149
./frontend/test-results.json
133-
./frontend/e2e/snapshots.ci/**/*${{ matrix.project }}*
150+
./frontend/e2e/snapshots.ci/**/*
134151
retention-days: 7
135152

136153
- name: Review and Commit Approved Screenshots
137-
if: ${{ steps.check-visual-regression.outputs.has_visual_issues == 'true' }}
154+
if: steps.check-visual-regression.outputs.has_visual_issues == 'true'
138155
run: |
139156
echo "::error::Visual regression differences were detected."
140-
echo "::notice::Download the artifacts for each browser (this one is 'playwright-visual-report-${{ matrix.project }}')."
141-
echo "::notice::Review the new screenshots in test-results-diffs."
142-
echo "::notice::Manually copy and commit the screenshots you approve from 'e2e/snapshots.ci/' to the repository."
157+
echo "::notice::Download the artifact 'playwright-visual-report-all-browsers' to review all browser results."
158+
echo "::notice::Review the differences in 'playwright-report-diffs' HTML report."
159+
echo "::notice::Review the new screenshots and manually copy/commit approved ones from 'e2e/snapshots.ci/' to the repository."
143160
exit 1

.github/workflows/.e2e.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
description: "Frontend URL of the application"
99
required: true
1010
type: string
11-
external-api-base-url :
11+
external-api-base-url:
1212
description: "Base URL to the external service API"
1313
required: true
1414
type: string
@@ -19,7 +19,7 @@ on:
1919
type: string
2020
timeout-minutes:
2121
description: 'Timeout minutes'
22-
default: 12
22+
default: 20
2323
required: false
2424
type: number
2525
workflow_call:
@@ -40,13 +40,13 @@ on:
4040
required: false
4141
default: dev
4242
type: string
43-
external-api-base-url :
43+
external-api-base-url:
4444
description: "Base URL to the external service API"
4545
required: true
4646
type: string
4747
timeout-minutes:
4848
description: 'Timeout minutes'
49-
default: 12
49+
default: 20
5050
required: false
5151
type: number
5252

@@ -59,11 +59,6 @@ jobs:
5959
working-directory: frontend
6060
runs-on: ubuntu-24.04
6161
timeout-minutes: ${{ fromJson(inputs.timeout-minutes) }}
62-
strategy:
63-
fail-fast: true # Early fail for functional tests
64-
max-parallel: 1
65-
matrix:
66-
project: [chrome, firefox, safari, edge]
6762
steps:
6863
- uses: actions/checkout@v6
6964
name: Checkout
@@ -77,6 +72,9 @@ jobs:
7772
npm ci
7873
npx playwright install --with-deps
7974
75+
- name: Create blob reports directory
76+
run: mkdir -p all-blob-reports
77+
8078
- name: Run Functional Tests (excluding visual regression)
8179
id: playwright-functional-tests
8280
env:
@@ -86,15 +84,39 @@ jobs:
8684
EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY: ${{ secrets.EXTERNAL_CONSUMER_DELETE_REPORTS_API_KEY }}
8785
EXTERNAL_API_BASE_URL: ${{ inputs.external-api-base-url }}
8886
run: |
89-
npx playwright test --project="${{ matrix.project }}"
87+
test_failed=0
88+
for browser in chrome firefox safari edge; do
89+
echo "::group::Running tests for $browser"
90+
npx playwright test --project="$browser" || test_failed=1
91+
if [ -d "blob-report" ] && [ -n "$(ls -A blob-report/*.zip 2>/dev/null)" ]; then
92+
cp blob-report/*.zip all-blob-reports/
93+
rm -rf blob-report
94+
fi
95+
echo "::endgroup::"
96+
97+
# Exit after copying blob report if test failed
98+
if [ $test_failed -eq 1 ]; then
99+
echo "::error::Tests failed for $browser"
100+
exit 1
101+
fi
102+
done
103+
104+
- name: Merge blob reports and generate outputs
105+
if: always()
106+
env:
107+
PLAYWRIGHT_JSON_OUTPUT_NAME: test-results.json
108+
PLAYWRIGHT_HTML_OPEN: never
109+
run: |
110+
echo "Merging blob reports..."
111+
npx playwright merge-reports --reporter json ./all-blob-reports
112+
npx playwright merge-reports --reporter html ./all-blob-reports
90113
91-
- uses: actions/upload-artifact@v6
114+
- uses: actions/upload-artifact@v4
92115
if: always()
93116
name: Upload Playwright artifacts
94117
with:
95-
name: playwright-report-frontend-${{ matrix.project }}
118+
name: playwright-report-frontend
96119
path: |
97120
./frontend/playwright-report
98-
./frontend/test-results
99121
./frontend/test-results.json
100122
retention-days: 7

frontend/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ test-results.json
2727
/test-results/
2828
/playwright-report/
2929
/blob-report/
30+
/all-blob-reports/
3031
/playwright/
3132
.env.playwright
3233
user.json

frontend/playwright.config.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export default defineConfig({
2323
/* Opt out of parallel tests on CI. */
2424
workers: process.env.CI ? 1 : undefined,
2525
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
26-
reporter: [
27-
['list', { printSteps: true }],
28-
['html', { open: 'always' }],
29-
['json', { outputFile: './test-results.json' }],
30-
],
26+
reporter: process.env.CI
27+
? [['blob'], ['list', { printSteps: true }]]
28+
: [
29+
['list', { printSteps: true }],
30+
['html', { open: 'always' }],
31+
['json', { outputFile: './test-results.json' }],
32+
],
3133
// developer-machine-snapshots are in a different folder to prevent conflicts
3234
// developer snapshots should not be committed to the repository
3335
snapshotDir: process.env.CI ? 'e2e/snapshots.ci' : 'e2e/snapshots.user',

0 commit comments

Comments
 (0)