-
Notifications
You must be signed in to change notification settings - Fork 78
141 lines (124 loc) · 4.94 KB
/
Copy pathvisual-regression.yml
File metadata and controls
141 lines (124 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Visual Regression
on:
pull_request:
paths:
# Run when the visual suite, config, or the web UI it screenshots changes.
# Backend package-only changes are verified via the dispatch workflow.
- "web/tests/visual/**"
- "web/playwright.visual.config.ts"
- "web/src/**"
- "web/package.json"
- ".github/workflows/visual-regression.yml"
push:
branches: [main]
paths:
- "web/tests/visual/**"
- "web/playwright.visual.config.ts"
- "web/src/**"
workflow_dispatch:
inputs:
update:
description: "Regenerate baselines and commit them to the branch"
required: false
default: "false"
type: choice
options: ["false", "true"]
permissions:
contents: write # so the update-baselines job can push back to the branch
jobs:
visual:
name: Playwright visual snapshots
runs-on: ubuntu-latest
# Don't run the auto-update path on pull_request — only via dispatch or push
# with inputs.update=true. The comparison run is skipped when updating.
if: ${{ !(github.event.inputs.update == 'true') }}
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build workspace packages
# The seeded screenshot backend (tests/globalSetup.ts) imports
# @nodetool-ai/* via the `development` export condition, which resolves
# to each package's compiled dist/. Build them first, same as the
# documentation-screenshot workflow.
run: npm run build:packages
- name: Install Playwright browsers (chromium + firefox)
working-directory: web
run: npx playwright install chromium firefox --with-deps
- name: Run visual regression tests
working-directory: web
# Report-first phase (per the parent plan): the suite runs on every PR
# and uploads side-by-side diffs as an artifact, but does not block the
# PR yet. Committed baselines are captured outside CI, so cross-renderer
# font anti-aliasing produces diffs until baselines are regenerated in
# CI via the `update=true` dispatch. Flip this to blocking (remove
# continue-on-error) once CI-generated baselines are committed. See
# web/tests/visual/README.md § CI.
continue-on-error: true
env:
# Same deterministic test-only master key committed in
# web/tests/globalSetup.ts. Never use in production.
SECRETS_MASTER_KEY: "U0NSRUVOU0hPVF9URVNUX0tFWV9ET19OT1RfVVNFISE="
run: npm run test:visual
- name: Upload visual baselines + report
uses: actions/upload-artifact@v7
if: always()
with:
name: visual-regression
# Baselines (to download + commit on first run) and the HTML report
# with side-by-side diffs for any failures.
path: |
web/tests/visual/**/*-snapshots/
web/playwright-report/
retention-days: 30
update-baselines:
name: Update visual baselines
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.update == 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: ${{ github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build workspace packages
run: npm run build:packages
- name: Install Playwright browsers
working-directory: web
run: npx playwright install chromium firefox --with-deps
- name: Regenerate baselines
working-directory: web
# A spec that fails for a non-snapshot reason shouldn't discard the
# baselines the other specs just wrote — commit what was produced and
# let the step's own red mark surface the failure.
continue-on-error: true
env:
SECRETS_MASTER_KEY: "U0NSRUVOU0hPVF9URVNUX0tFWV9ET19OT1RfVVNFISE="
run: npm run test:visual:update
- name: Commit updated baselines
if: always()
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Stage the whole suite dir: a `**/*-snapshots/` glob does not survive
# bash here (globstar is off, so `**` collapses to `*` and matches
# nothing), and only the baselines change during an update run.
git add -A -- web/tests/visual
if git diff --cached --quiet; then
echo "No baseline changes to commit."
else
git commit -m "chore(visual): update E2E visual baselines [skip ci]"
git push
fi