@percy/cli-exec 1.32.6-beta.0 → 1.32.6-beta.2
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/dist/baseline.js +27 -3
- package/package.json +4 -4
package/dist/baseline.js
CHANGED
|
@@ -121,11 +121,24 @@ export async function findBaselineProvider({
|
|
|
121
121
|
return null;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
// The seed-build status poll needs a READ-capable token, but `percy exec` normally runs with the
|
|
125
|
+
// project's default write-only token — the read then 403s (build reads are master/read_only-gated
|
|
126
|
+
// server-side). That's a token-choice problem the user can fix, not a transient failure, so it is
|
|
127
|
+
// classified here and surfaced as its own sentinel instead of the generic wait-timeout warning.
|
|
128
|
+
function isAuthFailure(error) {
|
|
129
|
+
var _error$response;
|
|
130
|
+
let status = (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.statusCode;
|
|
131
|
+
if (status === 401 || status === 403) return true;
|
|
132
|
+
return /\b(401|403|forbidden|unauthori[sz]ed)\b/i.test(error.message || '');
|
|
133
|
+
}
|
|
134
|
+
|
|
124
135
|
// The seed build keeps processing (renders + auto-approval) after finalize. The head build must
|
|
125
136
|
// not start until it reaches a terminal state — head snapshots select their baseline as they are
|
|
126
137
|
// processed, and an unapproved seed means the whole first run shows as new instead of diffing.
|
|
127
138
|
// The timeout matches the pipeline latency budget (~99% of builds finish under 5 minutes) —
|
|
128
139
|
// a seed of committed screenshots still renders server-side, so first runs can hold for minutes.
|
|
140
|
+
// Returns the terminal state, or 'unauthorized' when the token cannot read build status at all
|
|
141
|
+
// (every retry would fail identically, so polling stops on the first auth failure).
|
|
129
142
|
export async function waitForSeedBuild(client, buildId, {
|
|
130
143
|
log,
|
|
131
144
|
timeout = 600000,
|
|
@@ -135,9 +148,14 @@ export async function waitForSeedBuild(client, buildId, {
|
|
|
135
148
|
let state = 'pending';
|
|
136
149
|
let polls = 0;
|
|
137
150
|
for (;;) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
151
|
+
try {
|
|
152
|
+
({
|
|
153
|
+
state
|
|
154
|
+
} = (await client.getBuild(buildId)).data.attributes);
|
|
155
|
+
} catch (err) {
|
|
156
|
+
if (isAuthFailure(err)) return 'unauthorized';
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
141
159
|
if (state !== 'pending' && state !== 'processing') return state;
|
|
142
160
|
if (Date.now() >= deadline) return state;
|
|
143
161
|
// A visible heartbeat every ~30s so a multi-minute first-run hold doesn't look like a hang.
|
|
@@ -230,6 +248,12 @@ export async function maybeSeedBaseline(percy, provider, {
|
|
|
230
248
|
}
|
|
231
249
|
if (state === 'finished') {
|
|
232
250
|
log.info(`Baseline established from ${seeded}/${baselines.length} committed snapshot(s) ` + 'and auto-approved — this run diffs against it.');
|
|
251
|
+
} else if (state === 'unauthorized') {
|
|
252
|
+
// Token-choice problem, not a transient one: build reads need a read-capable token, so
|
|
253
|
+
// with the default write-only token Percy cannot hold the run until the baseline is
|
|
254
|
+
// ready. Ask for the full access token up front — this fires BEFORE the head build's
|
|
255
|
+
// snapshots are taken, while switching tokens can still save the first run.
|
|
256
|
+
log.warn(`Uploaded ${seeded}/${baselines.length} baseline snapshot(s), but this token ` + 'cannot read build status, so Percy cannot wait for your baseline to finish before ' + 'tests start. Use your project\'s FULL ACCESS token as PERCY_TOKEN for this first run ' + '(Project settings → Tokens). If snapshots in this run appear as new instead of ' + 'diffing, approve build #1 in the dashboard.');
|
|
233
257
|
} else {
|
|
234
258
|
log.warn(`Baseline build did not finish processing in time (state: ${state || 'unknown'}) — ` + 'snapshots in this run may show as new instead of diffing against the baseline');
|
|
235
259
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/cli-exec",
|
|
3
|
-
"version": "1.32.6-beta.
|
|
3
|
+
"version": "1.32.6-beta.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
]
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@percy/cli-command": "1.32.6-beta.
|
|
38
|
-
"@percy/logger": "1.32.6-beta.
|
|
37
|
+
"@percy/cli-command": "1.32.6-beta.2",
|
|
38
|
+
"@percy/logger": "1.32.6-beta.2",
|
|
39
39
|
"cross-spawn": "^7.0.3",
|
|
40
40
|
"which": "^2.0.2"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "11bfa3bf3daebe5ae0b07999054be412e9995a02"
|
|
43
43
|
}
|