Skip to content

Commit 1bd39d3

Browse files
Add github action to run visual regression tests on PRs
1 parent 5acdf2a commit 1bd39d3

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Workflows that run visual regression tests on Flare26 components
2+
3+
name: Visual regression tests
4+
run-name: "Visual regression tests for ${{ github.head_ref || github.ref_name }}"
5+
on:
6+
push:
7+
branches:
8+
- 'main'
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- 'springfield/cms/templates/components/**'
14+
- 'springfield/cms/templates/pattern-library/components/flare-26/**'
15+
- 'media/css/cms/**'
16+
- 'tests/playwright/specs/visual-regression/**'
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
visual-regression-tests:
23+
if: always() && github.repository == 'mozmeao/springfield'
24+
runs-on: ubuntu-latest
25+
env:
26+
CI: true
27+
steps:
28+
- uses: actions/checkout@v6
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.13'
32+
- uses: astral-sh/setup-uv@v5
33+
- name: Install Python dependencies
34+
run: uv pip install -r requirements/dev.txt
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: 20
38+
- name: Build frontend assets
39+
run: npm ci && npm run build
40+
- name: Install Playwright dependencies
41+
run: cd tests/playwright && npm ci && npm run install-deps
42+
- name: Run Playwright tests
43+
run: cd tests/playwright && npm run local:visual-regression-tests
44+
- uses: actions/upload-artifact@v4
45+
if: ${{ !cancelled() }}
46+
with:
47+
name: test-results-${{ github.sha }}-${{ github.run_id }}
48+
path: tests/playwright/test-results/
49+
if-no-files-found: ignore # this avoids a false "Warning" if there were no issues
50+
retention-days: 30

tests/playwright/playwright.visual-regression.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ const baseConfig = require('./playwright.config');
1111

1212
module.exports = defineConfig({
1313
...baseConfig,
14+
webServer: {
15+
command: `uv run --active python manage.py runserver 0.0.0.0:8000`,
16+
url: 'http://localhost:8000/healthz/',
17+
reuseExistingServer: !process.env.CI,
18+
cwd: '../../',
19+
env: {
20+
...process.env,
21+
DEBUG: 'true',
22+
ENABLE_DJANGO_PATTERN_LIBRARY: 'true'
23+
}
24+
},
1425
fullyParallel: false,
1526
grepInvert: undefined,
1627
grep: /@visual-regression/,

0 commit comments

Comments
 (0)