viewev 0.1.0-beta.1 → 0.1.0-beta.3
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 +6 -2
- package/dist/cli/baseline-ref.d.ts +6 -0
- package/dist/cli/baseline-ref.js +9 -0
- package/dist/cli/baseline-ref.js.map +1 -1
- package/dist/cli/commands/report.js +23 -4
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/test.js +5 -3
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/impact/storybook.js +80 -33
- package/dist/impact/storybook.js.map +1 -1
- package/dist/reporting/html.d.ts +1 -1
- package/dist/reporting/html.js +212 -154
- package/dist/reporting/html.js.map +1 -1
- package/dist/reporting/report.d.ts +4 -0
- package/dist/reporting/report.js +44 -16
- package/dist/reporting/report.js.map +1 -1
- package/dist/reporting/results-json.d.ts +2 -0
- package/dist/reporting/results-json.js +166 -0
- package/dist/reporting/results-json.js.map +1 -1
- package/docs/architecture.md +5 -0
- package/docs/ci.md +41 -0
- package/docs/examples/github-pages.yml +183 -0
- package/docs/impact.md +5 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/reporting/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/reporting/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,gBAAg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,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC3D,IACE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC9C,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,EACnD,CAAC;YACD,MAAM,IAAI,WAAW,CAAC,6BAA6B,YAAY,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxD,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACvD,MAAM,IAAI,WAAW,CAAC,4BAA4B,YAAY,EAAE,CAAC,CAAC;YACpE,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;YAC5C,MAAM,IAAI,WAAW,CAAC,uCAAuC,YAAY,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,MAAM,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -31,6 +31,8 @@ export interface ResultsFile {
|
|
|
31
31
|
/** Present when impact analysis chose the scenarios. */
|
|
32
32
|
readonly selection?: SelectionInfo;
|
|
33
33
|
}
|
|
34
|
+
/** Validates JSON before it is used to render HTML, especially when supplied by an untrusted PR. */
|
|
35
|
+
export declare function parseResultsFile(value: unknown): ResultsFile | undefined;
|
|
34
36
|
/** The machine-readable result of a run; the HTML report is rendered from it. */
|
|
35
37
|
export declare function toResultsFile(result: RunResult): ResultsFile;
|
|
36
38
|
export declare function writeResultsFile(reportDir: string, result: RunResult): Promise<string>;
|
|
@@ -1,7 +1,173 @@
|
|
|
1
1
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
import { summarize } from '../core/result.js';
|
|
5
|
+
import { scenarioIdSchema } from '../scenarios/schema.js';
|
|
4
6
|
export const RESULTS_FILE_NAME = 'results.json';
|
|
7
|
+
const nonNegativeInt = z.number().int().nonnegative();
|
|
8
|
+
const positiveInt = z.number().int().positive();
|
|
9
|
+
const sizeSchema = z.object({ width: positiveInt, height: positiveInt }).strict();
|
|
10
|
+
const statsSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
diffPixels: nonNegativeInt,
|
|
13
|
+
totalPixels: nonNegativeInt,
|
|
14
|
+
diffRatio: z.number().min(0).max(1),
|
|
15
|
+
})
|
|
16
|
+
.strict();
|
|
17
|
+
const imagePathSchema = z
|
|
18
|
+
.string()
|
|
19
|
+
.regex(/^artifacts\/[A-Za-z0-9._@/-]+\.png$/)
|
|
20
|
+
.refine((value) => !value.split('/').some((part) => part === '.' || part === '..'));
|
|
21
|
+
const artifactsSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
expected: imagePathSchema.optional(),
|
|
24
|
+
actual: imagePathSchema.optional(),
|
|
25
|
+
diff: imagePathSchema.optional(),
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
const outcomeSchema = z.union([
|
|
29
|
+
z.object({ status: z.literal('passed'), stats: statsSchema }).strict(),
|
|
30
|
+
z
|
|
31
|
+
.object({
|
|
32
|
+
status: z.literal('regression'),
|
|
33
|
+
cause: z.literal('pixels'),
|
|
34
|
+
stats: statsSchema,
|
|
35
|
+
artifacts: artifactsSchema,
|
|
36
|
+
})
|
|
37
|
+
.strict(),
|
|
38
|
+
z
|
|
39
|
+
.object({
|
|
40
|
+
status: z.literal('regression'),
|
|
41
|
+
cause: z.literal('dimensions'),
|
|
42
|
+
expected: sizeSchema,
|
|
43
|
+
actual: sizeSchema,
|
|
44
|
+
artifacts: artifactsSchema,
|
|
45
|
+
})
|
|
46
|
+
.strict(),
|
|
47
|
+
z
|
|
48
|
+
.object({
|
|
49
|
+
status: z.literal('changed'),
|
|
50
|
+
change: z.literal('added'),
|
|
51
|
+
artifacts: artifactsSchema,
|
|
52
|
+
})
|
|
53
|
+
.strict(),
|
|
54
|
+
z
|
|
55
|
+
.object({
|
|
56
|
+
status: z.literal('changed'),
|
|
57
|
+
change: z.literal('modified'),
|
|
58
|
+
cause: z.literal('pixels'),
|
|
59
|
+
stats: statsSchema,
|
|
60
|
+
artifacts: artifactsSchema,
|
|
61
|
+
})
|
|
62
|
+
.strict(),
|
|
63
|
+
z
|
|
64
|
+
.object({
|
|
65
|
+
status: z.literal('changed'),
|
|
66
|
+
change: z.literal('modified'),
|
|
67
|
+
cause: z.literal('dimensions'),
|
|
68
|
+
expected: sizeSchema,
|
|
69
|
+
actual: sizeSchema,
|
|
70
|
+
artifacts: artifactsSchema,
|
|
71
|
+
})
|
|
72
|
+
.strict(),
|
|
73
|
+
z.object({ status: z.literal('missing-baseline'), artifacts: artifactsSchema }).strict(),
|
|
74
|
+
z
|
|
75
|
+
.object({
|
|
76
|
+
status: z.literal('error'),
|
|
77
|
+
error: z
|
|
78
|
+
.object({
|
|
79
|
+
phase: z.enum([
|
|
80
|
+
'discover',
|
|
81
|
+
'navigate',
|
|
82
|
+
'ready',
|
|
83
|
+
'stabilize',
|
|
84
|
+
'screenshot',
|
|
85
|
+
'compare',
|
|
86
|
+
'baseline',
|
|
87
|
+
]),
|
|
88
|
+
message: z.string(),
|
|
89
|
+
})
|
|
90
|
+
.strict(),
|
|
91
|
+
})
|
|
92
|
+
.strict(),
|
|
93
|
+
]);
|
|
94
|
+
const environmentSchema = z
|
|
95
|
+
.object({
|
|
96
|
+
browser: z.object({ name: z.literal('chromium'), version: z.string() }).strict(),
|
|
97
|
+
automation: z.object({ name: z.string(), version: z.string() }).strict(),
|
|
98
|
+
os: z
|
|
99
|
+
.object({
|
|
100
|
+
platform: z.enum(['darwin', 'linux', 'win32']),
|
|
101
|
+
arch: z.string(),
|
|
102
|
+
release: z.string(),
|
|
103
|
+
})
|
|
104
|
+
.strict(),
|
|
105
|
+
container: z.boolean(),
|
|
106
|
+
})
|
|
107
|
+
.strict();
|
|
108
|
+
const resultsFileSchema = z
|
|
109
|
+
.object({
|
|
110
|
+
schemaVersion: z.literal(1),
|
|
111
|
+
startedAt: z.string(),
|
|
112
|
+
durationMs: nonNegativeInt,
|
|
113
|
+
environment: environmentSchema.optional(),
|
|
114
|
+
reference: z.object({ ref: z.string(), commit: z.string() }).strict().optional(),
|
|
115
|
+
summary: z
|
|
116
|
+
.object({
|
|
117
|
+
total: nonNegativeInt,
|
|
118
|
+
passed: nonNegativeInt,
|
|
119
|
+
regressions: nonNegativeInt,
|
|
120
|
+
changed: nonNegativeInt,
|
|
121
|
+
missingBaselines: nonNegativeInt,
|
|
122
|
+
errors: nonNegativeInt,
|
|
123
|
+
obsolete: nonNegativeInt,
|
|
124
|
+
removed: nonNegativeInt.optional(),
|
|
125
|
+
})
|
|
126
|
+
.strict(),
|
|
127
|
+
warnings: z.array(z.string()),
|
|
128
|
+
scenarios: z.array(z
|
|
129
|
+
.object({
|
|
130
|
+
id: scenarioIdSchema,
|
|
131
|
+
name: z.string(),
|
|
132
|
+
group: z.array(z.string()).optional(),
|
|
133
|
+
origin: z
|
|
134
|
+
.object({ provider: z.string(), ref: z.string(), source: z.string().optional() })
|
|
135
|
+
.strict(),
|
|
136
|
+
viewport: sizeSchema,
|
|
137
|
+
variant: z.record(z.string()).optional(),
|
|
138
|
+
tags: z.array(z.string()).optional(),
|
|
139
|
+
durationMs: nonNegativeInt,
|
|
140
|
+
clipped: z.boolean().optional(),
|
|
141
|
+
outcome: outcomeSchema,
|
|
142
|
+
})
|
|
143
|
+
.strict()),
|
|
144
|
+
obsolete: z.array(scenarioIdSchema),
|
|
145
|
+
removed: z.array(scenarioIdSchema).optional(),
|
|
146
|
+
selection: z
|
|
147
|
+
.object({
|
|
148
|
+
mode: z.enum(['all', 'impact']),
|
|
149
|
+
total: nonNegativeInt,
|
|
150
|
+
selected: nonNegativeInt,
|
|
151
|
+
baseRef: z.string().optional(),
|
|
152
|
+
changedFileCount: nonNegativeInt.optional(),
|
|
153
|
+
reason: z.string().optional(),
|
|
154
|
+
reasons: z.record(z.array(z.string())).optional(),
|
|
155
|
+
})
|
|
156
|
+
.strict()
|
|
157
|
+
.optional(),
|
|
158
|
+
})
|
|
159
|
+
.strict();
|
|
160
|
+
/** Validates JSON before it is used to render HTML, especially when supplied by an untrusted PR. */
|
|
161
|
+
export function parseResultsFile(value) {
|
|
162
|
+
const parsed = resultsFileSchema.safeParse(value);
|
|
163
|
+
if (!parsed.success)
|
|
164
|
+
return undefined;
|
|
165
|
+
return {
|
|
166
|
+
...parsed.data,
|
|
167
|
+
summary: { ...parsed.data.summary, removed: parsed.data.summary.removed ?? 0 },
|
|
168
|
+
removed: parsed.data.removed ?? [],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
5
171
|
/** The machine-readable result of a run; the HTML report is rendered from it. */
|
|
6
172
|
export function toResultsFile(result) {
|
|
7
173
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results-json.js","sourceRoot":"","sources":["../../src/reporting/results-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"results-json.js","sourceRoot":"","sources":["../../src/reporting/results-json.ts"],"names":[],"mappings":"AAA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,IAAI,CAAC,CAAC;IAC7E,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/docs/architecture.md
CHANGED
|
@@ -131,6 +131,11 @@ CI security: tests run on `pull_request` with read-only permissions and no secre
|
|
|
131
131
|
branch build runs in that same untrusted job, so it must not require secrets. `pull_request_target`
|
|
132
132
|
is never combined with a checkout of PR code.
|
|
133
133
|
|
|
134
|
+
Optional GitHub Pages hosting stays in the consuming repository's workflow. Viewev emits a portable
|
|
135
|
+
static report; a trusted post-run job can validate `results.json`, rerender it, publish it under the
|
|
136
|
+
PR number, and remove that directory when the PR closes. The core CLI does not receive a GitHub
|
|
137
|
+
token or deploy reports itself.
|
|
138
|
+
|
|
134
139
|
## Variants
|
|
135
140
|
|
|
136
141
|
A variant is another way of rendering every story, such as a theme or a narrow viewport. The
|
package/docs/ci.md
CHANGED
|
@@ -81,6 +81,47 @@ scenarios when source mapping is incomplete or a changed file cannot be mapped.
|
|
|
81
81
|
and GitHub job summary show the target ref, selected scenarios, regressions and
|
|
82
82
|
expected/actual/diff images. New and removed stories are listed separately.
|
|
83
83
|
|
|
84
|
+
## Host pull request reports on GitHub Pages
|
|
85
|
+
|
|
86
|
+
Viewev can publish a static report for each open pull request and remove it after the pull request
|
|
87
|
+
is merged or closed. Pages is configured in the consuming repository because each project owns its
|
|
88
|
+
report URLs and retention lifecycle.
|
|
89
|
+
|
|
90
|
+
1. Keep the visual test workflow on `pull_request` with read-only permissions. Upload
|
|
91
|
+
`.viewev/report` as the `viewev-report` artifact.
|
|
92
|
+
2. Copy [the Pages workflow example](examples/github-pages.yml) into `.github/workflows/` in the
|
|
93
|
+
consuming repository. Change `workflows: [Visual tests]` to match the visual workflow's `name`.
|
|
94
|
+
It publishes reports to `pr/<number>/` and removes that directory on the closed event.
|
|
95
|
+
3. Merge the Pages workflow to the default branch, then run a PR visual test once. The publisher
|
|
96
|
+
creates the `gh-pages` branch even before Pages hosting is enabled.
|
|
97
|
+
4. In **Settings → Pages → Build and deployment**, choose **Deploy from a branch**, then select
|
|
98
|
+
`gh-pages` and `/ (root)`.
|
|
99
|
+
5. Optionally define repository variables `VIEWEV_REPORT_REF` (a Viewev tag or commit to use as the
|
|
100
|
+
trusted report renderer) and `VIEWEV_PAGES_URL` (the Pages site URL, without a trailing slash).
|
|
101
|
+
|
|
102
|
+
The publisher and cleanup jobs need `contents: write` for `GITHUB_TOKEN`. Repository or organization
|
|
103
|
+
policy and branch protection must allow that token to update `gh-pages`.
|
|
104
|
+
|
|
105
|
+
The publisher runs from the repository's default branch after the visual workflow completes. It
|
|
106
|
+
does not check out pull request code. It reads the artifact's `results.json`, validates it, copies
|
|
107
|
+
only referenced PNG files, and renders fresh HTML with the trusted Viewev CLI. The workflow uses
|
|
108
|
+
`workflow_run` to gain narrowly scoped write access, so the Pages workflow must first be merged to
|
|
109
|
+
the default branch before it can publish reports for later pull request runs. It also writes
|
|
110
|
+
`.nojekyll` so GitHub serves the generated report files without processing PR supplied text as
|
|
111
|
+
Liquid templates. The separate `pull_request_target` cleanup job uses only the numeric PR number and
|
|
112
|
+
does not read PR code.
|
|
113
|
+
The first PR that adds the publisher cannot trigger it; GitHub loads `workflow_run` handlers from
|
|
114
|
+
the default branch, so use a later PR run to create the initial Pages branch.
|
|
115
|
+
|
|
116
|
+
For a local or custom deployment pipeline, render an artifact into another directory with:
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
viewev report --from .viewev/report --to site/pr/123
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The command validates the results file and copies only the screenshots referenced by it. Do not
|
|
123
|
+
publish the uploaded `index.html` directly from an untrusted pull request artifact.
|
|
124
|
+
|
|
84
125
|
To select a different target manually, pass `viewev test --compare-ref <ref>`. The ref must be
|
|
85
126
|
available in the checkout. You can run a full capture with `--filter` patterns, but impact
|
|
86
127
|
analysis otherwise selects the affected scenarios before screenshots are taken.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
name: Viewev report Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_run:
|
|
5
|
+
workflows: [Visual tests]
|
|
6
|
+
types: [completed]
|
|
7
|
+
pull_request_target:
|
|
8
|
+
types: [closed]
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: viewev-pages-${{ github.event.pull_request.number ||
|
|
15
|
+
github.event.workflow_run.pull_requests[0].number || github.run_id }}
|
|
16
|
+
cancel-in-progress: false
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
publish-report:
|
|
20
|
+
if: github.event_name == 'workflow_run' && github.event.workflow_run.event ==
|
|
21
|
+
'pull_request'
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
permissions:
|
|
24
|
+
actions: read
|
|
25
|
+
contents: write
|
|
26
|
+
pull-requests: read
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
with:
|
|
30
|
+
persist-credentials: true
|
|
31
|
+
|
|
32
|
+
- name: Find the pull request
|
|
33
|
+
id: pr
|
|
34
|
+
uses: actions/github-script@v7
|
|
35
|
+
with:
|
|
36
|
+
script: |
|
|
37
|
+
let pullRequest = context.payload.workflow_run.pull_requests?.[0];
|
|
38
|
+
if (!pullRequest) {
|
|
39
|
+
const associated = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
|
40
|
+
owner: context.repo.owner,
|
|
41
|
+
repo: context.repo.repo,
|
|
42
|
+
commit_sha: context.payload.workflow_run.head_sha,
|
|
43
|
+
});
|
|
44
|
+
pullRequest = associated.data.find((item) => item.state === 'open');
|
|
45
|
+
}
|
|
46
|
+
if (!pullRequest) {
|
|
47
|
+
core.notice('No open pull request is associated with this visual test run.');
|
|
48
|
+
core.setOutput('number', '');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const current = await github.rest.pulls.get({
|
|
52
|
+
owner: context.repo.owner,
|
|
53
|
+
repo: context.repo.repo,
|
|
54
|
+
pull_number: pullRequest.number,
|
|
55
|
+
});
|
|
56
|
+
const testedHead = pullRequest.head?.sha;
|
|
57
|
+
if (current.data.state !== 'open' || (testedHead && testedHead !== current.data.head.sha)) {
|
|
58
|
+
core.notice('This report belongs to a closed or superseded pull request revision.');
|
|
59
|
+
core.setOutput('number', '');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
core.setOutput('number', String(pullRequest.number));
|
|
63
|
+
|
|
64
|
+
- name: Download the report artifact
|
|
65
|
+
id: download
|
|
66
|
+
if: steps.pr.outputs.number != ''
|
|
67
|
+
continue-on-error: true
|
|
68
|
+
uses: actions/download-artifact@v4
|
|
69
|
+
with:
|
|
70
|
+
name: viewev-report
|
|
71
|
+
path: ${{ runner.temp }}/viewev-report
|
|
72
|
+
repository: ${{ github.repository }}
|
|
73
|
+
run-id: ${{ github.event.workflow_run.id }}
|
|
74
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
75
|
+
|
|
76
|
+
- name: Check out the trusted Viewev renderer
|
|
77
|
+
if: steps.download.outcome == 'success'
|
|
78
|
+
uses: actions/checkout@v4
|
|
79
|
+
with:
|
|
80
|
+
repository: viewev/viewev
|
|
81
|
+
ref: ${{ vars.VIEWEV_REPORT_REF || 'main' }}
|
|
82
|
+
path: .viewev-source
|
|
83
|
+
persist-credentials: false
|
|
84
|
+
|
|
85
|
+
- uses: actions/setup-node@v4
|
|
86
|
+
if: steps.download.outcome == 'success'
|
|
87
|
+
with:
|
|
88
|
+
node-version: 22
|
|
89
|
+
|
|
90
|
+
- name: Build the trusted report renderer
|
|
91
|
+
if: steps.download.outcome == 'success'
|
|
92
|
+
run: |
|
|
93
|
+
npm ci
|
|
94
|
+
npm run build
|
|
95
|
+
working-directory: .viewev-source
|
|
96
|
+
|
|
97
|
+
- name: Prepare the Pages worktree
|
|
98
|
+
if: steps.download.outcome == 'success'
|
|
99
|
+
env:
|
|
100
|
+
PAGES_DIR: ${{ runner.temp }}/viewev-pages
|
|
101
|
+
run: |
|
|
102
|
+
git fetch origin gh-pages || true
|
|
103
|
+
if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
|
|
104
|
+
git worktree add -b gh-pages "$PAGES_DIR" origin/gh-pages
|
|
105
|
+
else
|
|
106
|
+
git worktree add --detach "$PAGES_DIR" HEAD
|
|
107
|
+
git -C "$PAGES_DIR" switch --orphan gh-pages
|
|
108
|
+
git -C "$PAGES_DIR" rm -r -f . >/dev/null 2>&1 || true
|
|
109
|
+
git -C "$PAGES_DIR" clean -fdx
|
|
110
|
+
fi
|
|
111
|
+
git -C "$PAGES_DIR" config user.name "github-actions[bot]"
|
|
112
|
+
git -C "$PAGES_DIR" config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
113
|
+
|
|
114
|
+
- name: Render and publish the report
|
|
115
|
+
if: steps.download.outcome == 'success'
|
|
116
|
+
env:
|
|
117
|
+
PR_NUMBER: ${{ steps.pr.outputs.number }}
|
|
118
|
+
PAGES_DIR: ${{ runner.temp }}/viewev-pages
|
|
119
|
+
REPORT_DIR: ${{ runner.temp }}/viewev-report
|
|
120
|
+
PAGES_BASE_URL: ${{ vars.VIEWEV_PAGES_URL || format('https://{0}.github.io/{1}',
|
|
121
|
+
github.repository_owner, github.event.repository.name) }}
|
|
122
|
+
run: |
|
|
123
|
+
case "$PR_NUMBER" in ''|*[!0-9]*) echo "Invalid pull request number" >&2; exit 1 ;; esac
|
|
124
|
+
test -f "$REPORT_DIR/results.json"
|
|
125
|
+
rm -rf -- "$PAGES_DIR/pr/$PR_NUMBER"
|
|
126
|
+
node "$GITHUB_WORKSPACE/.viewev-source/dist/cli/bin.js" report \
|
|
127
|
+
--from "$REPORT_DIR" \
|
|
128
|
+
--to "$PAGES_DIR/pr/$PR_NUMBER"
|
|
129
|
+
touch "$PAGES_DIR/.nojekyll"
|
|
130
|
+
git -C "$PAGES_DIR" add -f -- .nojekyll "pr/$PR_NUMBER"
|
|
131
|
+
if ! git -C "$PAGES_DIR" diff --cached --quiet; then
|
|
132
|
+
git -C "$PAGES_DIR" commit -m "Update Viewev report for PR #$PR_NUMBER"
|
|
133
|
+
for attempt in 1 2 3 4 5; do
|
|
134
|
+
if git -C "$PAGES_DIR" push origin HEAD:gh-pages; then
|
|
135
|
+
break
|
|
136
|
+
fi
|
|
137
|
+
if [ "$attempt" -eq 5 ]; then exit 1; fi
|
|
138
|
+
git fetch origin gh-pages
|
|
139
|
+
git -C "$PAGES_DIR" merge --no-edit --allow-unrelated-histories origin/gh-pages
|
|
140
|
+
done
|
|
141
|
+
fi
|
|
142
|
+
echo "## Viewev report" >> "$GITHUB_STEP_SUMMARY"
|
|
143
|
+
echo "Published: $PAGES_BASE_URL/pr/$PR_NUMBER/" >> "$GITHUB_STEP_SUMMARY"
|
|
144
|
+
|
|
145
|
+
remove-report:
|
|
146
|
+
if: github.event_name == 'pull_request_target'
|
|
147
|
+
runs-on: ubuntu-latest
|
|
148
|
+
permissions:
|
|
149
|
+
contents: write
|
|
150
|
+
steps:
|
|
151
|
+
- uses: actions/checkout@v4
|
|
152
|
+
with:
|
|
153
|
+
persist-credentials: true
|
|
154
|
+
|
|
155
|
+
- name: Remove the closed pull request report
|
|
156
|
+
env:
|
|
157
|
+
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
158
|
+
PAGES_DIR: ${{ runner.temp }}/viewev-pages
|
|
159
|
+
run: |
|
|
160
|
+
case "$PR_NUMBER" in ''|*[!0-9]*) echo "Invalid pull request number" >&2; exit 1 ;; esac
|
|
161
|
+
if ! git ls-remote --exit-code --heads origin gh-pages >/dev/null 2>&1; then
|
|
162
|
+
echo "No Pages report branch exists yet."
|
|
163
|
+
exit 0
|
|
164
|
+
fi
|
|
165
|
+
git fetch origin gh-pages
|
|
166
|
+
git worktree add -b gh-pages "$PAGES_DIR" origin/gh-pages
|
|
167
|
+
git -C "$PAGES_DIR" config user.name "github-actions[bot]"
|
|
168
|
+
git -C "$PAGES_DIR" config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
169
|
+
if [ ! -d "$PAGES_DIR/pr/$PR_NUMBER" ]; then
|
|
170
|
+
echo "No report directory exists for PR #$PR_NUMBER."
|
|
171
|
+
exit 0
|
|
172
|
+
fi
|
|
173
|
+
rm -rf -- "$PAGES_DIR/pr/$PR_NUMBER"
|
|
174
|
+
git -C "$PAGES_DIR" add -A -- "pr/$PR_NUMBER"
|
|
175
|
+
git -C "$PAGES_DIR" commit -m "Remove Viewev report for PR #$PR_NUMBER"
|
|
176
|
+
for attempt in 1 2 3 4 5; do
|
|
177
|
+
if git -C "$PAGES_DIR" push origin HEAD:gh-pages; then
|
|
178
|
+
break
|
|
179
|
+
fi
|
|
180
|
+
if [ "$attempt" -eq 5 ]; then exit 1; fi
|
|
181
|
+
git fetch origin gh-pages
|
|
182
|
+
git -C "$PAGES_DIR" merge --no-edit origin/gh-pages
|
|
183
|
+
done
|
package/docs/impact.md
CHANGED
|
@@ -10,6 +10,11 @@ import cannot be resolved, the project uses a dynamic import pattern that cannot
|
|
|
10
10
|
a changed source/configuration file cannot be mapped. This protects coverage when Viewev cannot
|
|
11
11
|
make a confident selection. `--filter` and `include`/`exclude` still apply after impact selection.
|
|
12
12
|
|
|
13
|
+
Package manifests, lockfiles, and Storybook or bundler configuration are treated as global inputs,
|
|
14
|
+
so changing one selects every scenario. For example, adding Viewev to `package.json` and `yarn.lock`
|
|
15
|
+
can make the initial setup PR run the full catalog. Component and story source changes are mapped
|
|
16
|
+
through imports and can select a smaller set on later PRs.
|
|
17
|
+
|
|
13
18
|
For provider-specific logic, a project can still supply an analyzer module. `viewev test --changed`
|
|
14
19
|
uses this extension for non-reference runs:
|
|
15
20
|
|