@testsprite/testsprite-cli 0.14.0 → 0.15.0
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 +3 -1
- package/dist/commands/ci.d.ts +66 -17
- package/dist/commands/ci.js +466 -104
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.js +50 -9
- package/dist/commands/init.js +17 -3
- package/dist/commands/project.js +15 -1
- package/dist/commands/test.d.ts +74 -11
- package/dist/commands/test.js +579 -112
- package/dist/index.js +5 -1
- package/dist/lib/agent-targets.d.ts +8 -3
- package/dist/lib/agent-targets.js +15 -4
- package/dist/lib/ci-run.d.ts +11 -0
- package/dist/lib/ci-run.js +34 -0
- package/dist/lib/client-factory.d.ts +23 -0
- package/dist/lib/client-factory.js +7 -6
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.js +1 -1
- package/dist/lib/credentials.d.ts +0 -1
- package/dist/lib/credentials.js +51 -14
- package/dist/lib/dry-run/samples.js +42 -1
- package/dist/lib/first-suite-hint.d.ts +55 -0
- package/dist/lib/first-suite-hint.js +101 -0
- package/dist/lib/gh-output.d.ts +62 -4
- package/dist/lib/gh-output.js +149 -7
- package/dist/lib/github-context.d.ts +21 -0
- package/dist/lib/github-context.js +153 -0
- package/dist/lib/http.d.ts +10 -1
- package/dist/lib/http.js +9 -1
- package/dist/lib/plans.types.d.ts +1 -1
- package/dist/lib/response-schemas.d.ts +5 -1
- package/dist/lib/response-schemas.js +54 -0
- package/dist/lib/runs.types.d.ts +106 -0
- package/dist/lib/telemetry.d.ts +25 -1
- package/dist/lib/telemetry.js +45 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schemas/plan.schema.json +2 -2
- package/skills/testsprite-ci.skill.md +154 -0
package/dist/lib/runs.types.d.ts
CHANGED
|
@@ -320,6 +320,16 @@ export interface RunResponse {
|
|
|
320
320
|
error: string | null;
|
|
321
321
|
videoUrl: string | null;
|
|
322
322
|
stepSummary: RunStepSummary;
|
|
323
|
+
/**
|
|
324
|
+
* How the stored code was routed. `path: 'refused'` means the run was
|
|
325
|
+
* blocked before dispatch because the stored code could not be replayed;
|
|
326
|
+
* `reason` names why. Absent on older backends.
|
|
327
|
+
*/
|
|
328
|
+
replay?: {
|
|
329
|
+
path: string;
|
|
330
|
+
reason?: string | null;
|
|
331
|
+
caveat?: string | null;
|
|
332
|
+
};
|
|
323
333
|
/** Optional hint from the server; honored by the polling loop. */
|
|
324
334
|
retryAfterSeconds?: number;
|
|
325
335
|
/**
|
|
@@ -482,6 +492,18 @@ export interface ListRunsQuery {
|
|
|
482
492
|
* BE-only engine — FE tests in the set are skipped server-side (advisory only).
|
|
483
493
|
* `testIds` absent / empty → run ALL BE tests in the project.
|
|
484
494
|
*/
|
|
495
|
+
/**
|
|
496
|
+
* Where a `ci run` came from on GitHub, read off the Actions event. Stamped on
|
|
497
|
+
* the execution so the Portal can link the run back to its pull request.
|
|
498
|
+
*/
|
|
499
|
+
export interface CiGithubTrigger {
|
|
500
|
+
repoOwner: string;
|
|
501
|
+
repoName: string;
|
|
502
|
+
branchName?: string;
|
|
503
|
+
/** 40-hex commit the preview was built from. */
|
|
504
|
+
commitSha?: string;
|
|
505
|
+
prNumber: number;
|
|
506
|
+
}
|
|
485
507
|
export interface BatchRunFreshRequest {
|
|
486
508
|
projectId: string;
|
|
487
509
|
testIds?: string[];
|
|
@@ -492,9 +514,25 @@ export interface BatchRunFreshRequest {
|
|
|
492
514
|
environment?: string;
|
|
493
515
|
/** Per-run URL override for the batch; echoed when the backend honors it. */
|
|
494
516
|
targetUrl?: string;
|
|
517
|
+
/**
|
|
518
|
+
* `'all'`: the server seeds every selected case into one execution and
|
|
519
|
+
* paces dispatch itself (as for a GitHub App run) instead of cutting the
|
|
520
|
+
* selection to the per-key budget and returning the rest as `deferred`.
|
|
521
|
+
* Default `'budget'` is today's behaviour. Echoed when honored.
|
|
522
|
+
*/
|
|
523
|
+
admission?: 'budget' | 'all';
|
|
524
|
+
/** `github-pr-<N>`: run in a temporary clone of `environment` at `targetUrl`. Echoed when honored. */
|
|
525
|
+
previewName?: string;
|
|
526
|
+
githubTrigger?: CiGithubTrigger;
|
|
495
527
|
}
|
|
496
528
|
/** One accepted run in the batch fresh-run response. */
|
|
497
529
|
export interface BatchRunFreshAccepted {
|
|
530
|
+
/**
|
|
531
|
+
* The `test_execution.id` this run was dispatched under (V3-served runs
|
|
532
|
+
* only; absent on a V2 backend). One execution usually covers the whole
|
|
533
|
+
* batch — `ci run` de-duplicates it to read the execution report.
|
|
534
|
+
*/
|
|
535
|
+
executionId?: string;
|
|
498
536
|
testId: string;
|
|
499
537
|
/**
|
|
500
538
|
* runId minted synchronously by `claimRunSlotOrThrow`. The backend partitions
|
|
@@ -539,6 +577,17 @@ export interface BatchRunFreshResponse {
|
|
|
539
577
|
skippedIntegration: Array<{
|
|
540
578
|
testId: string;
|
|
541
579
|
}>;
|
|
580
|
+
/**
|
|
581
|
+
* Backend projects only: the integration phase that follows the wave.
|
|
582
|
+
* `existing` integration tests run after it (0.2 credits each);
|
|
583
|
+
* `mayGenerate` means a first run may also generate new ones. Absent on
|
|
584
|
+
* older backends and for frontend projects.
|
|
585
|
+
*/
|
|
586
|
+
integration?: {
|
|
587
|
+
existing: number;
|
|
588
|
+
runsAfterWave: boolean;
|
|
589
|
+
mayGenerate: boolean;
|
|
590
|
+
};
|
|
542
591
|
/**
|
|
543
592
|
* Project-level portal link the batch closes with ("watch it here"). Same
|
|
544
593
|
* absent-vs-present contract as the per-run `dashboardUrl`: ABSENT ⇒ an older
|
|
@@ -555,4 +604,61 @@ export interface BatchRunFreshResponse {
|
|
|
555
604
|
* report a verdict for an unconfirmed target.
|
|
556
605
|
*/
|
|
557
606
|
targetUrl?: string;
|
|
607
|
+
/** Echoes, same contract as `targetUrl`: absent means this backend never read the field. */
|
|
608
|
+
admission?: 'budget' | 'all';
|
|
609
|
+
previewName?: string;
|
|
610
|
+
}
|
|
611
|
+
/** One row of an execution report — one `test_result` of that execution. */
|
|
612
|
+
export interface ExecutionReportTest {
|
|
613
|
+
/** The `test_result.id` (the CLI's run id). */
|
|
614
|
+
id: string;
|
|
615
|
+
title: string;
|
|
616
|
+
/** Display id of the case (e.g. `AUTH-002`); null when unresolved. */
|
|
617
|
+
slug: string | null;
|
|
618
|
+
status: 'PASSED' | 'FAILED' | 'BLOCKED' | (string & {});
|
|
619
|
+
/** Presigned PNG of a step snapshot; null when unavailable. */
|
|
620
|
+
screenshotUrl: string | null;
|
|
621
|
+
/** Raw failure text; set for FAILED rows. */
|
|
622
|
+
error: string | null;
|
|
623
|
+
/** Suggested fix prompt; set for FAILED rows. */
|
|
624
|
+
fix: string | null;
|
|
625
|
+
/** This result's own Portal page (`…/execution/{eid}/test/{rid}`). */
|
|
626
|
+
resultUrl?: string;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* The execution report the GitHub App posts as its PR comment — the server's
|
|
630
|
+
* content model, returned verbatim so a later CI step can shape it itself.
|
|
631
|
+
*/
|
|
632
|
+
export interface ExecutionReport {
|
|
633
|
+
projectId: string;
|
|
634
|
+
executionId: string;
|
|
635
|
+
projectName: string;
|
|
636
|
+
orgId: string | null;
|
|
637
|
+
stats: {
|
|
638
|
+
passed: number;
|
|
639
|
+
failed: number;
|
|
640
|
+
blocked: number;
|
|
641
|
+
total: number;
|
|
642
|
+
};
|
|
643
|
+
allPassed: boolean;
|
|
644
|
+
/** Narrative run summary from the analyze pass; null when unavailable. */
|
|
645
|
+
narrative: string | null;
|
|
646
|
+
whatCouldBeBetter: string | null;
|
|
647
|
+
recommendedNextStep: string | null;
|
|
648
|
+
/** Ordered failed → blocked → passed. */
|
|
649
|
+
tests: ExecutionReportTest[];
|
|
650
|
+
/** The execution's Portal page. */
|
|
651
|
+
resultUrl: string;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* `ready: false` means the execution is still running or its report is still
|
|
655
|
+
* being built (the build waits for the analyze pass); poll again after
|
|
656
|
+
* `retryAfterSeconds`. `report` and `markdown` are present only when ready.
|
|
657
|
+
*/
|
|
658
|
+
export interface ExecutionReportResponse {
|
|
659
|
+
ready: boolean;
|
|
660
|
+
retryAfterSeconds?: number;
|
|
661
|
+
report?: ExecutionReport;
|
|
662
|
+
/** The report rendered as GitHub-flavoured Markdown — the PR comment body. */
|
|
663
|
+
markdown?: string;
|
|
558
664
|
}
|
package/dist/lib/telemetry.d.ts
CHANGED
|
@@ -104,7 +104,9 @@ export type TelemetryConflictReason = 'in_flight' | 'insufficient_credits' | 'pa
|
|
|
104
104
|
/**
|
|
105
105
|
* Low-cardinality facts a command records about its own outcome before it
|
|
106
106
|
* returns, merged into the one event `index.ts` fires. Counts are non-negative
|
|
107
|
-
* integers; enums are closed. Nothing here can carry
|
|
107
|
+
* integers; enums are closed. Nothing here can carry a URL, a message, or an
|
|
108
|
+
* id that names a person or a repository — `executionId` is the server's own
|
|
109
|
+
* opaque UUID for the run, so the event can be joined to the execution's report.
|
|
108
110
|
*/
|
|
109
111
|
export interface TelemetryExtras {
|
|
110
112
|
local?: boolean;
|
|
@@ -128,7 +130,29 @@ export interface TelemetryExtras {
|
|
|
128
130
|
force?: boolean;
|
|
129
131
|
workflowExisted?: boolean;
|
|
130
132
|
projectResolved?: 'flag' | 'auto';
|
|
133
|
+
/** `ci run` facts: what the gate did, which execution it was, whether the report arrived. */
|
|
134
|
+
ciRunOutcome?: CiRunTelemetryOutcome;
|
|
135
|
+
executionId?: string;
|
|
136
|
+
reportReady?: boolean;
|
|
131
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* What a `ci run` invocation ended up doing. `gated` = tests were dispatched
|
|
140
|
+
* and the exit code is the verdict; `skipped_*` = nothing to gate (exit 0, no
|
|
141
|
+
* summary); `refused_*` = refused before or at dispatch; `empty` = nothing
|
|
142
|
+
* selected. The funnel step "`ci init` → first gated run" is computed from it.
|
|
143
|
+
*/
|
|
144
|
+
export type CiRunTelemetryOutcome = 'gated' | 'skipped_draft' | 'skipped_no_pr' | 'refused_admission' | 'refused_env' | 'refused_preview_name' | 'refused_loopback' | 'refused_billing' | 'refused_other' | 'empty';
|
|
145
|
+
/**
|
|
146
|
+
* The `ci run` outcome for an API refusal — at the environment pre-check or at
|
|
147
|
+
* the batch dispatch. Every refusal gets a value, so `refused_other` really is
|
|
148
|
+
* "any other refusal": a validation error is split by the server's
|
|
149
|
+
* `details.reason`; a 402/403 (credits, a feature gate) is `refused_billing`;
|
|
150
|
+
* a 401, 429 or anything else is `refused_other`.
|
|
151
|
+
*/
|
|
152
|
+
export declare function ciRefusalOutcome(err: {
|
|
153
|
+
code: string;
|
|
154
|
+
details?: Record<string, unknown>;
|
|
155
|
+
}): CiRunTelemetryOutcome;
|
|
132
156
|
/** What callers may hand the sanitizer: the typed shape, or an arbitrary bag it filters. */
|
|
133
157
|
export type TelemetryExtrasInput = TelemetryExtras | Readonly<Record<string, unknown>>;
|
|
134
158
|
/**
|
package/dist/lib/telemetry.js
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* - Opt-out: skipped when `TESTSPRITE_NO_TELEMETRY` or the cross-tool
|
|
15
15
|
* `DO_NOT_TRACK` is set. Also skipped under `--dry-run` (no network) and
|
|
16
16
|
* when no leaf command actually ran (bare `--help` / parse errors).
|
|
17
|
-
* -
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* - On abort (SIGINT/SIGTERM) the event is still sent — `outcome: 'abort'`,
|
|
18
|
+
* through the same bounded flush `index.ts` runs before setting the exit
|
|
19
|
+
* code — and the extras the command recorded before the signal ride along
|
|
20
|
+
* (a cancelled CI gate keeps its `gated` outcome and execution id).
|
|
20
21
|
*
|
|
21
22
|
* Privacy: the event is a fixed allowlist of low-cardinality, PII-free fields.
|
|
22
23
|
* It NEVER carries target URLs, api keys, arg values, error messages, or
|
|
@@ -111,6 +112,26 @@ export function buildCiContext(env) {
|
|
|
111
112
|
...(typeof repo === 'string' && repo !== '' ? { repoHash: hashRepository(repo) } : {}),
|
|
112
113
|
};
|
|
113
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The `ci run` outcome for an API refusal — at the environment pre-check or at
|
|
117
|
+
* the batch dispatch. Every refusal gets a value, so `refused_other` really is
|
|
118
|
+
* "any other refusal": a validation error is split by the server's
|
|
119
|
+
* `details.reason`; a 402/403 (credits, a feature gate) is `refused_billing`;
|
|
120
|
+
* a 401, 429 or anything else is `refused_other`.
|
|
121
|
+
*/
|
|
122
|
+
export function ciRefusalOutcome(err) {
|
|
123
|
+
if (err.code === 'VALIDATION_ERROR') {
|
|
124
|
+
const reason = err.details?.reason;
|
|
125
|
+
if (reason === 'preview-name-taken')
|
|
126
|
+
return 'refused_preview_name';
|
|
127
|
+
if (reason === 'private-or-local')
|
|
128
|
+
return 'refused_loopback';
|
|
129
|
+
return 'refused_other';
|
|
130
|
+
}
|
|
131
|
+
if (err.code === 'INSUFFICIENT_CREDITS' || err.code === 'FEATURE_GATED')
|
|
132
|
+
return 'refused_billing';
|
|
133
|
+
return 'refused_other';
|
|
134
|
+
}
|
|
114
135
|
const COUNT_KEYS = [
|
|
115
136
|
'accepted',
|
|
116
137
|
'conflicts',
|
|
@@ -123,7 +144,10 @@ const COUNT_KEYS = [
|
|
|
123
144
|
'localConcurrencyLimit',
|
|
124
145
|
'localPeakInFlight',
|
|
125
146
|
];
|
|
126
|
-
const BOOLEAN_KEYS = ['force', 'workflowExisted', 'local'];
|
|
147
|
+
const BOOLEAN_KEYS = ['force', 'workflowExisted', 'local', 'reportReady'];
|
|
148
|
+
/** Opaque server ids the beacon accepts — a UUID, nothing free-form. */
|
|
149
|
+
const UUID_KEYS = ['executionId'];
|
|
150
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
127
151
|
const ENUM_KEYS = {
|
|
128
152
|
conflictReason: new Set([
|
|
129
153
|
'in_flight',
|
|
@@ -137,6 +161,18 @@ const ENUM_KEYS = {
|
|
|
137
161
|
]),
|
|
138
162
|
platform: new Set(['github']),
|
|
139
163
|
projectResolved: new Set(['flag', 'auto']),
|
|
164
|
+
ciRunOutcome: new Set([
|
|
165
|
+
'gated',
|
|
166
|
+
'skipped_draft',
|
|
167
|
+
'skipped_no_pr',
|
|
168
|
+
'refused_admission',
|
|
169
|
+
'refused_env',
|
|
170
|
+
'refused_preview_name',
|
|
171
|
+
'refused_loopback',
|
|
172
|
+
'refused_billing',
|
|
173
|
+
'refused_other',
|
|
174
|
+
'empty',
|
|
175
|
+
]),
|
|
140
176
|
};
|
|
141
177
|
/**
|
|
142
178
|
* Keep only the allowlisted keys with a value of the right shape. Pure: this is
|
|
@@ -156,6 +192,11 @@ export function sanitizeTelemetryExtras(partial) {
|
|
|
156
192
|
if (typeof v === 'boolean')
|
|
157
193
|
out[key] = v;
|
|
158
194
|
}
|
|
195
|
+
for (const key of UUID_KEYS) {
|
|
196
|
+
const v = rec[key];
|
|
197
|
+
if (typeof v === 'string' && UUID_RE.test(v))
|
|
198
|
+
out[key] = v;
|
|
199
|
+
}
|
|
159
200
|
for (const key of Object.keys(ENUM_KEYS)) {
|
|
160
201
|
const v = rec[key];
|
|
161
202
|
if (typeof v === 'string' && ENUM_KEYS[key].has(v)) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.15.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
package/schemas/plan.schema.json
CHANGED
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"priority": {
|
|
34
34
|
"type": "string",
|
|
35
|
-
"
|
|
36
|
-
"description": "Optional. p0 = must-pass, p1 = important paths, p2 = edge cases
|
|
35
|
+
"pattern": "^([pP][0-3]|[hH][iI][gG][hH]|[mM][eE][dD][iI][uU][mM]|[lL][oO][wW])$",
|
|
36
|
+
"description": "Optional. p0/high = must-pass, p1/medium = important paths, p2/low = edge cases; p3 is treated as low."
|
|
37
37
|
},
|
|
38
38
|
"planSteps": {
|
|
39
39
|
"type": "array",
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
User-facing content for `testsprite agent install` (skill: testsprite-ci).
|
|
3
|
+
Body only — name + description frontmatter is emitted by the install wrapper.
|
|
4
|
+
The cursor (.mdc), cline (.clinerules), and antigravity (experimental)
|
|
5
|
+
wrappers reuse this body verbatim and swap only the frontmatter/header.
|
|
6
|
+
-->
|
|
7
|
+
|
|
8
|
+
# TestSprite: gate pull requests in CI
|
|
9
|
+
|
|
10
|
+
Put `testsprite ci run` into the repo's CI so every pull request's **preview
|
|
11
|
+
deployment** is tested before it merges.
|
|
12
|
+
|
|
13
|
+
This skill uses shipped CLI commands plus `git`, `gh` and the deploy platform's own
|
|
14
|
+
CLI. Do **not** call backend APIs directly.
|
|
15
|
+
|
|
16
|
+
## When to use
|
|
17
|
+
|
|
18
|
+
- "Add TestSprite to CI / GitHub Actions", "run the tests on every PR", "block merges
|
|
19
|
+
on the tests", "PR gate".
|
|
20
|
+
- The project already has tests. If not, onboard it first with the `testsprite-onboard`
|
|
21
|
+
skill.
|
|
22
|
+
|
|
23
|
+
## When NOT to use
|
|
24
|
+
|
|
25
|
+
- A nightly run of a fixed environment: `testsprite ci run --project <id> --env <name>`
|
|
26
|
+
on a `schedule:` trigger. No pull-request context is involved.
|
|
27
|
+
|
|
28
|
+
If this turns out to be more setup than the user wants, the TestSprite GitHub App
|
|
29
|
+
(Portal → project → Integrations) runs the same tests on every pull request with one
|
|
30
|
+
click.
|
|
31
|
+
|
|
32
|
+
## 1. Find out how pull requests get deployed (the shape)
|
|
33
|
+
|
|
34
|
+
Decide from configuration. Read `.github/workflows/` and the repo root, in this order:
|
|
35
|
+
|
|
36
|
+
- A workflow step already runs `vercel deploy`, `netlify deploy` or a deploy script:
|
|
37
|
+
**B — the workflow deploys**. Trigger: `on: pull_request`.
|
|
38
|
+
- No workflow deploys, and `vercel.json` / `.vercel/` / `netlify.toml` or the platform's
|
|
39
|
+
git integration is present: **A — the platform deploys every PR**. Trigger:
|
|
40
|
+
`on: deployment_status`.
|
|
41
|
+
- Neither is clear: ask the user who deploys their pull-request previews.
|
|
42
|
+
|
|
43
|
+
Deployment history is a reference, not the decision:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
gh api repos/{owner}/{repo}/deployments --jq '.[] | "\(.environment) \(.ref[0:8]) \(.created_at)"'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Recent **preview** records support A; production-only records mean preview deploys are
|
|
50
|
+
off on the platform. History is evidence, not configuration — the proof is a real pull
|
|
51
|
+
request (step 5).
|
|
52
|
+
|
|
53
|
+
Not linked but the user wants A: connect the repository to the platform's git
|
|
54
|
+
integration (Vercel: project → Settings → Git, or `npx vercel git connect` with the
|
|
55
|
+
user's approval — never `--yes`), or use shape B instead. Installing the platform's
|
|
56
|
+
GitHub App is a browser step only the user can do.
|
|
57
|
+
|
|
58
|
+
## 2. Pick the environment the gate signs in with
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
testsprite project env list <project-id>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Choose the environment whose **account** the gate should sign in with. `ci run
|
|
65
|
+
--target-url` swaps only its address for the pull request's preview; the sign-in
|
|
66
|
+
stays. Without `--env` the project's default is written into the workflow **by name**.
|
|
67
|
+
|
|
68
|
+
## 3. Generate the workflow, then finish it by hand
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
testsprite ci init github --project <project-id> --env <name>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This writes `.github/workflows/testsprite.yml` with one step marked `REPLACE ME`
|
|
75
|
+
(the job fails until it is replaced):
|
|
76
|
+
|
|
77
|
+
- **A:** change the trigger from `pull_request:` to `deployment_status:` and delete the
|
|
78
|
+
placeholder step; the run then reads the URL from `deployment_status.environment_url`.
|
|
79
|
+
A repo that deploys **several** Vercel projects gets one event per project for the
|
|
80
|
+
same commit — add `&& github.event.deployment.environment == 'Preview – <project>'`
|
|
81
|
+
to the `deployment_status` branch of the `if:`.
|
|
82
|
+
- **B:** replace the placeholder's `run:` with the deploy commands, ending in
|
|
83
|
+
`echo "url=<preview address>" >> "$GITHUB_OUTPUT"`. The platform token goes in its
|
|
84
|
+
own repo secret.
|
|
85
|
+
|
|
86
|
+
Keep what the template fixes: `testsprite ci run … --target-url "$PREVIEW_URL"
|
|
87
|
+
--fail-on-skipped --summary-file`, `npm i -g @testsprite/testsprite-cli@latest` (no
|
|
88
|
+
version pin — verdicts come from the backend), fork and draft PRs skipped, the upload
|
|
89
|
+
step on `if: always()`, and `concurrency` on the **job** (keyed by PR number in B, by
|
|
90
|
+
commit in A). Never re-judge pass/fail in YAML (`jq` + `exit 1`): `ci run`'s exit code
|
|
91
|
+
is the gate. Regenerate with `--force`; the previous file is kept as `.bak`.
|
|
92
|
+
|
|
93
|
+
## 4. Secrets
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
gh secret set TESTSPRITE_API_KEY # paste when prompted, or pipe on stdin
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
(`ci init github --set-secret` does the same.) Never put the key in argv, YAML or
|
|
100
|
+
logs. A non-production endpoint goes in the workflow `env:` as `TESTSPRITE_API_URL`.
|
|
101
|
+
B also needs the platform's deploy token as a secret.
|
|
102
|
+
|
|
103
|
+
## 5. Preflight, then prove it on one real pull request
|
|
104
|
+
|
|
105
|
+
Three checks before pushing; each of these otherwise shows up only as a red check
|
|
106
|
+
with the cause buried in the job log:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
gh auth status # gh can see this repo
|
|
110
|
+
gh secret list | grep TESTSPRITE_API_KEY # the secret landed (B: the deploy token too)
|
|
111
|
+
actionlint .github/workflows/testsprite.yml # the file parses — or `gh workflow view TestSprite` after the push
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Commit and push the workflow on a branch, open a PR that is **not a draft** and has
|
|
115
|
+
**no merge conflicts**, and watch the `TestSprite / testsprite-tests` check. The log shows
|
|
116
|
+
`Dispatched N tests.` then `CI run: x/y passed …`; the job summary is the execution
|
|
117
|
+
report (the same content as the App's PR comment); a `testsprite-results` artifact
|
|
118
|
+
holds `testsprite-summary.json`. Then suggest making the check **required** in branch
|
|
119
|
+
protection. In shape A the workflow file runs **at the deployed commit**, so the PR
|
|
120
|
+
branch itself is enough — nothing has to be merged first.
|
|
121
|
+
|
|
122
|
+
If nothing ran: a draft PR prints `Skipping draft pull request` and exits 0 with no
|
|
123
|
+
summary (mark it ready and re-run the job); a PR with merge conflicts never fires
|
|
124
|
+
`pull_request` workflows and GitHub shows no error; no run at all, not even the repo's
|
|
125
|
+
own workflows, means Actions is disabled on the repository (common on forks) — the
|
|
126
|
+
Actions tab shows an enable button; enable it and push an empty commit; in shape A
|
|
127
|
+
check that a
|
|
128
|
+
`deployment_status` with state `success` arrived for that commit (production
|
|
129
|
+
deployments are filtered out by the `if:`).
|
|
130
|
+
|
|
131
|
+
## Reading the result
|
|
132
|
+
|
|
133
|
+
- The check is `ci run`'s exit code: 1 = a test failed, 7 = timeout or an unsupported
|
|
134
|
+
backend, 5 = configuration. A summary opening with a **CI gate** warning means the
|
|
135
|
+
CLI's own counts differ from the report (a run it could not read, a timeout) — the
|
|
136
|
+
check is right, the report is the server's view of the execution.
|
|
137
|
+
- `exit 7` with "did not confirm the single-execution admission mode" = the backend is
|
|
138
|
+
too old for `ci run`; the dispatched runs were cancelled and refunded.
|
|
139
|
+
- Screenshots in the report are capped at 12 per execution; later rows show `—`.
|
|
140
|
+
- Shape A is per commit: a new push starts its own run against its own preview, and
|
|
141
|
+
cancelling the job only stops the CLI — the execution keeps running and reports in
|
|
142
|
+
the Portal.
|
|
143
|
+
- Backend tests use the URL baked into their code, not `--target-url`.
|
|
144
|
+
- Testing `ci run` locally: a shell that exports `TESTSPRITE_API_URL` or
|
|
145
|
+
`TESTSPRITE_API_KEY` overrides `--profile` — a `fetch failed` against a healthy API is
|
|
146
|
+
usually that. Check `env | grep TESTSPRITE_` first.
|
|
147
|
+
|
|
148
|
+
## Don'ts
|
|
149
|
+
|
|
150
|
+
- Don't add a CI gate next to the GitHub App on the same project without asking.
|
|
151
|
+
- Don't run `vercel link --yes`; don't pass secrets as arguments.
|
|
152
|
+
- Don't pin the CLI version in the workflow; don't parse the summary to decide the verdict.
|
|
153
|
+
- Don't commit a loopback or private `--target-url` (`ci run` refuses it).
|
|
154
|
+
- Don't skip step 5: a workflow that has not run on a real PR is not onboarded.
|