@testsprite/testsprite-cli 0.6.0 → 0.7.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 +38 -30
- package/dist/commands/agent.js +44 -42
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +4 -7
- package/dist/commands/project.js +3 -2
- package/dist/commands/schedule.d.ts +120 -0
- package/dist/commands/schedule.js +487 -0
- package/dist/commands/test.d.ts +15 -1
- package/dist/commands/test.js +460 -256
- package/dist/commands/testlist.d.ts +88 -0
- package/dist/commands/testlist.js +747 -0
- package/dist/index.js +6 -2
- package/dist/lib/agent-targets.d.ts +13 -4
- package/dist/lib/agent-targets.js +11 -2
- package/dist/lib/conflict-reason.d.ts +30 -0
- package/dist/lib/conflict-reason.js +45 -0
- package/dist/lib/credentials.js +42 -1
- package/dist/lib/cron.d.ts +40 -0
- package/dist/lib/cron.js +190 -0
- package/dist/lib/dry-run/samples.js +177 -55
- package/dist/lib/errors.d.ts +9 -0
- package/dist/lib/errors.js +11 -0
- package/dist/lib/gh-output.d.ts +26 -1
- package/dist/lib/gh-output.js +47 -20
- package/dist/lib/http.d.ts +25 -0
- package/dist/lib/http.js +128 -2
- package/dist/lib/junit-report.d.ts +20 -2
- package/dist/lib/junit-report.js +38 -5
- package/dist/lib/proxy.d.ts +16 -0
- package/dist/lib/proxy.js +19 -1
- package/dist/lib/response-schemas.d.ts +7 -0
- package/dist/lib/response-schemas.js +23 -1
- package/dist/lib/runs.types.d.ts +8 -3
- package/dist/lib/secret-file.d.ts +15 -0
- package/dist/lib/secret-file.js +82 -0
- package/dist/lib/target-url-preflight.d.ts +91 -0
- package/dist/lib/target-url-preflight.js +259 -0
- package/dist/lib/target-url.d.ts +22 -5
- package/dist/lib/target-url.js +60 -28
- package/dist/lib/testlist.types.d.ts +77 -0
- package/dist/lib/testlist.types.js +9 -0
- package/dist/lib/v3-advisory.d.ts +35 -22
- package/dist/lib/v3-advisory.js +44 -24
- package/dist/lib/wait-exit.d.ts +29 -0
- package/dist/lib/wait-exit.js +103 -0
- package/dist/version-guard.d.ts +10 -7
- package/dist/version-guard.js +37 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/lib/v3-advisory.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared V3-routing text surfaces
|
|
2
|
+
* Shared V3-routing text surfaces.
|
|
3
3
|
*
|
|
4
|
-
* `
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* `V3_ROUTING_ADVISORY`/`emitV3RoutingAdvisory` back `auth status` and
|
|
5
|
+
* `doctor`: `v3Enabled` on the `/me` response is the authoritative routing
|
|
6
|
+
* bit, and when it is on, some commands behave differently while the V3
|
|
7
|
+
* gaps stay open — the advisory names them. Copy lives here so both
|
|
8
|
+
* commands stay in sync.
|
|
9
|
+
*
|
|
10
|
+
* `targetUrlAdvisoryText`/`emitTargetUrlMismatchAdvisory` back the
|
|
11
|
+
* `--target-url` point-of-use advisory in `commands/test.ts` — a different,
|
|
12
|
+
* response-driven mechanism (see its own docblock below) that does not
|
|
13
|
+
* depend on `v3Enabled` at all.
|
|
7
14
|
*/
|
|
8
15
|
/** One-word routing label for the text card. */
|
|
9
16
|
export function routingLabel(v3Enabled) {
|
|
@@ -30,26 +37,39 @@ export function emitV3RoutingAdvisory(stderr) {
|
|
|
30
37
|
stderr(line);
|
|
31
38
|
}
|
|
32
39
|
/**
|
|
33
|
-
* Point-of-use advisory for `test run --target-url
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* (
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* `
|
|
44
|
-
*
|
|
45
|
-
* (no "on
|
|
46
|
-
*
|
|
47
|
-
*
|
|
40
|
+
* Point-of-use advisory for `test run --target-url`, redesigned to be
|
|
41
|
+
* response-driven rather than assumption-driven. The original
|
|
42
|
+
* version probed `GET /me` for `v3Enabled` and warned on that ASSUMPTION —
|
|
43
|
+
* but the backend is the ground truth here, not a proxy for it. V3
|
|
44
|
+
* deliberately returns `targetUrl: ''` rather than echoing an override it
|
|
45
|
+
* did not apply ("so the response doesn't claim a target we didn't use"),
|
|
46
|
+
* while V2 echoes the real applied value. So the advisory now fires purely
|
|
47
|
+
* from comparing what the caller asked for against what the trigger
|
|
48
|
+
* response reports — it self-corrects the day the backend applies the
|
|
49
|
+
* override, needs no `v3Enabled` lookup (and so no extra `/me` round trip,
|
|
50
|
+
* no `X-CLI-Command` tagging machinery), and is exact rather than inferred.
|
|
51
|
+
*
|
|
52
|
+
* Deliberately type-agnostic in its wording (no "on the V3 path" claim):
|
|
53
|
+
* a mismatch is reported purely from the observed response, regardless of
|
|
54
|
+
* why the backend didn't apply the override.
|
|
55
|
+
*/
|
|
56
|
+
export function targetUrlAdvisoryText(requested, applied) {
|
|
57
|
+
const appliedClause = applied.length > 0
|
|
58
|
+
? `the run will use ${applied} instead`
|
|
59
|
+
: 'the run reports no target URL for it';
|
|
60
|
+
return (`[advisory] --target-url ${requested} was not applied to this run — ${appliedClause}. ` +
|
|
61
|
+
`The run used its own configured environment.`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Compare the requested `--target-url` against what the trigger response
|
|
65
|
+
* reports and write the advisory when they differ. No-op when they match
|
|
66
|
+
* (the override was applied, or the caller didn't supply one — callers are
|
|
67
|
+
* expected to gate the `requested` argument on `opts.targetUrl !== undefined`
|
|
68
|
+
* themselves so this stays a pure comparison).
|
|
48
69
|
*/
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
stderr(TARGET_URL_V3_ADVISORY);
|
|
70
|
+
export function emitTargetUrlMismatchAdvisory(stderr, requested, applied) {
|
|
71
|
+
if (applied === requested)
|
|
72
|
+
return;
|
|
73
|
+
stderr(targetUrlAdvisoryText(requested, applied));
|
|
54
74
|
}
|
|
55
75
|
//# sourceMappingURL=v3-advisory.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ApiError, CLIError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* One member of a `--wait` fan-out poll (a single dispatched run's outcome).
|
|
4
|
+
* `status` is the terminal run status (`passed`/`failed`/`blocked`/…), or the
|
|
5
|
+
* synthesized `'timeout'` / `'error'` when the poll itself timed out or the
|
|
6
|
+
* run-read returned a typed `ApiError`. When `status === 'error'`, `error`
|
|
7
|
+
* carries that ApiError's `code` + `exitCode`.
|
|
8
|
+
*/
|
|
9
|
+
export interface WaitMemberResult {
|
|
10
|
+
testId?: string;
|
|
11
|
+
runId?: string;
|
|
12
|
+
status: string;
|
|
13
|
+
error?: {
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
exitCode?: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the process-level failure for a completed `--wait` fan-out, or `null`
|
|
21
|
+
* when every member passed. Shared by `test run --all` / `test rerun` and
|
|
22
|
+
* `testlist run` so their exit-code semantics can't drift.
|
|
23
|
+
*
|
|
24
|
+
* Precedence (see {@link WAIT_EXIT_PRIORITY}): auth / client-too-old → typed
|
|
25
|
+
* operational ApiError → timeout (7) → generic test-failure (1).
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveWaitFailure(results: readonly WaitMemberResult[], opts: {
|
|
28
|
+
timeoutSeconds: number;
|
|
29
|
+
}): CLIError | ApiError | null;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ApiError, CLIError, isAuthCode } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Exit-code precedence for a `--wait` fan-out, highest first. Ordered
|
|
4
|
+
* batch-wide-non-retriable → per-run → transient → timeout → generic:
|
|
5
|
+
* - auth (3) and CLIENT_TOO_OLD (14): a bad credential / too-old client fails
|
|
6
|
+
* EVERY poll and retrying can never succeed — batch-wide, so they top the
|
|
7
|
+
* table (a transient `RATE_LIMITED` "retry later" must never outrank them).
|
|
8
|
+
* - INSUFFICIENT_CREDITS (12) / FEATURE_GATED (13): per-run, non-retriable.
|
|
9
|
+
* - NOT_FOUND (4) / VALIDATION_ERROR (5) / CONFLICT (6): per-run.
|
|
10
|
+
* - RATE_LIMITED (11) / UNAVAILABLE (10): transient — a retry may help.
|
|
11
|
+
* - timeout (7): outranks only a generic failure.
|
|
12
|
+
* - generic (1): the floor (genuine test-fail / INTERNAL).
|
|
13
|
+
* A code NOT in this table folds into the generic bucket (never surfaced as an
|
|
14
|
+
* operational error), so an out-of-contract exit (0, 99, a leaked signal code)
|
|
15
|
+
* can neither preempt a real verdict nor produce a printed-failure-green-exit.
|
|
16
|
+
*/
|
|
17
|
+
const WAIT_EXIT_PRIORITY = [3, 14, 12, 13, 4, 5, 6, 11, 10, 7, 1];
|
|
18
|
+
/**
|
|
19
|
+
* A "typed operational" code is one that sits in the precedence table above the
|
|
20
|
+
* generic floor — known AND not the generic `1`. Everything else (unknown
|
|
21
|
+
* codes, `0`, INTERNAL/1) folds into the generic failure bucket.
|
|
22
|
+
*/
|
|
23
|
+
function isOperationalCode(exitCode) {
|
|
24
|
+
return (exitCode !== 1 && WAIT_EXIT_PRIORITY.includes(exitCode));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Index of `exitCode` in the precedence table (lower = higher priority). Only
|
|
28
|
+
* ever called on operational codes (see `isOperationalCode`), so the index is
|
|
29
|
+
* always valid.
|
|
30
|
+
*/
|
|
31
|
+
function priorityOf(exitCode) {
|
|
32
|
+
return WAIT_EXIT_PRIORITY.indexOf(exitCode);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the process-level failure for a completed `--wait` fan-out, or `null`
|
|
36
|
+
* when every member passed. Shared by `test run --all` / `test rerun` and
|
|
37
|
+
* `testlist run` so their exit-code semantics can't drift.
|
|
38
|
+
*
|
|
39
|
+
* Precedence (see {@link WAIT_EXIT_PRIORITY}): auth / client-too-old → typed
|
|
40
|
+
* operational ApiError → timeout (7) → generic test-failure (1).
|
|
41
|
+
*/
|
|
42
|
+
export function resolveWaitFailure(results, opts) {
|
|
43
|
+
const timedOut = results.filter(r => r.status === 'timeout');
|
|
44
|
+
const errored = results.filter((r) => r.status === 'error' && r.error !== undefined);
|
|
45
|
+
// A genuine test failure: terminal-not-passed, and not one of the synthesized
|
|
46
|
+
// timeout/typed-error members above.
|
|
47
|
+
const failed = results.filter(r => r.status !== 'passed' && r.status !== 'timeout' && !(r.status === 'error' && r.error));
|
|
48
|
+
// How many runs did NOT pass — used for the auth failure count so the message
|
|
49
|
+
// agrees with the "N failed/blocked" summary printed just above it.
|
|
50
|
+
const notPassed = results.filter(r => r.status !== 'passed').length;
|
|
51
|
+
// 1) Auth wins over everything — the credential is bad, not the test.
|
|
52
|
+
// Classified via the single `isAuthCode` source (derived from `exitCodeFor`)
|
|
53
|
+
// rather than a local `=== 3` so a future AUTH_* code can't be missed here.
|
|
54
|
+
const authErr = errored.find(r => isAuthCode(r.error.code));
|
|
55
|
+
if (authErr) {
|
|
56
|
+
return new CLIError(`${notPassed} run${notPassed !== 1 ? 's' : ''} failed — auth error (${authErr.error.code}): ${authErr.error.message}`, 3);
|
|
57
|
+
}
|
|
58
|
+
// 2) Any other typed operational ApiError, highest-priority first. Only codes
|
|
59
|
+
// IN the precedence table qualify — an unknown / out-of-contract code folds
|
|
60
|
+
// into the generic bucket below rather than being surfaced (or leaking a
|
|
61
|
+
// non-1 exit like 0/99). Routed through the ENVELOPE so `--output json`
|
|
62
|
+
// carries `error.code` — the machine-readable field this fix exists for;
|
|
63
|
+
// `ApiError.fromEnvelope` derives the exit via `exitCodeFor(code)`.
|
|
64
|
+
const operational = errored
|
|
65
|
+
.filter(r => isOperationalCode(r.error.exitCode ?? 1))
|
|
66
|
+
.sort((a, b) => priorityOf(a.error.exitCode) - priorityOf(b.error.exitCode))[0];
|
|
67
|
+
if (operational) {
|
|
68
|
+
return ApiError.fromEnvelope({
|
|
69
|
+
error: {
|
|
70
|
+
code: operational.error.code,
|
|
71
|
+
message: operational.error.message,
|
|
72
|
+
nextAction: '',
|
|
73
|
+
requestId: 'local',
|
|
74
|
+
details: { runId: operational.runId ?? null, testId: operational.testId ?? null },
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// 3) Timeout — outranks a generic failure so the operator gets resume/cancel
|
|
79
|
+
// guidance for the runs that didn't finish.
|
|
80
|
+
if (timedOut.length > 0) {
|
|
81
|
+
const runIds = timedOut.map(r => r.runId).filter((id) => Boolean(id));
|
|
82
|
+
return ApiError.fromEnvelope({
|
|
83
|
+
error: {
|
|
84
|
+
code: 'UNSUPPORTED',
|
|
85
|
+
message: `${timedOut.length} run${timedOut.length !== 1 ? 's' : ''} timed out.`,
|
|
86
|
+
nextAction: [
|
|
87
|
+
...runIds.map(rid => `Resume: testsprite test wait ${rid}`),
|
|
88
|
+
...runIds.map(rid => `Cancel: testsprite test cancel ${rid}`),
|
|
89
|
+
].join('\n'),
|
|
90
|
+
requestId: 'local',
|
|
91
|
+
details: { timedOutRunIds: runIds, timeoutSeconds: opts.timeoutSeconds },
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// 4) Generic test failures — genuine test-fails, INTERNAL (1), and any
|
|
96
|
+
// unknown / out-of-contract error code folded here.
|
|
97
|
+
const genericCount = failed.length + errored.filter(r => !isOperationalCode(r.error.exitCode ?? 1)).length;
|
|
98
|
+
if (genericCount > 0) {
|
|
99
|
+
return new CLIError(`${genericCount} run${genericCount !== 1 ? 's' : ''} failed.`, 1);
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=wait-exit.js.map
|
package/dist/version-guard.d.ts
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
* The logic lives here (rather than inline) so it can be unit-tested against the
|
|
10
10
|
* real implementation the entrypoint uses — not a copy.
|
|
11
11
|
*/
|
|
12
|
-
/**
|
|
12
|
+
/** Canonical supported range, pinned to package.json by the unit test. */
|
|
13
|
+
export declare const SUPPORTED_NODE_ENGINE = "^20.19.0 || ^22.13.0 || >=24";
|
|
14
|
+
/** Human-readable form of the supported range for startup errors. */
|
|
15
|
+
export declare const SUPPORTED_NODE_RANGE = "20.19+, 22.13+, or 24+";
|
|
13
16
|
export declare const MIN_SUPPORTED_NODE_MAJOR = 20;
|
|
14
17
|
/**
|
|
15
18
|
* Parse the leading major version number from a Node.js version string.
|
|
@@ -20,14 +23,14 @@ export declare const MIN_SUPPORTED_NODE_MAJOR = 20;
|
|
|
20
23
|
*/
|
|
21
24
|
export declare function parseMajorVersion(nodeVersion: string): number;
|
|
22
25
|
/**
|
|
23
|
-
* Decide whether the given Node.js version is
|
|
26
|
+
* Decide whether the given Node.js version is outside the supported engine range.
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* treated as "do not reject" so the guard never blocks on a
|
|
28
|
-
* cannot understand (the runtime would surface any
|
|
28
|
+
* Mirrors `^20.19.0 || ^22.13.0 || >=24`: Node 20 is supported from 20.19,
|
|
29
|
+
* Node 22 from 22.13, odd intermediate majors 21/23 are rejected, and 24+ is supported.
|
|
30
|
+
* An unparseable string is treated as "do not reject" so the guard never blocks on a
|
|
31
|
+
* version string it cannot understand (the runtime would surface any incompatibility).
|
|
29
32
|
*
|
|
30
33
|
* @param nodeVersion - a `process.versions.node` style string (e.g. `"18.19.1"`).
|
|
31
|
-
* @returns `true` when the runtime is
|
|
34
|
+
* @returns `true` when the runtime is unsupported and should be rejected.
|
|
32
35
|
*/
|
|
33
36
|
export declare function shouldRejectNodeVersion(nodeVersion: string): boolean;
|
package/dist/version-guard.js
CHANGED
|
@@ -9,8 +9,13 @@
|
|
|
9
9
|
* The logic lives here (rather than inline) so it can be unit-tested against the
|
|
10
10
|
* real implementation the entrypoint uses — not a copy.
|
|
11
11
|
*/
|
|
12
|
-
/**
|
|
12
|
+
/** Canonical supported range, pinned to package.json by the unit test. */
|
|
13
|
+
export const SUPPORTED_NODE_ENGINE = '^20.19.0 || ^22.13.0 || >=24';
|
|
14
|
+
/** Human-readable form of the supported range for startup errors. */
|
|
15
|
+
export const SUPPORTED_NODE_RANGE = '20.19+, 22.13+, or 24+';
|
|
13
16
|
export const MIN_SUPPORTED_NODE_MAJOR = 20;
|
|
17
|
+
const MIN_NODE_20_MINOR = 19;
|
|
18
|
+
const MIN_NODE_22_MINOR = 13;
|
|
14
19
|
/**
|
|
15
20
|
* Parse the leading major version number from a Node.js version string.
|
|
16
21
|
*
|
|
@@ -21,19 +26,42 @@ export const MIN_SUPPORTED_NODE_MAJOR = 20;
|
|
|
21
26
|
export function parseMajorVersion(nodeVersion) {
|
|
22
27
|
return Number(nodeVersion.split('.')[0]);
|
|
23
28
|
}
|
|
29
|
+
function parseMajorMinor(nodeVersion) {
|
|
30
|
+
const [majorRaw, minorRaw] = nodeVersion.split('.');
|
|
31
|
+
const major = Number(majorRaw);
|
|
32
|
+
// Preserve the old guard's behavior for injectable major-only versions such as "18".
|
|
33
|
+
const minor = minorRaw === undefined ? 0 : Number(minorRaw);
|
|
34
|
+
if (!Number.isInteger(major) || !Number.isInteger(minor) || major < 0 || minor < 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return { major, minor };
|
|
38
|
+
}
|
|
24
39
|
/**
|
|
25
|
-
* Decide whether the given Node.js version is
|
|
40
|
+
* Decide whether the given Node.js version is outside the supported engine range.
|
|
26
41
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* treated as "do not reject" so the guard never blocks on a
|
|
30
|
-
* cannot understand (the runtime would surface any
|
|
42
|
+
* Mirrors `^20.19.0 || ^22.13.0 || >=24`: Node 20 is supported from 20.19,
|
|
43
|
+
* Node 22 from 22.13, odd intermediate majors 21/23 are rejected, and 24+ is supported.
|
|
44
|
+
* An unparseable string is treated as "do not reject" so the guard never blocks on a
|
|
45
|
+
* version string it cannot understand (the runtime would surface any incompatibility).
|
|
31
46
|
*
|
|
32
47
|
* @param nodeVersion - a `process.versions.node` style string (e.g. `"18.19.1"`).
|
|
33
|
-
* @returns `true` when the runtime is
|
|
48
|
+
* @returns `true` when the runtime is unsupported and should be rejected.
|
|
34
49
|
*/
|
|
35
50
|
export function shouldRejectNodeVersion(nodeVersion) {
|
|
36
|
-
const
|
|
37
|
-
|
|
51
|
+
const parsed = parseMajorMinor(nodeVersion);
|
|
52
|
+
if (parsed === null)
|
|
53
|
+
return false;
|
|
54
|
+
const { major, minor } = parsed;
|
|
55
|
+
if (major < MIN_SUPPORTED_NODE_MAJOR)
|
|
56
|
+
return true;
|
|
57
|
+
if (major === 20)
|
|
58
|
+
return minor < MIN_NODE_20_MINOR;
|
|
59
|
+
if (major === 21)
|
|
60
|
+
return true;
|
|
61
|
+
if (major === 22)
|
|
62
|
+
return minor < MIN_NODE_22_MINOR;
|
|
63
|
+
if (major === 23)
|
|
64
|
+
return true;
|
|
65
|
+
return false;
|
|
38
66
|
}
|
|
39
67
|
//# sourceMappingURL=version-guard.js.map
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.7.0";
|
package/dist/version.js
CHANGED