@testsprite/testsprite-cli 0.14.0 → 0.16.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 +27 -17
- package/dist/commands/agent.js +7 -2
- package/dist/commands/auth.js +7 -3
- package/dist/commands/ci.d.ts +66 -17
- package/dist/commands/ci.js +486 -122
- package/dist/commands/completion.js +2 -1
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.js +52 -10
- package/dist/commands/init.js +25 -5
- package/dist/commands/project-env.js +39 -17
- package/dist/commands/project-sign-in.js +9 -4
- package/dist/commands/project.js +43 -22
- package/dist/commands/schedule.js +24 -15
- package/dist/commands/test.d.ts +105 -36
- package/dist/commands/test.js +1494 -847
- package/dist/commands/testlist.js +13 -3
- package/dist/commands/tunnel.js +23 -25
- package/dist/commands/usage.js +1 -0
- package/dist/index.js +14 -7
- 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/conflict-reason.d.ts +24 -3
- package/dist/lib/conflict-reason.js +33 -2
- package/dist/lib/credentials.d.ts +0 -1
- package/dist/lib/credentials.js +51 -14
- package/dist/lib/deprecate.d.ts +22 -0
- package/dist/lib/deprecate.js +26 -0
- package/dist/lib/dry-run/samples.js +56 -5
- package/dist/lib/environment-tunnel.d.ts +2 -1
- package/dist/lib/environment-tunnel.js +1 -4
- 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 +29 -3
- package/dist/lib/junit-report.d.ts +3 -0
- package/dist/lib/junit-report.js +8 -1
- package/dist/lib/output.d.ts +11 -1
- package/dist/lib/output.js +17 -2
- package/dist/lib/plans.types.d.ts +1 -1
- package/dist/lib/response-schemas.d.ts +5 -1
- package/dist/lib/response-schemas.js +57 -0
- package/dist/lib/runs.types.d.ts +122 -0
- package/dist/lib/telemetry.d.ts +26 -2
- package/dist/lib/telemetry.js +47 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/schemas/plan.schema.json +2 -2
- package/skills/testsprite-ci.skill.md +154 -0
- package/skills/testsprite-verify.codex.md +7 -7
- package/skills/testsprite-verify.skill.md +24 -21
|
@@ -110,6 +110,13 @@ export const RUN_RESPONSE_SCHEMA = v.looseObject({
|
|
|
110
110
|
error: v.nullish(v.string(), null),
|
|
111
111
|
videoUrl: v.nullish(v.string(), null),
|
|
112
112
|
stepSummary: RUN_STEP_SUMMARY_SCHEMA,
|
|
113
|
+
// Optional with no default: absent on older backends. `reason` / `caveat` are
|
|
114
|
+
// `null` on the wire when the run carries no routing reason or caveat.
|
|
115
|
+
replay: v.optional(v.looseObject({
|
|
116
|
+
path: v.string(),
|
|
117
|
+
reason: v.nullish(v.string()),
|
|
118
|
+
caveat: v.nullish(v.string()),
|
|
119
|
+
})),
|
|
113
120
|
retryAfterSeconds: v.optional(v.number()),
|
|
114
121
|
// Portal link. Three-state wire contract (pinned): **absent** — an older
|
|
115
122
|
// backend that predates this field, and cannot have produced a V3-native/
|
|
@@ -190,6 +197,8 @@ export const TRIGGER_RUN_RESPONSE_SCHEMA = v.looseObject({
|
|
|
190
197
|
// `dashboard` line only when the key is present.
|
|
191
198
|
dashboardUrl: v.optional(v.string()),
|
|
192
199
|
executionUrl: v.optional(v.string()),
|
|
200
|
+
// Present-or-omitted echo of the request's `skipDependencies: true`; no default.
|
|
201
|
+
skipDependencies: v.optional(v.boolean()),
|
|
193
202
|
});
|
|
194
203
|
// ---------------------------------------------------------------------------
|
|
195
204
|
// POST /tests/{testId}/runs/rerun
|
|
@@ -286,6 +295,8 @@ export const BATCH_RUN_FRESH_RESPONSE_SCHEMA = v.looseObject({
|
|
|
286
295
|
runId: v.string(),
|
|
287
296
|
enqueuedAt: v.string(),
|
|
288
297
|
dashboardUrl: v.optional(v.string()),
|
|
298
|
+
// V3-served runs name their execution; an older backend omits it.
|
|
299
|
+
executionId: v.optional(v.string()),
|
|
289
300
|
})),
|
|
290
301
|
conflicts: v.array(v.looseObject({
|
|
291
302
|
testId: v.string(),
|
|
@@ -296,6 +307,12 @@ export const BATCH_RUN_FRESH_RESPONSE_SCHEMA = v.looseObject({
|
|
|
296
307
|
deferred: v.array(v.looseObject({ testId: v.string() })),
|
|
297
308
|
skippedFrontend: v.array(v.string()),
|
|
298
309
|
skippedIntegration: v.array(v.looseObject({ testId: v.string() })),
|
|
310
|
+
// Optional with no default: absent on older backends and frontend projects.
|
|
311
|
+
integration: v.optional(v.looseObject({
|
|
312
|
+
existing: v.number(),
|
|
313
|
+
runsAfterWave: v.boolean(),
|
|
314
|
+
mayGenerate: v.boolean(),
|
|
315
|
+
})),
|
|
299
316
|
// Project-level closing link. Absent-key-preserving like `RUN_RESPONSE_SCHEMA`'s
|
|
300
317
|
// `dashboardUrl` (see the note there): omitted stays ABSENT so the client
|
|
301
318
|
// keeps computing its legacy template for an older backend / the V2 engine;
|
|
@@ -303,6 +320,11 @@ export const BATCH_RUN_FRESH_RESPONSE_SCHEMA = v.looseObject({
|
|
|
303
320
|
dashboardUrl: v.nullish(v.string(), undefined),
|
|
304
321
|
// An exact echo confirms that the backend read the target URL override.
|
|
305
322
|
targetUrl: v.optional(v.string()),
|
|
323
|
+
// Same contract for the CI fields: a client that sent one and gets no
|
|
324
|
+
// echo was served by a backend that cut the batch / ran a plain override.
|
|
325
|
+
admission: v.optional(v.picklist(['budget', 'all'])),
|
|
326
|
+
previewName: v.optional(v.string()),
|
|
327
|
+
skipDependencies: v.optional(v.boolean()),
|
|
306
328
|
});
|
|
307
329
|
/**
|
|
308
330
|
* `POST /api/cli/v1/testlist/{listId}/run`. Mirrors the batch-run-fresh shape so
|
|
@@ -466,4 +488,39 @@ export const TUNNEL_LIST_RESPONSE_SCHEMA = v.looseObject({
|
|
|
466
488
|
createdAt: v.optional(v.nullable(v.string())),
|
|
467
489
|
})),
|
|
468
490
|
});
|
|
491
|
+
/** Mirrors `ExecutionReport` — the server's report model, kept loose so new fields pass through. */
|
|
492
|
+
export const EXECUTION_REPORT_SCHEMA = v.looseObject({
|
|
493
|
+
projectId: v.string(),
|
|
494
|
+
executionId: v.string(),
|
|
495
|
+
projectName: v.string(),
|
|
496
|
+
orgId: v.nullish(v.string(), null),
|
|
497
|
+
stats: v.looseObject({
|
|
498
|
+
passed: v.number(),
|
|
499
|
+
failed: v.number(),
|
|
500
|
+
blocked: v.number(),
|
|
501
|
+
total: v.number(),
|
|
502
|
+
}),
|
|
503
|
+
allPassed: v.boolean(),
|
|
504
|
+
narrative: v.nullish(v.string(), null),
|
|
505
|
+
whatCouldBeBetter: v.nullish(v.string(), null),
|
|
506
|
+
recommendedNextStep: v.nullish(v.string(), null),
|
|
507
|
+
tests: v.array(v.looseObject({
|
|
508
|
+
id: v.string(),
|
|
509
|
+
title: v.string(),
|
|
510
|
+
slug: v.nullish(v.string(), null),
|
|
511
|
+
status: openWireLiteral(),
|
|
512
|
+
screenshotUrl: v.nullish(v.string(), null),
|
|
513
|
+
error: v.nullish(v.string(), null),
|
|
514
|
+
fix: v.nullish(v.string(), null),
|
|
515
|
+
resultUrl: v.optional(v.string()),
|
|
516
|
+
})),
|
|
517
|
+
resultUrl: v.string(),
|
|
518
|
+
});
|
|
519
|
+
/** Mirrors `ExecutionReportResponse`: `report`/`markdown` only travel with `ready: true`. */
|
|
520
|
+
export const EXECUTION_REPORT_RESPONSE_SCHEMA = v.looseObject({
|
|
521
|
+
ready: v.boolean(),
|
|
522
|
+
retryAfterSeconds: v.optional(v.number()),
|
|
523
|
+
report: v.optional(EXECUTION_REPORT_SCHEMA),
|
|
524
|
+
markdown: v.optional(v.string()),
|
|
525
|
+
});
|
|
469
526
|
//# sourceMappingURL=response-schemas.js.map
|
package/dist/lib/runs.types.d.ts
CHANGED
|
@@ -45,6 +45,12 @@ export interface TriggerRunBody {
|
|
|
45
45
|
* this picks WHOSE credentials it logs in with.
|
|
46
46
|
*/
|
|
47
47
|
environment?: string;
|
|
48
|
+
/**
|
|
49
|
+
* BE only: run just the named test without expanding the producer/teardown
|
|
50
|
+
* closure. Sent only when the caller asked for it (never `false`); an older
|
|
51
|
+
* backend strips the field, so omitting it is the default on the wire.
|
|
52
|
+
*/
|
|
53
|
+
skipDependencies?: boolean;
|
|
48
54
|
}
|
|
49
55
|
/** The environment a run resolved to — its credentials, its config, its address. */
|
|
50
56
|
export interface RunEnvironmentRef {
|
|
@@ -242,6 +248,12 @@ export interface TriggerRunResponse {
|
|
|
242
248
|
* run has no execution page). Same present-or-absent contract.
|
|
243
249
|
*/
|
|
244
250
|
executionUrl?: string;
|
|
251
|
+
/**
|
|
252
|
+
* `true` exactly when the request carried `skipDependencies: true` and this
|
|
253
|
+
* backend handled it; otherwise OMITTED. A CLI that sent the flag and gets no
|
|
254
|
+
* echo was served by a backend that stripped it and ran the full closure.
|
|
255
|
+
*/
|
|
256
|
+
skipDependencies?: boolean;
|
|
245
257
|
}
|
|
246
258
|
/**
|
|
247
259
|
* Public run-status values.
|
|
@@ -320,6 +332,16 @@ export interface RunResponse {
|
|
|
320
332
|
error: string | null;
|
|
321
333
|
videoUrl: string | null;
|
|
322
334
|
stepSummary: RunStepSummary;
|
|
335
|
+
/**
|
|
336
|
+
* How the stored code was routed. `path: 'refused'` means the run was
|
|
337
|
+
* blocked before dispatch because the stored code could not be replayed;
|
|
338
|
+
* `reason` names why. Absent on older backends.
|
|
339
|
+
*/
|
|
340
|
+
replay?: {
|
|
341
|
+
path: string;
|
|
342
|
+
reason?: string | null;
|
|
343
|
+
caveat?: string | null;
|
|
344
|
+
};
|
|
323
345
|
/** Optional hint from the server; honored by the polling loop. */
|
|
324
346
|
retryAfterSeconds?: number;
|
|
325
347
|
/**
|
|
@@ -482,6 +504,18 @@ export interface ListRunsQuery {
|
|
|
482
504
|
* BE-only engine — FE tests in the set are skipped server-side (advisory only).
|
|
483
505
|
* `testIds` absent / empty → run ALL BE tests in the project.
|
|
484
506
|
*/
|
|
507
|
+
/**
|
|
508
|
+
* Where a `ci run` came from on GitHub, read off the Actions event. Stamped on
|
|
509
|
+
* the execution so the Portal can link the run back to its pull request.
|
|
510
|
+
*/
|
|
511
|
+
export interface CiGithubTrigger {
|
|
512
|
+
repoOwner: string;
|
|
513
|
+
repoName: string;
|
|
514
|
+
branchName?: string;
|
|
515
|
+
/** 40-hex commit the preview was built from. */
|
|
516
|
+
commitSha?: string;
|
|
517
|
+
prNumber: number;
|
|
518
|
+
}
|
|
485
519
|
export interface BatchRunFreshRequest {
|
|
486
520
|
projectId: string;
|
|
487
521
|
testIds?: string[];
|
|
@@ -490,11 +524,29 @@ export interface BatchRunFreshRequest {
|
|
|
490
524
|
autoHeal?: false;
|
|
491
525
|
/** See `TriggerRunBody.environment` — applied to every test in the batch. */
|
|
492
526
|
environment?: string;
|
|
527
|
+
/** See `TriggerRunBody.skipDependencies` — applies to every BE test in the batch. */
|
|
528
|
+
skipDependencies?: boolean;
|
|
493
529
|
/** Per-run URL override for the batch; echoed when the backend honors it. */
|
|
494
530
|
targetUrl?: string;
|
|
531
|
+
/**
|
|
532
|
+
* `'all'`: the server seeds every selected case into one execution and
|
|
533
|
+
* paces dispatch itself (as for a GitHub App run) instead of cutting the
|
|
534
|
+
* selection to the per-key budget and returning the rest as `deferred`.
|
|
535
|
+
* Default `'budget'` is today's behaviour. Echoed when honored.
|
|
536
|
+
*/
|
|
537
|
+
admission?: 'budget' | 'all';
|
|
538
|
+
/** `github-pr-<N>`: run in a temporary clone of `environment` at `targetUrl`. Echoed when honored. */
|
|
539
|
+
previewName?: string;
|
|
540
|
+
githubTrigger?: CiGithubTrigger;
|
|
495
541
|
}
|
|
496
542
|
/** One accepted run in the batch fresh-run response. */
|
|
497
543
|
export interface BatchRunFreshAccepted {
|
|
544
|
+
/**
|
|
545
|
+
* The `test_execution.id` this run was dispatched under (V3-served runs
|
|
546
|
+
* only; absent on a V2 backend). One execution usually covers the whole
|
|
547
|
+
* batch — `ci run` de-duplicates it to read the execution report.
|
|
548
|
+
*/
|
|
549
|
+
executionId?: string;
|
|
498
550
|
testId: string;
|
|
499
551
|
/**
|
|
500
552
|
* runId minted synchronously by `claimRunSlotOrThrow`. The backend partitions
|
|
@@ -539,6 +591,17 @@ export interface BatchRunFreshResponse {
|
|
|
539
591
|
skippedIntegration: Array<{
|
|
540
592
|
testId: string;
|
|
541
593
|
}>;
|
|
594
|
+
/**
|
|
595
|
+
* Backend projects only: the integration phase that follows the wave.
|
|
596
|
+
* `existing` integration tests run after it (0.2 credits each);
|
|
597
|
+
* `mayGenerate` means a first run may also generate new ones. Absent on
|
|
598
|
+
* older backends and for frontend projects.
|
|
599
|
+
*/
|
|
600
|
+
integration?: {
|
|
601
|
+
existing: number;
|
|
602
|
+
runsAfterWave: boolean;
|
|
603
|
+
mayGenerate: boolean;
|
|
604
|
+
};
|
|
542
605
|
/**
|
|
543
606
|
* Project-level portal link the batch closes with ("watch it here"). Same
|
|
544
607
|
* absent-vs-present contract as the per-run `dashboardUrl`: ABSENT ⇒ an older
|
|
@@ -555,4 +618,63 @@ export interface BatchRunFreshResponse {
|
|
|
555
618
|
* report a verdict for an unconfirmed target.
|
|
556
619
|
*/
|
|
557
620
|
targetUrl?: string;
|
|
621
|
+
/** Echoes, same contract as `targetUrl`: absent means this backend never read the field. */
|
|
622
|
+
admission?: 'budget' | 'all';
|
|
623
|
+
previewName?: string;
|
|
624
|
+
/** See `TriggerRunResponse.skipDependencies`; same present-or-omitted contract. */
|
|
625
|
+
skipDependencies?: boolean;
|
|
626
|
+
}
|
|
627
|
+
/** One row of an execution report — one `test_result` of that execution. */
|
|
628
|
+
export interface ExecutionReportTest {
|
|
629
|
+
/** The `test_result.id` (the CLI's run id). */
|
|
630
|
+
id: string;
|
|
631
|
+
title: string;
|
|
632
|
+
/** Display id of the case (e.g. `AUTH-002`); null when unresolved. */
|
|
633
|
+
slug: string | null;
|
|
634
|
+
status: 'PASSED' | 'FAILED' | 'BLOCKED' | (string & {});
|
|
635
|
+
/** Presigned PNG of a step snapshot; null when unavailable. */
|
|
636
|
+
screenshotUrl: string | null;
|
|
637
|
+
/** Raw failure text; set for FAILED rows. */
|
|
638
|
+
error: string | null;
|
|
639
|
+
/** Suggested fix prompt; set for FAILED rows. */
|
|
640
|
+
fix: string | null;
|
|
641
|
+
/** This result's own Portal page (`…/execution/{eid}/test/{rid}`). */
|
|
642
|
+
resultUrl?: string;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* The execution report the GitHub App posts as its PR comment — the server's
|
|
646
|
+
* content model, returned verbatim so a later CI step can shape it itself.
|
|
647
|
+
*/
|
|
648
|
+
export interface ExecutionReport {
|
|
649
|
+
projectId: string;
|
|
650
|
+
executionId: string;
|
|
651
|
+
projectName: string;
|
|
652
|
+
orgId: string | null;
|
|
653
|
+
stats: {
|
|
654
|
+
passed: number;
|
|
655
|
+
failed: number;
|
|
656
|
+
blocked: number;
|
|
657
|
+
total: number;
|
|
658
|
+
};
|
|
659
|
+
allPassed: boolean;
|
|
660
|
+
/** Narrative run summary from the analyze pass; null when unavailable. */
|
|
661
|
+
narrative: string | null;
|
|
662
|
+
whatCouldBeBetter: string | null;
|
|
663
|
+
recommendedNextStep: string | null;
|
|
664
|
+
/** Ordered failed → blocked → passed. */
|
|
665
|
+
tests: ExecutionReportTest[];
|
|
666
|
+
/** The execution's Portal page. */
|
|
667
|
+
resultUrl: string;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* `ready: false` means the execution is still running or its report is still
|
|
671
|
+
* being built (the build waits for the analyze pass); poll again after
|
|
672
|
+
* `retryAfterSeconds`. `report` and `markdown` are present only when ready.
|
|
673
|
+
*/
|
|
674
|
+
export interface ExecutionReportResponse {
|
|
675
|
+
ready: boolean;
|
|
676
|
+
retryAfterSeconds?: number;
|
|
677
|
+
report?: ExecutionReport;
|
|
678
|
+
/** The report rendered as GitHub-flavoured Markdown — the PR comment body. */
|
|
679
|
+
markdown?: string;
|
|
558
680
|
}
|
package/dist/lib/telemetry.d.ts
CHANGED
|
@@ -100,11 +100,13 @@ export declare function buildCiContext(env: NodeJS.ProcessEnv): {
|
|
|
100
100
|
* `conflict-reason.ts`'s rendering type: `tunnel-required` is a server reason
|
|
101
101
|
* this CLI has no label for yet, and `not_found` is rendered but not counted.
|
|
102
102
|
*/
|
|
103
|
-
export type TelemetryConflictReason = 'in_flight' | 'insufficient_credits' | 'paused' | 'billing_hold' | 'mcp_view_only' | 'local_address' | 'tunnel-required' | 'error';
|
|
103
|
+
export type TelemetryConflictReason = 'in_flight' | 'insufficient_credits' | 'paused' | 'billing_hold' | 'mcp_view_only' | 'local_address' | 'tunnel-required' | 'no_producer' | 'producer_in_flight' | 'error';
|
|
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',
|
|
@@ -133,10 +157,24 @@ const ENUM_KEYS = {
|
|
|
133
157
|
'mcp_view_only',
|
|
134
158
|
'local_address',
|
|
135
159
|
'tunnel-required',
|
|
160
|
+
'no_producer',
|
|
161
|
+
'producer_in_flight',
|
|
136
162
|
'error',
|
|
137
163
|
]),
|
|
138
164
|
platform: new Set(['github']),
|
|
139
165
|
projectResolved: new Set(['flag', 'auto']),
|
|
166
|
+
ciRunOutcome: new Set([
|
|
167
|
+
'gated',
|
|
168
|
+
'skipped_draft',
|
|
169
|
+
'skipped_no_pr',
|
|
170
|
+
'refused_admission',
|
|
171
|
+
'refused_env',
|
|
172
|
+
'refused_preview_name',
|
|
173
|
+
'refused_loopback',
|
|
174
|
+
'refused_billing',
|
|
175
|
+
'refused_other',
|
|
176
|
+
'empty',
|
|
177
|
+
]),
|
|
140
178
|
};
|
|
141
179
|
/**
|
|
142
180
|
* Keep only the allowlisted keys with a value of the right shape. Pure: this is
|
|
@@ -156,6 +194,11 @@ export function sanitizeTelemetryExtras(partial) {
|
|
|
156
194
|
if (typeof v === 'boolean')
|
|
157
195
|
out[key] = v;
|
|
158
196
|
}
|
|
197
|
+
for (const key of UUID_KEYS) {
|
|
198
|
+
const v = rec[key];
|
|
199
|
+
if (typeof v === 'string' && UUID_RE.test(v))
|
|
200
|
+
out[key] = v;
|
|
201
|
+
}
|
|
159
202
|
for (const key of Object.keys(ENUM_KEYS)) {
|
|
160
203
|
const v = rec[key];
|
|
161
204
|
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.16.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testsprite/testsprite-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Official TestSprite command-line interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@llmcode/yamux-ts": "0.0.2",
|
|
63
63
|
"commander": "^12.1.0",
|
|
64
|
-
"undici": "^7.
|
|
64
|
+
"undici": "^7.30.1",
|
|
65
65
|
"valibot": "^1.4.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"ajv": "^8.20.0",
|
|
72
72
|
"eslint": "^10.7.0",
|
|
73
73
|
"eslint-config-prettier": "^9.1.0",
|
|
74
|
-
"eslint-plugin-security": "4.0
|
|
74
|
+
"eslint-plugin-security": "4.2.0",
|
|
75
75
|
"globals": "^17.7.0",
|
|
76
76
|
"msw": "^2.14.3",
|
|
77
77
|
"prettier": "^3.3.3",
|
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.
|
|
@@ -45,17 +45,17 @@ testsprite test run <test-id> --env staging \
|
|
|
45
45
|
# Backend Python assertion
|
|
46
46
|
testsprite test create --type backend --name "Login rejects empty password" \
|
|
47
47
|
--project <id> --code-file /tmp/test.py --run --wait --timeout 600
|
|
48
|
-
#
|
|
49
|
-
testsprite test
|
|
50
|
-
# Dependency batch;
|
|
48
|
+
# Several tests, one batch (V3 FE: 0.5 credit each)
|
|
49
|
+
testsprite test run <test-id> <test-id> --env staging --wait --output json
|
|
50
|
+
# Dependency batch; --filter <substr>, --status failed,blocked
|
|
51
51
|
testsprite test run --all --project <id> --env staging --wait --output json
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
- Supported backends grant existing keys `run:tunnel`; a narrowed key without it
|
|
55
|
-
exits 3. Free-plan local runs work
|
|
55
|
+
exits 3. Free-plan local runs work. BE cannot use `--local`.
|
|
56
56
|
- `--local` implies `--wait` (1200 s per run; ordinary: 600). `--local-host`:
|
|
57
57
|
`localhost`, `127.0.0.1` (default), `::1`. A dead port exits 5 before charge;
|
|
58
|
-
`--skip-preflight` skips the probe. Environment `--url` rejects private hosts.
|
|
58
|
+
`--skip-preflight` skips the probe. Environment `--url` rejects private (non-loopback) hosts.
|
|
59
59
|
`--local` selects/creates `local-<port>`; a named `--env` must be local.
|
|
60
60
|
`--target-url` cannot combine with `--local`.
|
|
61
61
|
- Run local ids together (`test run <id> <id> … --local <port>`); `--all --project
|
|
@@ -82,14 +82,14 @@ testsprite test run --all --project <id> --env staging --wait --output json
|
|
|
82
82
|
free BLOCKED results. A public `--env` or Default works regardless of earlier
|
|
83
83
|
tunnel runs. V3 local runs use the agent path, never saved-code replay, and
|
|
84
84
|
preserve saved code.
|
|
85
|
-
- `--wait` handles polling/backoff;
|
|
85
|
+
- `--wait` handles polling/backoff; don't wrap it in a retry loop.
|
|
86
86
|
- Backend Python runs top-to-bottom, not via pytest: call `test_*` functions.
|
|
87
87
|
The sandbox has stdlib, `requests`, `pytest`, `numpy`, `scipy`; use HTTP,
|
|
88
88
|
not project imports or uninstalled packages.
|
|
89
89
|
- Backend `--produces`/`--needs` are repeatable; `--category teardown` marks cleanup.
|
|
90
90
|
Set dependencies with `test create` or edit with `test update`; do not delete
|
|
91
91
|
and recreate. Use `test run --all` for producer → consumer → teardown ordering
|
|
92
|
-
and variable passing. A BE
|
|
92
|
+
and variable passing. A BE run includes that closure and its side effects;
|
|
93
93
|
`--skip-dependencies` selects only the named test. Triage failed producers before
|
|
94
94
|
blaming consumers starved of their token/fixture.
|
|
95
95
|
|