viewev 0.1.0-beta.0 → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -27
- package/dist/baselines/memory-store.d.ts +3 -0
- package/dist/baselines/memory-store.js +15 -0
- package/dist/baselines/memory-store.js.map +1 -0
- package/dist/browser/playwright/capturer.js.map +1 -1
- package/dist/ci/github-summary.js +23 -8
- package/dist/ci/github-summary.js.map +1 -1
- package/dist/cli/commands/test.js +185 -23
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/doctor.js +17 -8
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/format.d.ts +1 -1
- package/dist/cli/format.js +29 -7
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/impact.d.ts +3 -0
- package/dist/cli/impact.js +21 -15
- package/dist/cli/impact.js.map +1 -1
- package/dist/config/schema.d.ts +175 -1
- package/dist/config/schema.js +24 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/core/result.d.ts +6 -0
- package/dist/core/result.js.map +1 -1
- package/dist/core/test-run.d.ts +3 -1
- package/dist/core/test-run.js +1 -0
- package/dist/core/test-run.js.map +1 -1
- package/dist/impact/storybook.d.ts +16 -0
- package/dist/impact/storybook.js +324 -0
- package/dist/impact/storybook.js.map +1 -0
- package/dist/impact/types.d.ts +4 -0
- package/dist/impact/types.js.map +1 -1
- package/dist/reference/build.d.ts +10 -0
- package/dist/reference/build.js +36 -0
- package/dist/reference/build.js.map +1 -0
- package/dist/reference/git-worktree.d.ts +8 -0
- package/dist/reference/git-worktree.js +77 -0
- package/dist/reference/git-worktree.js.map +1 -0
- package/dist/reference/open.d.ts +13 -0
- package/dist/reference/open.js +66 -0
- package/dist/reference/open.js.map +1 -0
- package/dist/reporting/html.js +19 -12
- package/dist/reporting/html.js.map +1 -1
- package/dist/reporting/results-json.d.ts +2 -1
- package/dist/reporting/results-json.js +1 -0
- package/dist/reporting/results-json.js.map +1 -1
- package/docs/architecture.md +55 -59
- package/docs/ci.md +51 -177
- package/docs/impact.md +27 -12
- package/docs/publishing.md +35 -0
- package/package.json +1 -1
package/dist/reporting/html.js
CHANGED
|
@@ -56,7 +56,7 @@ function details(scenario) {
|
|
|
56
56
|
rows.map(([name, value]) => `<tr><th>${e(name)}</th><td>${e(value)}</td></tr>`).join('') +
|
|
57
57
|
'</table>');
|
|
58
58
|
}
|
|
59
|
-
function summaryText(scenario) {
|
|
59
|
+
function summaryText(scenario, hasReference) {
|
|
60
60
|
const { outcome } = scenario;
|
|
61
61
|
switch (outcome.status) {
|
|
62
62
|
case 'passed':
|
|
@@ -66,7 +66,9 @@ function summaryText(scenario) {
|
|
|
66
66
|
? `size changed ${outcome.expected.width}x${outcome.expected.height} → ${outcome.actual.width}x${outcome.actual.height}`
|
|
67
67
|
: `${percent(outcome.stats.diffRatio)} different (${outcome.stats.diffPixels} of ${outcome.stats.totalPixels} px)`;
|
|
68
68
|
case 'missing-baseline':
|
|
69
|
-
return
|
|
69
|
+
return hasReference
|
|
70
|
+
? 'no matching scenario on the target branch'
|
|
71
|
+
: 'no approved baseline yet';
|
|
70
72
|
case 'changed':
|
|
71
73
|
if (outcome.change === 'added')
|
|
72
74
|
return 'new baseline proposed by this change';
|
|
@@ -77,7 +79,7 @@ function summaryText(scenario) {
|
|
|
77
79
|
return `[${outcome.error.phase}] ${outcome.error.message}`;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
|
-
function body(scenario) {
|
|
82
|
+
function body(scenario, hasReference) {
|
|
81
83
|
const { outcome, id } = scenario;
|
|
82
84
|
switch (outcome.status) {
|
|
83
85
|
case 'passed':
|
|
@@ -85,7 +87,7 @@ function body(scenario) {
|
|
|
85
87
|
case 'error':
|
|
86
88
|
return `<p class="error-text">${e(outcome.error.message)}</p>`;
|
|
87
89
|
case 'missing-baseline':
|
|
88
|
-
return `<div class="images">${figure('Actual', outcome.artifacts.actual, id)}</div>`;
|
|
90
|
+
return `<div class="images">${figure(hasReference ? 'Current UI' : 'Actual', outcome.artifacts.actual, id)}</div>`;
|
|
89
91
|
case 'changed': {
|
|
90
92
|
const { expected, actual, diff } = outcome.artifacts;
|
|
91
93
|
return (`<p class="muted">The approved baseline differs, but this change proposes a matching one. ` +
|
|
@@ -100,16 +102,17 @@ function body(scenario) {
|
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
|
-
function scenarioHtml(scenario) {
|
|
105
|
+
function scenarioHtml(scenario, hasReference) {
|
|
104
106
|
const { status } = scenario.outcome;
|
|
105
|
-
const
|
|
107
|
+
const statusLabel = status === 'missing-baseline' && hasReference ? 'New scenario' : STATUS_LABELS[status];
|
|
108
|
+
const label = `<span class="badge ${status}">${statusLabel}</span>`;
|
|
106
109
|
const title = `${label} <span class="id">${e(scenario.id)}</span> ` +
|
|
107
|
-
`<span class="muted">${e(scenario.name)}</span> <span class="muted">— ${e(summaryText(scenario))}</span>`;
|
|
110
|
+
`<span class="muted">${e(scenario.name)}</span> <span class="muted">— ${e(summaryText(scenario, hasReference))}</span>`;
|
|
108
111
|
if (status === 'passed') {
|
|
109
112
|
return `<div class="scenario row" data-status="${status}">${title}</div>`;
|
|
110
113
|
}
|
|
111
114
|
return (`<details class="scenario" data-status="${status}" open><summary>${title}</summary>` +
|
|
112
|
-
`${body(scenario)}${details(scenario)}</details>`);
|
|
115
|
+
`${body(scenario, hasReference)}${details(scenario)}</details>`);
|
|
113
116
|
}
|
|
114
117
|
const STYLE = `
|
|
115
118
|
:root{color-scheme:light dark;--bg:#fff;--fg:#161616;--muted:#6f6f6f;--line:#d0d0d0;--card:#f4f4f4;
|
|
@@ -179,6 +182,7 @@ export function renderReportHtml(file) {
|
|
|
179
182
|
const filterLabels = {
|
|
180
183
|
all: 'All',
|
|
181
184
|
...STATUS_LABELS,
|
|
185
|
+
'missing-baseline': file.reference !== undefined ? 'New scenario' : 'No baseline',
|
|
182
186
|
};
|
|
183
187
|
const buttons = FILTERS.map((f) => `<button type="button" data-set-filter="${f}" aria-pressed="${f === 'all'}">` +
|
|
184
188
|
`${filterLabels[f]} (${counts[f]})</button>`).join('');
|
|
@@ -208,8 +212,10 @@ export function renderReportHtml(file) {
|
|
|
208
212
|
`<ul class="plain">${removed.map((id) => `<li class="id">${e(id)}</li>`).join('')}</ul>`
|
|
209
213
|
: '';
|
|
210
214
|
const obsolete = file.obsolete.length > 0
|
|
211
|
-
? `<h2
|
|
212
|
-
|
|
215
|
+
? `<h2>${file.reference !== undefined ? 'Scenarios removed since reference' : 'Obsolete baselines'} (${file.obsolete.length})</h2>` +
|
|
216
|
+
(file.reference !== undefined
|
|
217
|
+
? `<p class="muted">These scenarios exist on ${e(file.reference.ref)} but not in the current UI.</p>`
|
|
218
|
+
: '<p class="muted">These baselines have no matching scenario. Remove them with <code>viewev baseline prune --yes</code>.</p>') +
|
|
213
219
|
`<ul class="plain">${file.obsolete.map((id) => `<li class="id">${e(id)}</li>`).join('')}</ul>`
|
|
214
220
|
: '';
|
|
215
221
|
return `<!doctype html>
|
|
@@ -225,17 +231,18 @@ export function renderReportHtml(file) {
|
|
|
225
231
|
<h1>Viewev report</h1>
|
|
226
232
|
<div class="muted"><time datetime="${e(file.startedAt)}">${e(file.startedAt)}</time> · ${file.durationMs} ms</div>
|
|
227
233
|
<div class="muted">${environment}</div>
|
|
234
|
+
${file.reference !== undefined ? `<div class="muted">Reference UI: ${e(file.reference.ref)} (${e(file.reference.commit.slice(0, 12))})</div>` : ''}
|
|
228
235
|
${selectionHtml}
|
|
229
236
|
<div class="counts">${buttons}</div>
|
|
230
237
|
</header>
|
|
231
238
|
<main data-filter="all">
|
|
232
239
|
${warnings}
|
|
233
240
|
<h2>Scenarios</h2>
|
|
234
|
-
${sorted.length > 0 ? sorted.map(scenarioHtml).join('\n') : '<p class="muted">No scenarios were run.</p>'}
|
|
241
|
+
${sorted.length > 0 ? sorted.map((scenario) => scenarioHtml(scenario, file.reference !== undefined)).join('\n') : '<p class="muted">No scenarios were run.</p>'}
|
|
235
242
|
${obsolete}
|
|
236
243
|
${removedHtml}
|
|
237
244
|
</main>
|
|
238
|
-
<footer class="muted"
|
|
245
|
+
<footer class="muted">${file.reference !== undefined ? `Generated by Viewev. Expected images are fresh captures from ${e(file.reference.ref)} (${e(file.reference.commit.slice(0, 12))}).` : 'Generated by Viewev. Approve intended changes with <code>viewev baseline update</code> and review the changed images in Git.'}</footer>
|
|
239
246
|
<script>${SCRIPT}</script>
|
|
240
247
|
</body>
|
|
241
248
|
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/reporting/html.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,CAAC,GAAG,UAAU,CAAC;AAErB,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,kBAAkB,EAAE,QAAQ,CAAU,CAAC;AAE/F,MAAM,aAAa,GAAuD;IACxE,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,oBAAoB;IAC7B,kBAAkB,EAAE,aAAa;IACjC,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,SAAS,OAAO,CAAC,KAAa;IAC5B,MAAM,KAAK,GAAG,KAAK,GAAG,GAAG,CAAC;IAC1B,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACvE,CAAC;AAED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WAAW;;wBAEW,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,gEAAgE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,8HAA8H;UACjT,MAAM;;;CAGf,CAAC;AACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RunResult, RunSummary, ScenarioOutcome, SelectionInfo } from '../core/result.js';
|
|
1
|
+
import type { ReferenceInfo, RunResult, RunSummary, ScenarioOutcome, SelectionInfo } from '../core/result.js';
|
|
2
2
|
import type { EnvironmentInfo } from '../shared/environment.js';
|
|
3
3
|
import type { Size } from '../shared/size.js';
|
|
4
4
|
export declare const RESULTS_FILE_NAME = "results.json";
|
|
@@ -7,6 +7,7 @@ export interface ResultsFile {
|
|
|
7
7
|
readonly startedAt: string;
|
|
8
8
|
readonly durationMs: number;
|
|
9
9
|
readonly environment?: EnvironmentInfo;
|
|
10
|
+
readonly reference?: ReferenceInfo;
|
|
10
11
|
readonly summary: RunSummary;
|
|
11
12
|
readonly warnings: readonly string[];
|
|
12
13
|
readonly scenarios: ReadonlyArray<{
|
|
@@ -9,6 +9,7 @@ export function toResultsFile(result) {
|
|
|
9
9
|
startedAt: result.startedAt,
|
|
10
10
|
durationMs: result.durationMs,
|
|
11
11
|
...(result.environment !== undefined ? { environment: result.environment } : {}),
|
|
12
|
+
...(result.reference !== undefined ? { reference: result.reference } : {}),
|
|
12
13
|
summary: summarize(result),
|
|
13
14
|
warnings: result.warnings ?? [],
|
|
14
15
|
scenarios: result.scenarios.map(({ scenario, outcome, durationMs, clipped }) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results-json.js","sourceRoot":"","sources":["../../src/reporting/results-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,K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/docs/architecture.md
CHANGED
|
@@ -10,7 +10,8 @@ the source of truth for those boundaries and for the decisions behind them.
|
|
|
10
10
|
- Automation-independent: the core never sees Playwright types.
|
|
11
11
|
- Local-first: no hosted service, database or account.
|
|
12
12
|
- Deterministic: reproducible screenshots matter more than features.
|
|
13
|
-
-
|
|
13
|
+
- Fresh PR references: each pull request compares against a newly built capture of its target
|
|
14
|
+
branch; local image baselines remain an explicit optional workflow.
|
|
14
15
|
- No speculative abstractions: an interface exists only where it protects a real boundary.
|
|
15
16
|
|
|
16
17
|
## Modules and dependency rules
|
|
@@ -22,6 +23,8 @@ src/
|
|
|
22
23
|
core/ lifecycle orchestration and the result model (interfaces only)
|
|
23
24
|
scenarios/ VisualScenario, ScenarioProvider, validation
|
|
24
25
|
adapters/storybook/ index.json -> scenarios, built-in static server
|
|
26
|
+
impact/ changed-file analysis and Storybook dependency tracing
|
|
27
|
+
reference/ temporary Git worktrees, target-branch builds and cleanup
|
|
25
28
|
browser/ ScreenshotCapturer interface and types
|
|
26
29
|
browser/playwright/ the only code that imports Playwright
|
|
27
30
|
comparison/ pure image comparison with Pixelmatch
|
|
@@ -53,14 +56,13 @@ A scenario is a UI state Viewev can capture. Providers resolve everything provid
|
|
|
53
56
|
## Test lifecycle
|
|
54
57
|
|
|
55
58
|
1. Load and validate configuration.
|
|
56
|
-
2. Discover scenarios through the configured provider, then validate them.
|
|
57
|
-
3.
|
|
58
|
-
4.
|
|
59
|
-
5.
|
|
60
|
-
6.
|
|
61
|
-
7.
|
|
62
|
-
8.
|
|
63
|
-
9. Map the result to an exit code.
|
|
59
|
+
2. Discover current-branch scenarios through the configured provider, then validate them.
|
|
60
|
+
3. For a fresh-reference run, check out and build the target branch, then discover its scenarios.
|
|
61
|
+
4. Compare Git changes with provider impact mapping before opening a capture session.
|
|
62
|
+
5. Capture only selected scenarios on both branches, with bounded concurrency and fresh contexts.
|
|
63
|
+
6. Compare corresponding screenshots and record regressions, new and removed scenarios, or errors.
|
|
64
|
+
7. Write `results.json`, the HTML report and the CI job summary.
|
|
65
|
+
8. Map the result to an exit code.
|
|
64
66
|
|
|
65
67
|
Exit codes: `0` passed, `1` visual failures, `2` execution errors (take precedence over `1`
|
|
66
68
|
because the run is incomplete), `3` configuration or usage error.
|
|
@@ -86,53 +88,47 @@ by explicit configuration, never by hiding large areas.
|
|
|
86
88
|
- Defaults (`colorThreshold: 0.1`, `maxDiffPixels: 0`) are validated in Phase 2 by a
|
|
87
89
|
repeated-capture determinism test.
|
|
88
90
|
|
|
89
|
-
## Baselines
|
|
91
|
+
## Baselines and target references
|
|
90
92
|
|
|
91
93
|
```
|
|
92
94
|
.viewev/baselines/<environment-key>/<scenario-id>.png
|
|
93
95
|
.viewev/baselines/<environment-key>/<scenario-id>.json # sidecar metadata
|
|
94
96
|
```
|
|
95
97
|
|
|
96
|
-
- The environment key is `<platform>-<browser>`, for example `linux-chromium`.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
recommend committing only the Linux baselines produced in CI as the shared gate.
|
|
98
|
+
- The environment key is `<platform>-<browser>`, for example `linux-chromium`. Optional local
|
|
99
|
+
baselines remain environment-specific. PR references and actual captures are taken in the same
|
|
100
|
+
run and environment, so CI does not need committed image files.
|
|
100
101
|
- One sidecar per image avoids merge conflicts. It records the scenario id, environment (browser
|
|
101
102
|
and automation versions, OS), viewport, device scale factor, screenshot size, a SHA-256 of the
|
|
102
103
|
PNG and any variant. `schemaVersion` is the metadata format version; history is Git's job.
|
|
103
|
-
- `viewev test` never writes baselines.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
- `viewev test` never writes stored baselines. In PR mode, target-branch screenshots are held in
|
|
105
|
+
memory for the current run. Local `baseline create`, `baseline update` and `baseline prune`
|
|
106
|
+
remain available for projects that use image baselines.
|
|
107
|
+
- When `reference` is configured, the CLI makes a disposable worktree at the target Git ref,
|
|
108
|
+
runs project-defined install/build commands there, and captures the target UI into a memory
|
|
109
|
+
store. The store is discarded after comparison. No baseline approval commit is part of PR flow.
|
|
110
|
+
- Build commands are project configuration. Viewev does not choose a package manager or build
|
|
111
|
+
tool. The Storybook output is located using `provider.staticDir` inside the reference worktree.
|
|
109
112
|
- Baselines are stored in plain Git. Git LFS is not used for now.
|
|
110
113
|
|
|
111
114
|
## Pull requests
|
|
112
115
|
|
|
113
|
-
CI compares
|
|
114
|
-
|
|
115
|
-
`--
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
4. If the actual screenshot matches neither baseline, the scenario is a regression.
|
|
130
|
-
|
|
131
|
-
Obsolete baselines fail the run by default (`baselines.failOnObsolete`). Deleting a baseline in
|
|
132
|
-
the PR is a proposed, reviewable change in the same way.
|
|
133
|
-
|
|
134
|
-
CI security: tests run on `pull_request` with read-only permissions and no secrets. Baseline
|
|
135
|
-
updates run in a separate workflow started by a maintainer, on trusted refs. `pull_request_target`
|
|
116
|
+
When `reference` is configured, CI compares screenshots from the PR against fresh captures from
|
|
117
|
+
the target branch. GitHub Actions provides `GITHUB_BASE_REF`; other CI systems can pass
|
|
118
|
+
`--compare-ref` or configure `reference.baseRef`. The target ref must be fetched before Viewev runs.
|
|
119
|
+
|
|
120
|
+
Before taking screenshots, the Storybook impact analyzer traces JavaScript, TypeScript and style
|
|
121
|
+
imports from each story. It selects stories whose dependency graph contains a changed file. If the
|
|
122
|
+
story entry or a dependency cannot be resolved, or a changed file cannot be mapped, Viewev selects
|
|
123
|
+
all scenarios. Other providers can supply `impact.module` to map their own source changes.
|
|
124
|
+
|
|
125
|
+
Scenarios on both refs are captured and compared. New stories are shown as new because the target
|
|
126
|
+
branch has no corresponding scenario. Removed stories are listed from the target branch inventory.
|
|
127
|
+
Pixel and dimension differences fail the run and include expected, actual and diff images in the
|
|
128
|
+
report.
|
|
129
|
+
|
|
130
|
+
CI security: tests run on `pull_request` with read-only permissions and no secrets. The target
|
|
131
|
+
branch build runs in that same untrusted job, so it must not require secrets. `pull_request_target`
|
|
136
132
|
is never combined with a checkout of PR code.
|
|
137
133
|
|
|
138
134
|
## Variants
|
|
@@ -140,8 +136,7 @@ is never combined with a checkout of PR code.
|
|
|
140
136
|
A variant is another way of rendering every story, such as a theme or a narrow viewport. The
|
|
141
137
|
config lists them; the Storybook adapter expands each story into one scenario per variant with
|
|
142
138
|
ids like `button--primary@g100`, passing Storybook globals through the story URL. The core
|
|
143
|
-
never knows what a variant means.
|
|
144
|
-
nothing changes.
|
|
139
|
+
never knows what a variant means. Local baseline sidecars record the variant.
|
|
145
140
|
|
|
146
141
|
## Dependencies
|
|
147
142
|
|
|
@@ -161,20 +156,21 @@ Sharp is not used in v1: nothing in the MVP needs resizing.
|
|
|
161
156
|
(done).
|
|
162
157
|
3. Comparison and baselines: Pixelmatch, baseline store, `test` and `baseline` commands (done).
|
|
163
158
|
4. Reporting and CLI polish: static HTML report, `report` and `doctor` commands (done).
|
|
164
|
-
5. CI and branch-aware baselines: GitHub Actions summary,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
159
|
+
5. CI and branch-aware image baselines: GitHub Actions summary, optional legacy image-baseline
|
|
160
|
+
mode and impact-analysis extension were implemented.
|
|
161
|
+
6. Fresh target-branch comparison: disposable Git worktrees, project-defined reference builds,
|
|
162
|
+
in-memory reference captures and Storybook source-impact analysis are implemented. Consumer CI
|
|
163
|
+
validation remains. Carbon-specific config stays outside Viewev.
|
|
168
164
|
|
|
169
165
|
## Decision log
|
|
170
166
|
|
|
171
|
-
| Decision | Outcome
|
|
172
|
-
| ------------------ |
|
|
173
|
-
| PR
|
|
174
|
-
| Platforms | macOS, Linux and Windows; baselines keyed by environment
|
|
175
|
-
| Capture area | Viewport only
|
|
176
|
-
| Sharp | Dropped from v1; `pngjs` instead
|
|
177
|
-
| Variants | Implemented in the Storybook adapter and baseline metadata
|
|
178
|
-
| Obsolete baselines | Fail by default
|
|
179
|
-
| Git LFS | Not for now
|
|
180
|
-
| Package manager | npm
|
|
167
|
+
| Decision | Outcome |
|
|
168
|
+
| ------------------ | --------------------------------------------------------------------------------- |
|
|
169
|
+
| PR comparison | Capture the target branch and PR branch in the same run; store no approved images |
|
|
170
|
+
| Platforms | macOS, Linux and Windows; baselines keyed by environment |
|
|
171
|
+
| Capture area | Viewport only |
|
|
172
|
+
| Sharp | Dropped from v1; `pngjs` instead |
|
|
173
|
+
| Variants | Implemented in the Storybook adapter and baseline metadata |
|
|
174
|
+
| Obsolete baselines | Fail by default |
|
|
175
|
+
| Git LFS | Not for now |
|
|
176
|
+
| Package manager | Viewev publishes as an npm package; consumer build commands are project-defined |
|
package/docs/ci.md
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
# Running Viewev in GitHub Actions
|
|
2
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
|
-
.viewev/baselines/darwin-*
|
|
31
|
-
.viewev/baselines/win32-*
|
|
3
|
+
Pull request runs compare the UI from the PR with a fresh build and capture from the target
|
|
4
|
+
branch. They do not download or update approved image baselines. Viewev creates a temporary Git
|
|
5
|
+
worktree for the target ref, runs the configured reference build commands there, and discards the
|
|
6
|
+
captured reference images after the run.
|
|
7
|
+
|
|
8
|
+
## Configure the reference build
|
|
9
|
+
|
|
10
|
+
`reference.build` contains commands that install and build the target branch's Storybook. They run
|
|
11
|
+
in order from the target checkout root. Use the same Node version, package manager and build
|
|
12
|
+
settings as the PR build.
|
|
13
|
+
|
|
14
|
+
For Yarn 4:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
// viewev.config.mjs
|
|
18
|
+
export default {
|
|
19
|
+
provider: { type: 'storybook', staticDir: 'packages/react/storybook-static' },
|
|
20
|
+
reference: {
|
|
21
|
+
baseRef: 'origin/main',
|
|
22
|
+
build: [
|
|
23
|
+
{ command: 'corepack', args: ['yarn', 'install', '--immutable'] },
|
|
24
|
+
{ command: 'corepack', args: ['yarn', 'workspace', '@your-scope/react', 'storybook:build'] },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
32
28
|
```
|
|
33
29
|
|
|
34
|
-
|
|
30
|
+
For npm, use commands such as `{ command: 'npm', args: ['ci'] }` and
|
|
31
|
+
`{ command: 'npm', args: ['run', 'build-storybook'] }`. The command names and arguments are
|
|
32
|
+
project configuration; Viewev does not assume a package manager or workspace layout.
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
## Pull request workflow
|
|
37
35
|
|
|
38
36
|
```yaml
|
|
39
37
|
name: Visual tests
|
|
@@ -41,172 +39,48 @@ name: Visual tests
|
|
|
41
39
|
on: pull_request
|
|
42
40
|
|
|
43
41
|
permissions:
|
|
44
|
-
contents: read
|
|
42
|
+
contents: read
|
|
45
43
|
|
|
46
44
|
jobs:
|
|
47
45
|
visual:
|
|
48
46
|
runs-on: ubuntu-latest
|
|
49
|
-
# The tag must match the playwright-core version that Viewev pins.
|
|
50
47
|
container: mcr.microsoft.com/playwright:v1.60.0-noble
|
|
51
48
|
steps:
|
|
52
|
-
- uses: actions/checkout@v4
|
|
49
|
+
- uses: actions/checkout@v4
|
|
53
50
|
with:
|
|
54
|
-
fetch-depth: 0 #
|
|
51
|
+
fetch-depth: 0 # the target branch ref and merge base must be present
|
|
55
52
|
|
|
56
53
|
- uses: actions/setup-node@v4
|
|
57
54
|
with:
|
|
58
55
|
node-version-file: .nvmrc
|
|
59
|
-
cache:
|
|
60
|
-
- run: npm ci
|
|
61
|
-
- run: npm run build-storybook # your command that writes the static Storybook
|
|
56
|
+
cache: yarn
|
|
62
57
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
--proposed-dir .viewev/baselines
|
|
58
|
+
# Install and build the pull request UI using the repository's normal commands.
|
|
59
|
+
- run: corepack yarn install --immutable
|
|
60
|
+
- run: corepack yarn workspace @your-scope/react storybook:build
|
|
67
61
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
|
72
|
-
npx viewev baseline update --all
|
|
73
|
-
npx viewev baseline prune --yes
|
|
74
|
-
git add -A .viewev/baselines
|
|
75
|
-
git diff --cached --name-status -- .viewev/baselines > proposal.txt
|
|
76
|
-
tar -cf proposal.tar $(git diff --cached --name-only --diff-filter=AM -- .viewev/baselines) 2>/dev/null || true
|
|
62
|
+
# GITHUB_BASE_REF selects the target branch automatically. Viewev builds that ref using
|
|
63
|
+
# reference.build, then captures only affected stories on both refs when it can map them.
|
|
64
|
+
- run: corepack yarn viewev test
|
|
77
65
|
|
|
78
66
|
- uses: actions/upload-artifact@v4
|
|
79
67
|
if: always()
|
|
80
68
|
with:
|
|
81
69
|
name: viewev-report
|
|
82
70
|
path: .viewev/report
|
|
83
|
-
|
|
84
|
-
- uses: actions/upload-artifact@v4
|
|
85
|
-
if: always()
|
|
86
|
-
with:
|
|
87
|
-
name: viewev-proposal
|
|
88
|
-
path: |
|
|
89
|
-
proposal.txt
|
|
90
|
-
proposal.tar
|
|
91
71
|
```
|
|
92
72
|
|
|
93
|
-
The
|
|
94
|
-
|
|
95
|
-
`
|
|
96
|
-
|
|
97
|
-
For a Yarn project, add Viewev with `yarn add --dev viewev@beta`, install dependencies in CI with
|
|
98
|
-
the lockfile-appropriate command (`yarn install --immutable` for modern Yarn or
|
|
99
|
-
`yarn install --frozen-lockfile` for Yarn Classic), and invoke the CLI with `yarn viewev`.
|
|
100
|
-
|
|
101
|
-
Pull requests from forks get a read-only token, so they can run the tests and upload artifacts
|
|
102
|
-
but cannot receive baseline commits; a maintainer applies the proposal manually.
|
|
103
|
-
|
|
104
|
-
## Proposing baselines automatically
|
|
73
|
+
The PR capture runs with read-only permissions and no secrets. The target branch's build commands
|
|
74
|
+
also run inside this job, so they must not need secrets. Use `pull_request`; do not combine
|
|
75
|
+
`pull_request_target` with a checkout or build of PR code.
|
|
105
76
|
|
|
106
|
-
The
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
77
|
+
The built-in Storybook analyzer follows static JavaScript, TypeScript and stylesheet imports from
|
|
78
|
+
each story. Other providers can define `impact.module`; in a fresh-reference run, that module
|
|
79
|
+
receives the changed files, both scenario lists, and both repository roots. Viewev runs all
|
|
80
|
+
scenarios when source mapping is incomplete or a changed file cannot be mapped. The HTML report
|
|
81
|
+
and GitHub job summary show the target ref, selected scenarios, regressions and
|
|
82
|
+
expected/actual/diff images. New and removed stories are listed separately.
|
|
110
83
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
name: Apply visual baseline proposal
|
|
115
|
-
|
|
116
|
-
on:
|
|
117
|
-
workflow_run:
|
|
118
|
-
workflows: ['Visual tests']
|
|
119
|
-
types: [completed]
|
|
120
|
-
|
|
121
|
-
permissions:
|
|
122
|
-
contents: write
|
|
123
|
-
pull-requests: read
|
|
124
|
-
actions: read
|
|
125
|
-
|
|
126
|
-
jobs:
|
|
127
|
-
apply:
|
|
128
|
-
# Same-repository branches only; fork branches cannot be pushed to.
|
|
129
|
-
if: >
|
|
130
|
-
github.event.workflow_run.event == 'pull_request' &&
|
|
131
|
-
github.event.workflow_run.head_repository.full_name == github.repository
|
|
132
|
-
runs-on: ubuntu-latest
|
|
133
|
-
steps:
|
|
134
|
-
- name: Check for the label
|
|
135
|
-
id: label
|
|
136
|
-
env:
|
|
137
|
-
GH_TOKEN: ${{ github.token }}
|
|
138
|
-
PR: ${{ github.event.workflow_run.pull_requests[0].number }}
|
|
139
|
-
run: |
|
|
140
|
-
labels=$(gh pr view "$PR" --repo "$GITHUB_REPOSITORY" --json labels --jq '.labels[].name')
|
|
141
|
-
if echo "$labels" | grep -qx 'update-visual-baselines'; then echo "apply=true" >> "$GITHUB_OUTPUT"; fi
|
|
142
|
-
|
|
143
|
-
- uses: actions/checkout@v4
|
|
144
|
-
if: steps.label.outputs.apply == 'true'
|
|
145
|
-
with:
|
|
146
|
-
ref: ${{ github.event.workflow_run.head_branch }}
|
|
147
|
-
|
|
148
|
-
- uses: actions/download-artifact@v4
|
|
149
|
-
if: steps.label.outputs.apply == 'true'
|
|
150
|
-
with:
|
|
151
|
-
name: viewev-proposal
|
|
152
|
-
path: proposal
|
|
153
|
-
run-id: ${{ github.event.workflow_run.id }}
|
|
154
|
-
github-token: ${{ github.token }}
|
|
155
|
-
|
|
156
|
-
- name: Validate and apply
|
|
157
|
-
if: steps.label.outputs.apply == 'true'
|
|
158
|
-
run: |
|
|
159
|
-
set -euo pipefail
|
|
160
|
-
pattern='^\.viewev/baselines/linux-chromium/[a-z0-9][a-z0-9._@-]*\.(png|json)$'
|
|
161
|
-
|
|
162
|
-
# Never trust the artifact: check every path before extracting anything.
|
|
163
|
-
if [ -s proposal/proposal.tar ]; then
|
|
164
|
-
tar -tf proposal/proposal.tar | while read -r path; do
|
|
165
|
-
echo "$path" | grep -Eq "$pattern" || { echo "Unexpected path: $path"; exit 1; }
|
|
166
|
-
done
|
|
167
|
-
tar -xf proposal/proposal.tar
|
|
168
|
-
fi
|
|
169
|
-
|
|
170
|
-
# Deleted baselines are listed as "D<TAB>path" in proposal.txt.
|
|
171
|
-
awk -F'\t' '$1 == "D" { print $2 }' proposal/proposal.txt | while read -r path; do
|
|
172
|
-
echo "$path" | grep -Eq "$pattern" || { echo "Unexpected path: $path"; exit 1; }
|
|
173
|
-
rm -f -- "$path"
|
|
174
|
-
done
|
|
175
|
-
|
|
176
|
-
- name: Commit
|
|
177
|
-
if: steps.label.outputs.apply == 'true'
|
|
178
|
-
run: |
|
|
179
|
-
git config user.name "viewev[bot]"
|
|
180
|
-
git config user.email "viewev@users.noreply.github.com"
|
|
181
|
-
git add -A .viewev/baselines
|
|
182
|
-
git diff --cached --quiet || git commit -m "chore: update visual baselines"
|
|
183
|
-
git push
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
The push triggers the pull request workflow again. This time the proposed baselines match the
|
|
187
|
-
screenshots, so the run reports the visual changes as **changed** instead of failing, and the
|
|
188
|
-
reviewers see the old and new images in the pull request.
|
|
189
|
-
|
|
190
|
-
Make sure the token that pushes is allowed to trigger workflows (a push made with the default
|
|
191
|
-
`GITHUB_TOKEN` does not start new workflow runs; use a GitHub App token or a fine-grained
|
|
192
|
-
personal access token if you want the check to refresh automatically).
|
|
193
|
-
|
|
194
|
-
## Require review of baseline changes
|
|
195
|
-
|
|
196
|
-
`.github/CODEOWNERS`
|
|
197
|
-
|
|
198
|
-
```
|
|
199
|
-
/.viewev/baselines/ @your-org/design-system-maintainers
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
Turn on "Require review from Code Owners" for the target branch. Then a visual change can only
|
|
203
|
-
be merged after the owners approved the changed baseline images.
|
|
204
|
-
|
|
205
|
-
## Generating Linux baselines locally
|
|
206
|
-
|
|
207
|
-
On macOS or Windows you can produce the Linux baselines in the same container CI uses:
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
docker run --rm -v "$PWD":/work -w /work mcr.microsoft.com/playwright:v1.60.0-noble \
|
|
211
|
-
npx viewev baseline update --all
|
|
212
|
-
```
|
|
84
|
+
To select a different target manually, pass `viewev test --compare-ref <ref>`. The ref must be
|
|
85
|
+
available in the checkout. You can run a full capture with `--filter` patterns, but impact
|
|
86
|
+
analysis otherwise selects the affected scenarios before screenshots are taken.
|