@testsprite/testsprite-cli 0.16.0 → 0.18.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 +52 -147
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +48 -63
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +40 -56
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +293 -487
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +741 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +129 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +108 -66
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +434 -43
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -229
- package/dist/commands/project.d.ts +19 -186
- package/dist/commands/project.js +108 -926
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +216 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1838
- package/dist/commands/test.js +1880 -13917
- package/dist/commands/testlist.d.ts +130 -5
- package/dist/commands/testlist.js +300 -342
- package/dist/commands/tunnel.d.ts +3 -3
- package/dist/commands/tunnel.js +23 -20
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +191 -110
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +12 -4
- package/dist/lib/client-factory.js +41 -30
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +9 -3
- package/dist/lib/conflict-reason.js +6 -3
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +75 -0
- package/dist/lib/conversation/api.js +151 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +29 -0
- package/dist/lib/conversation/context.js +82 -0
- package/dist/lib/conversation/environment.d.ts +16 -0
- package/dist/lib/conversation/environment.js +21 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +318 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +158 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +100 -0
- package/dist/lib/download.js +408 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +375 -747
- package/dist/lib/environment-tunnel.d.ts +19 -30
- package/dist/lib/environment-tunnel.js +168 -202
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +20 -30
- package/dist/lib/first-suite-hint.js +57 -72
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +354 -291
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +57 -4
- package/dist/lib/junit-report.js +202 -32
- package/dist/lib/local-target.d.ts +8 -7
- package/dist/lib/local-target.js +14 -13
- package/dist/lib/output.d.ts +2 -41
- package/dist/lib/output.js +13 -51
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +170 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +207 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +73 -0
- package/dist/lib/result/evidence.js +422 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +118 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +8 -8
- package/dist/lib/target-url.js +14 -24
- package/dist/lib/telemetry.d.ts +35 -15
- package/dist/lib/telemetry.js +38 -9
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +8 -2
- package/dist/lib/tunnel-session.js +24 -11
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/skills/testsprite-ci.skill.md +52 -23
- package/skills/testsprite-onboard.skill.md +70 -153
- package/skills/testsprite-verify.codex.md +54 -58
- package/skills/testsprite-verify.skill.md +189 -358
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -32
- package/dist/lib/deprecate.js +0 -39
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/dist/lib/gh-output.js
CHANGED
|
@@ -2,6 +2,8 @@ import { appendFileSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { tmpdir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { describeConflict } from './conflict-reason.js';
|
|
5
|
+
import { launchIds } from './run-render.js';
|
|
6
|
+
import { terminalSafe } from './terminal-text.js';
|
|
5
7
|
/**
|
|
6
8
|
* Row statuses that mean "this test never ran" as opposed to "this run did not
|
|
7
9
|
* pass". They count as `skipped` in the summary (not `failed`) and annotate as
|
|
@@ -21,8 +23,9 @@ export function isNonDispatchedStatus(status) {
|
|
|
21
23
|
/**
|
|
22
24
|
* Reduce a non-dispatched bucket (`deferred` / `conflicts` / `notFound`) into
|
|
23
25
|
* CI rows. Items are either bare testId strings (`notFound`) or
|
|
24
|
-
* `{ testId, currentRunId? }` objects; both shapes are
|
|
25
|
-
* the row's error text so the annotation explains why
|
|
26
|
+
* `{ testId, currentResultId?, currentRunId? }` objects; both shapes are
|
|
27
|
+
* handled. `note` becomes the row's error text so the annotation explains why
|
|
28
|
+
* the item did not run.
|
|
26
29
|
*/
|
|
27
30
|
function bucketRows(bucket, status, note) {
|
|
28
31
|
if (!Array.isArray(bucket))
|
|
@@ -30,10 +33,20 @@ function bucketRows(bucket, status, note) {
|
|
|
30
33
|
return bucket.map(item => {
|
|
31
34
|
const rec = item !== null && typeof item === 'object' ? item : undefined;
|
|
32
35
|
const testId = typeof item === 'string' ? item : typeof rec?.testId === 'string' ? rec.testId : '';
|
|
33
|
-
const
|
|
36
|
+
const currentResultId = typeof rec?.resultId === 'string'
|
|
37
|
+
? rec.resultId
|
|
38
|
+
: typeof rec?.currentResultId === 'string'
|
|
39
|
+
? rec.currentResultId
|
|
40
|
+
: undefined;
|
|
41
|
+
const currentRunId = typeof rec?.runId === 'string'
|
|
42
|
+
? rec.runId
|
|
43
|
+
: typeof rec?.currentRunId === 'string'
|
|
44
|
+
? rec.currentRunId
|
|
45
|
+
: undefined;
|
|
34
46
|
return {
|
|
35
47
|
testId,
|
|
36
48
|
status,
|
|
49
|
+
...(currentResultId ? { resultId: currentResultId } : {}),
|
|
37
50
|
...(currentRunId ? { runId: currentRunId } : {}),
|
|
38
51
|
error: typeof note === 'string' ? note : note(item),
|
|
39
52
|
};
|
|
@@ -52,11 +65,10 @@ function bucketRows(bucket, status, note) {
|
|
|
52
65
|
* gates' call, and a `failed` count the gates disagree with is exactly the
|
|
53
66
|
* artifacts-contradict-the-exit bug.
|
|
54
67
|
*
|
|
55
|
-
* `
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* default would silently change its artifacts.
|
|
68
|
+
* `foldSkippedBuckets` (the `ci run` contract) keeps a `not_found` conflict's
|
|
69
|
+
* own status so the `ci run` gate can exit 4 for it. Default off — for
|
|
70
|
+
* `run --project` it stays a conflict row, and changing that default would
|
|
71
|
+
* silently change its artifacts.
|
|
60
72
|
*/
|
|
61
73
|
export function summarizeAcceptedPayload(capturedJson, opts = {}) {
|
|
62
74
|
let parsed;
|
|
@@ -70,8 +82,9 @@ export function summarizeAcceptedPayload(capturedJson, opts = {}) {
|
|
|
70
82
|
// `JSON.parse('null')` and non-object payloads are valid JSON but carry no
|
|
71
83
|
// batch envelope — treat them like unparseable input instead of crashing.
|
|
72
84
|
const payload = parsed !== null && typeof parsed === 'object' ? parsed : {};
|
|
73
|
-
const
|
|
74
|
-
|
|
85
|
+
const sourceRows = payload.results ?? payload.accepted;
|
|
86
|
+
const acceptedRows = Array.isArray(sourceRows)
|
|
87
|
+
? sourceRows
|
|
75
88
|
.filter((entry) => entry !== null && typeof entry === 'object')
|
|
76
89
|
.map(row => {
|
|
77
90
|
const errorMessage = row.error !== null && typeof row.error === 'object'
|
|
@@ -80,6 +93,7 @@ export function summarizeAcceptedPayload(capturedJson, opts = {}) {
|
|
|
80
93
|
return {
|
|
81
94
|
testId: String(row.testId ?? ''),
|
|
82
95
|
...(typeof row.testTitle === 'string' ? { title: row.testTitle } : {}),
|
|
96
|
+
...(typeof row.resultId === 'string' ? { resultId: row.resultId } : {}),
|
|
83
97
|
...(typeof row.runId === 'string' ? { runId: row.runId } : {}),
|
|
84
98
|
status: String(row.status ?? 'unknown'),
|
|
85
99
|
...(typeof row.dashboardUrl === 'string' ? { dashboardUrl: row.dashboardUrl } : {}),
|
|
@@ -88,13 +102,17 @@ export function summarizeAcceptedPayload(capturedJson, opts = {}) {
|
|
|
88
102
|
};
|
|
89
103
|
})
|
|
90
104
|
: [];
|
|
105
|
+
return summarizeRunRows(acceptedRows, payload, opts);
|
|
106
|
+
}
|
|
107
|
+
/** Summarize the known results together with members the server did not dispatch. */
|
|
108
|
+
export function summarizeRunRows(results, payload = {}, opts = {}) {
|
|
91
109
|
const notFoundConflicts = new Set(Array.isArray(payload.conflicts)
|
|
92
110
|
? payload.conflicts
|
|
93
111
|
.filter(c => c?.reason === 'not_found')
|
|
94
112
|
.map(c => String(c.testId))
|
|
95
113
|
: []);
|
|
96
114
|
const rows = [
|
|
97
|
-
...
|
|
115
|
+
...results,
|
|
98
116
|
...bucketRows(payload.skipped, 'skipped', item => typeof item?.reason === 'string'
|
|
99
117
|
? item.reason
|
|
100
118
|
: 'not dispatched'),
|
|
@@ -107,31 +125,42 @@ export function summarizeAcceptedPayload(capturedJson, opts = {}) {
|
|
|
107
125
|
return conflict && typeof conflict.testId === 'string' && conflict.reason
|
|
108
126
|
? `${describeConflict(conflict)} (not dispatched)`
|
|
109
127
|
: 'already in flight (not dispatched)';
|
|
110
|
-
}).map(row => opts.foldSkippedBuckets === true &&
|
|
128
|
+
}).map(row => opts.foldSkippedBuckets === true &&
|
|
129
|
+
row.testId !== undefined &&
|
|
130
|
+
notFoundConflicts.has(row.testId)
|
|
111
131
|
? { ...row, status: 'not_found' }
|
|
112
132
|
: row),
|
|
113
|
-
//
|
|
114
|
-
// run). `testlist run` passes its own — a not-found `--case` id is one that
|
|
133
|
+
// `run --testlist` passes its own note — a not-found `--case` id is one that
|
|
115
134
|
// is not a member of the list — so the annotation/artifact don't state the
|
|
116
135
|
// wrong reason on the surface this whole layer exists to serve.
|
|
117
|
-
...bucketRows(payload.notFound, 'not_found', opts.notFoundNote ?? '
|
|
118
|
-
...(opts.foldSkippedBuckets === true
|
|
119
|
-
? [
|
|
120
|
-
// `bucketRows` handles both bucket shapes: `skippedFrontend` is bare
|
|
121
|
-
// testId strings, `skippedIntegration` is `{ testId }` objects.
|
|
122
|
-
...bucketRows(payload.skippedFrontend, 'skipped', 'frontend test — not run by the batch engine'),
|
|
123
|
-
...bucketRows(payload.skippedIntegration, 'skipped', 'assembled integration test — run it from the portal'),
|
|
124
|
-
]
|
|
125
|
-
: []),
|
|
136
|
+
...bucketRows(payload.notFound, 'not_found', opts.notFoundNote ?? 'test not found (not dispatched)'),
|
|
126
137
|
];
|
|
138
|
+
return summarizeRows(rows);
|
|
139
|
+
}
|
|
140
|
+
function summarizeRows(rows) {
|
|
141
|
+
const running = rows.filter(row => row.status === 'running').length;
|
|
127
142
|
const passed = rows.filter(row => row.status === 'passed').length;
|
|
128
143
|
const timedOut = rows.filter(row => row.status === 'timeout').length;
|
|
129
144
|
const skipped = rows.filter(row => isNonDispatchedStatus(row.status)).length;
|
|
130
|
-
const
|
|
131
|
-
|
|
145
|
+
const blocked = rows.filter(row => row.status === 'blocked').length;
|
|
146
|
+
const failed = rows.filter(row => row.status === 'failed').length;
|
|
147
|
+
const cancelled = rows.filter(row => row.status === 'cancelled').length;
|
|
148
|
+
const errors = rows.length - passed - failed - blocked - cancelled - timedOut - skipped - running;
|
|
149
|
+
return {
|
|
150
|
+
total: rows.length,
|
|
151
|
+
passed,
|
|
152
|
+
failed,
|
|
153
|
+
...(blocked ? { blocked } : {}),
|
|
154
|
+
...(cancelled ? { cancelled } : {}),
|
|
155
|
+
...(errors ? { errors } : {}),
|
|
156
|
+
skipped,
|
|
157
|
+
timedOut,
|
|
158
|
+
...(running ? { running } : {}),
|
|
159
|
+
results: rows,
|
|
160
|
+
};
|
|
132
161
|
}
|
|
133
162
|
/**
|
|
134
|
-
* Reduce a single `
|
|
163
|
+
* Reduce a single `run <test-id> --wait` result into the same CI summary
|
|
135
164
|
* shape as the batch path, so `--gh-output` / `--summary-file` behave
|
|
136
165
|
* identically for a one-test CI job. Unlike the batch envelope, a single
|
|
137
166
|
* RunResponse carries `error` as a raw string (not `{ message }`) and
|
|
@@ -141,17 +170,14 @@ export function summarizeSingleRun(run) {
|
|
|
141
170
|
const row = {
|
|
142
171
|
testId: String(run.testId ?? ''),
|
|
143
172
|
...(typeof run.testTitle === 'string' ? { title: run.testTitle } : {}),
|
|
173
|
+
...(typeof run.resultId === 'string' ? { resultId: run.resultId } : {}),
|
|
144
174
|
...(typeof run.runId === 'string' ? { runId: run.runId } : {}),
|
|
145
175
|
status: String(run.status ?? 'unknown'),
|
|
146
176
|
...(typeof run.dashboardUrl === 'string' ? { dashboardUrl: run.dashboardUrl } : {}),
|
|
147
177
|
...(typeof run.executionUrl === 'string' ? { executionUrl: run.executionUrl } : {}),
|
|
148
178
|
...(typeof run.error === 'string' && run.error.length > 0 ? { error: run.error } : {}),
|
|
149
179
|
};
|
|
150
|
-
|
|
151
|
-
const timedOut = row.status === 'timeout' ? 1 : 0;
|
|
152
|
-
const skipped = isNonDispatchedStatus(row.status) ? 1 : 0;
|
|
153
|
-
const failed = 1 - passed - timedOut - skipped;
|
|
154
|
-
return { total: 1, passed, failed, skipped, timedOut, runs: [row] };
|
|
180
|
+
return summarizeRows([row]);
|
|
155
181
|
}
|
|
156
182
|
/**
|
|
157
183
|
* Escape a value for a Markdown table cell. A raw `|` would break the column
|
|
@@ -195,35 +221,69 @@ function escapeMarkdownUrl(url) {
|
|
|
195
221
|
.replace(/\)/g, '%29')
|
|
196
222
|
.replace(/\|/g, '%7C');
|
|
197
223
|
}
|
|
198
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* An id as inline code. A backtick or a line break in it would end the code
|
|
226
|
+
* span or start a new Markdown line, so both are dropped.
|
|
227
|
+
*/
|
|
228
|
+
function inlineCode(id) {
|
|
229
|
+
return `\`${id.replace(/[`\r\n]/g, '')}\``;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The Test cell of a results table: the human label, linked to the test-case
|
|
233
|
+
* page (`dashboardUrl`) when the server sent one. The label sits in link-text
|
|
234
|
+
* position, so it uses the bracket-aware escaper.
|
|
235
|
+
*/
|
|
236
|
+
function testCell(row) {
|
|
237
|
+
// `|| ` not `?? `: an empty / whitespace-only title must fall back to the
|
|
238
|
+
// id (a blank Test cell is useless), matching JUnit's `name?.trim() || id`.
|
|
239
|
+
const label = row.title?.trim() || row.testId || row.resultId || row.runId || '(unknown)';
|
|
240
|
+
return row.dashboardUrl
|
|
241
|
+
? `[${escapeMarkdownLinkText(label)}](${escapeMarkdownUrl(row.dashboardUrl)})`
|
|
242
|
+
: escapeTableCell(label);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The Result cell of a results table: the result id, linked to that result's
|
|
246
|
+
* own page (`executionUrl`) when the server sent one. The id stays the link
|
|
247
|
+
* text (not a constant word) so the column is scannable and clickable.
|
|
248
|
+
*/
|
|
249
|
+
function resultCell(row) {
|
|
250
|
+
const resultId = row.resultId ?? '';
|
|
251
|
+
return row.executionUrl && resultId
|
|
252
|
+
? `[${escapeMarkdownLinkText(resultId)}](${escapeMarkdownUrl(row.executionUrl)})`
|
|
253
|
+
: escapeTableCell(resultId);
|
|
254
|
+
}
|
|
255
|
+
export function formatFailureCounts(summary) {
|
|
256
|
+
return [
|
|
257
|
+
`${summary.failed} failed`,
|
|
258
|
+
...(summary.blocked ? [`${summary.blocked} blocked`] : []),
|
|
259
|
+
...(summary.cancelled ? [`${summary.cancelled} cancelled`] : []),
|
|
260
|
+
...(summary.errors ? [`${summary.errors} with errors`] : []),
|
|
261
|
+
].join(', ');
|
|
262
|
+
}
|
|
263
|
+
function runFailureLines(summary) {
|
|
264
|
+
return (summary.runFailures ?? []).map(failure => `> Run ${inlineCode(failure.runId)} — ${failure.status}: ${inlineCode(failure.message)}`);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Markdown table for the GitHub job summary: the launch (or launches) the
|
|
268
|
+
* dispatched tests belong to on a line of its own when the backend named one,
|
|
269
|
+
* then one row per test with its result. A test that never dispatched because
|
|
270
|
+
* it was already running names that other run's result, whose launch is not
|
|
271
|
+
* this run and is left off the line.
|
|
272
|
+
*/
|
|
199
273
|
export function renderJobSummaryMarkdown(summary) {
|
|
274
|
+
const launches = launchIds(summary.results.filter(row => !isNonDispatchedStatus(row.status)));
|
|
200
275
|
return [
|
|
201
276
|
'## TestSprite results',
|
|
202
277
|
'',
|
|
203
|
-
|
|
278
|
+
...runFailureLines(summary),
|
|
279
|
+
`**${summary.passed}/${summary.total} passed** (${formatFailureCounts(summary)}, ${summary.skipped} skipped, ${summary.timedOut} timed out${summary.running ? `, ${summary.running} still running` : ''})`,
|
|
204
280
|
'',
|
|
205
|
-
|
|
281
|
+
...(launches.length > 0
|
|
282
|
+
? [`${launches.length === 1 ? 'Run' : 'Runs'} ${launches.map(inlineCode).join(', ')}`, '']
|
|
283
|
+
: []),
|
|
284
|
+
'| Test | Status | Result |',
|
|
206
285
|
'| --- | --- | --- |',
|
|
207
|
-
...summary.
|
|
208
|
-
// `|| ` not `?? `: an empty / whitespace-only title must fall back to the
|
|
209
|
-
// id (a blank Test cell is useless), matching JUnit's `name?.trim() || id`.
|
|
210
|
-
const label = row.title?.trim() || row.testId;
|
|
211
|
-
const runId = row.runId ?? '';
|
|
212
|
-
// Test cell links the human label to the TEST-CASE page (`dashboardUrl`);
|
|
213
|
-
// Run cell links to THIS RUN's result page (`executionUrl`). The two are
|
|
214
|
-
// distinct destinations — the run link is absent for a V2 run (no execution
|
|
215
|
-
// page), where the run cell degrades to the raw runId. The label sits in
|
|
216
|
-
// link-text position, so it uses the bracket-aware escaper.
|
|
217
|
-
const test = row.dashboardUrl
|
|
218
|
-
? `[${escapeMarkdownLinkText(label)}](${escapeMarkdownUrl(row.dashboardUrl)})`
|
|
219
|
-
: escapeTableCell(label);
|
|
220
|
-
// Keep the run id as the link text (not a constant "result") so it stays
|
|
221
|
-
// scannable while being clickable.
|
|
222
|
-
const run = row.executionUrl && runId
|
|
223
|
-
? `[${escapeMarkdownLinkText(runId)}](${escapeMarkdownUrl(row.executionUrl)})`
|
|
224
|
-
: escapeTableCell(runId);
|
|
225
|
-
return `| ${test} | ${escapeTableCell(row.status)} | ${run} |`;
|
|
226
|
-
}),
|
|
286
|
+
...summary.results.map(row => `| ${testCell(row)} | ${escapeTableCell(row.status)} | ${resultCell(row)} |`),
|
|
227
287
|
'',
|
|
228
288
|
].join('\n');
|
|
229
289
|
}
|
|
@@ -232,10 +292,12 @@ export function renderJobSummaryMarkdown(summary) {
|
|
|
232
292
|
* after `::`). Per GitHub's rules, `%`, CR and LF are percent-encoded so a raw
|
|
233
293
|
* multiline run error can never introduce a newline that starts a second
|
|
234
294
|
* `::command::` line in the Actions output stream (`%` first, so the encodings
|
|
235
|
-
* we add are not themselves re-encoded).
|
|
295
|
+
* we add are not themselves re-encoded). The line is printed to a log a
|
|
296
|
+
* terminal or the Actions viewer shows, so the server's text loses its escape
|
|
297
|
+
* sequences and control characters ({@link terminalSafe}) once CR is encoded.
|
|
236
298
|
*/
|
|
237
|
-
function escapeCommandData(value) {
|
|
238
|
-
return value.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
|
299
|
+
export function escapeCommandData(value) {
|
|
300
|
+
return terminalSafe(value.replace(/%/g, '%25').replace(/\r/g, '%0D')).replace(/\n/g, '%0A');
|
|
239
301
|
}
|
|
240
302
|
/**
|
|
241
303
|
* Escape a value destined for a command PROPERTY (e.g. `title=...`). Beyond the
|
|
@@ -270,18 +332,21 @@ export function emitGithubOutputs(summary, env, sinks, opts = {}) {
|
|
|
270
332
|
}
|
|
271
333
|
if (env.GITHUB_ACTIONS === 'true' || opts.force === true) {
|
|
272
334
|
const annotate = sinks.annotations ?? sinks.stdout;
|
|
273
|
-
for (const
|
|
274
|
-
|
|
335
|
+
for (const failure of summary.runFailures ?? []) {
|
|
336
|
+
annotate(`::error title=TestSprite run ${escapeCommandProperty(failure.runId)}::${escapeCommandData(failure.message)}`);
|
|
337
|
+
}
|
|
338
|
+
for (const row of summary.results) {
|
|
339
|
+
if (row.status === 'passed' || row.status === 'running')
|
|
275
340
|
continue;
|
|
276
341
|
const detail = row.error !== undefined ? ` ${row.error}` : '';
|
|
277
342
|
// Prefer this run's result page over the test-case page — on a failure the
|
|
278
343
|
// result is what the reviewer wants to open. Falls back to the test-case
|
|
279
|
-
// link (
|
|
344
|
+
// link (when the server sent no run link), then to nothing.
|
|
280
345
|
const linkUrl = row.executionUrl ?? row.dashboardUrl;
|
|
281
346
|
const link = linkUrl !== undefined ? ` ${linkUrl}` : '';
|
|
282
347
|
// Escape both halves: a raw multiline run error (or a testId) must not be
|
|
283
348
|
// able to smuggle a second workflow command into the Actions stream.
|
|
284
|
-
const title = `TestSprite ${escapeCommandProperty(row.title?.trim() || row.testId)}`;
|
|
349
|
+
const title = `TestSprite ${escapeCommandProperty(row.title?.trim() || row.testId || row.resultId || row.runId || '(unknown)')}`;
|
|
285
350
|
const message = escapeCommandData(`status=${row.status}${detail}${link}`);
|
|
286
351
|
// Severity mirrors the summary counters: never-dispatched rows are
|
|
287
352
|
// warnings (they may not even gate the exit), real failures are errors.
|
|
@@ -294,13 +359,13 @@ export function emitGithubOutputs(summary, env, sinks, opts = {}) {
|
|
|
294
359
|
* Emit the CI artifacts for a `--wait` run: the machine summary file (when
|
|
295
360
|
* `--summary-file` is set) and the GitHub-native annotations + job-summary table
|
|
296
361
|
* (when `--gh-output` or `GITHUB_ACTIONS=true`). One shared implementation for
|
|
297
|
-
* every `--wait` command — `
|
|
298
|
-
*
|
|
362
|
+
* every `--wait` command — `run` (single + `--all`) and `run --testlist` —
|
|
363
|
+
* so the copies of this block can no longer drift (a
|
|
299
364
|
* per-copy fix like the `notFound` fold reaching only one of them is what this
|
|
300
365
|
* consolidates away). The caller reduces its own envelope to a `CiSummary` first
|
|
301
366
|
* (`summarizeAcceptedPayload` for a batch, `summarizeSingleRun` for one run);
|
|
302
367
|
* this owns only the two sinks and their best-effort writes. `label` names the
|
|
303
|
-
* command in the failure messages (`[run]` / `[
|
|
368
|
+
* command in the failure messages (`[run]` / `[ci run]` / `[testlist]`).
|
|
304
369
|
* Both writes are best-effort — a sink throwing must never change the exit code.
|
|
305
370
|
*/
|
|
306
371
|
export function emitCiArtifacts(summary, opts, io, label, extra = {}) {
|
|
@@ -309,6 +374,7 @@ export function emitCiArtifacts(summary, opts, io, label, extra = {}) {
|
|
|
309
374
|
return;
|
|
310
375
|
if (opts.summaryFile !== undefined) {
|
|
311
376
|
try {
|
|
377
|
+
// The file gets the output names; everything else here reads the wire rows.
|
|
312
378
|
// eslint-disable-next-line security/detect-non-literal-fs-filename -- `--summary-file` is an explicit operator-supplied CI-artifact output path; best-effort in try/catch.
|
|
313
379
|
writeFileSync(opts.summaryFile, `${JSON.stringify(summary, null, 2)}\n`, 'utf8');
|
|
314
380
|
}
|
|
@@ -332,6 +398,7 @@ export function emitCiArtifacts(summary, opts, io, label, extra = {}) {
|
|
|
332
398
|
* Hand the execution report to later steps: its JSON and Markdown are written
|
|
333
399
|
* under `$RUNNER_TEMP` (else the OS temp dir) and their paths appended to
|
|
334
400
|
* `$GITHUB_OUTPUT` as `execution-report-file` / `execution-report-markdown-file`.
|
|
401
|
+
* The JSON names the launch the report describes `runId`, as the summary does.
|
|
335
402
|
* Paths, not bodies — a step output is capped at 1 MiB and multi-line values
|
|
336
403
|
* need heredoc escaping. No-op without `GITHUB_OUTPUT` (nothing can consume
|
|
337
404
|
* them). Best-effort: a write failure is reported and never masks the gate.
|
|
@@ -341,7 +408,7 @@ export function emitExecutionReportOutputs(ready, io) {
|
|
|
341
408
|
if (!outputPath)
|
|
342
409
|
return undefined;
|
|
343
410
|
const dir = io.env.RUNNER_TEMP || tmpdir();
|
|
344
|
-
const safeId = ready.report.
|
|
411
|
+
const safeId = ready.report.runId.replace(/[^A-Za-z0-9_-]/g, '_');
|
|
345
412
|
const jsonPath = join(dir, `testsprite-execution-report-${safeId}.json`);
|
|
346
413
|
const markdownPath = join(dir, `testsprite-execution-report-${safeId}.md`);
|
|
347
414
|
// A `key=value` output line ends at a newline, so a path carrying one would
|
|
@@ -353,7 +420,7 @@ export function emitExecutionReportOutputs(ready, io) {
|
|
|
353
420
|
try {
|
|
354
421
|
// Owner-only: the report carries the run's narrative, error text, fix
|
|
355
422
|
// prompts and screenshot links, and the runner's temp dir is shared.
|
|
356
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Runner temp directory (`$RUNNER_TEMP` or the OS temp dir) plus a sanitised
|
|
423
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Runner temp directory (`$RUNNER_TEMP` or the OS temp dir) plus a sanitised launch id; never caller input.
|
|
357
424
|
writeFileSync(jsonPath, `${JSON.stringify(ready.report, null, 2)}\n`, {
|
|
358
425
|
encoding: 'utf8',
|
|
359
426
|
mode: 0o600,
|
|
@@ -377,7 +444,7 @@ export function emitExecutionReportOutputs(ready, io) {
|
|
|
377
444
|
/**
|
|
378
445
|
* The job-summary Markdown for a batch that has a server execution report.
|
|
379
446
|
*
|
|
380
|
-
* The exit code comes from the CLI's own
|
|
447
|
+
* The exit code comes from the CLI's own execution waits plus whatever did
|
|
381
448
|
* not dispatch; the report describes only the execution. Usually they agree
|
|
382
449
|
* and the summary is the report, byte for byte the App's comment. When they
|
|
383
450
|
* do not — a run the CLI could not read or that timed out, a test refused
|
|
@@ -387,22 +454,27 @@ export function emitExecutionReportOutputs(ready, io) {
|
|
|
387
454
|
* also shows agrees — the counts match — and keeps the App's comment as is.
|
|
388
455
|
*/
|
|
389
456
|
export function reconcileExecutionReportMarkdown(summary, ready) {
|
|
390
|
-
const localNonPassed = summary.
|
|
457
|
+
const localNonPassed = summary.results.filter(row => row.status !== 'passed');
|
|
391
458
|
const { stats } = ready.report;
|
|
392
|
-
const agrees = summary.
|
|
459
|
+
const agrees = !summary.runFailures?.length &&
|
|
460
|
+
!summary.errors &&
|
|
461
|
+
!summary.cancelled &&
|
|
462
|
+
summary.skipped === 0 &&
|
|
393
463
|
summary.timedOut === 0 &&
|
|
394
464
|
summary.passed === stats.passed &&
|
|
395
|
-
summary.failed === stats.failed
|
|
465
|
+
summary.failed === stats.failed &&
|
|
466
|
+
(summary.blocked ?? 0) === stats.blocked &&
|
|
396
467
|
summary.total === stats.total;
|
|
397
468
|
if (agrees)
|
|
398
469
|
return ready.markdown;
|
|
399
470
|
const reported = new Set(ready.report.tests.map(t => t.id));
|
|
400
|
-
const missing = localNonPassed.filter(row => !row.
|
|
471
|
+
const missing = localNonPassed.filter(row => !row.resultId || !reported.has(row.resultId));
|
|
401
472
|
const banner = [
|
|
402
473
|
'> [!WARNING]',
|
|
403
|
-
`> **CI gate: ${summary.passed} of ${summary.total} passed, ${summary
|
|
404
|
-
|
|
405
|
-
|
|
474
|
+
`> **CI gate: ${summary.passed} of ${summary.total} passed, ${formatFailureCounts(summary)}, ${summary.skipped} skipped, ${summary.timedOut} timed out${summary.running ? `, ${summary.running} still running` : ''}.**`,
|
|
475
|
+
...runFailureLines(summary),
|
|
476
|
+
"> The check's result comes from the CLI's own wait for each execution. The report below is the server's view of run " +
|
|
477
|
+
inlineCode(ready.report.runId) +
|
|
406
478
|
(missing.length > 0 ? ' and does not cover the rows listed at the end.' : '.'),
|
|
407
479
|
'',
|
|
408
480
|
];
|
|
@@ -411,32 +483,41 @@ export function reconcileExecutionReportMarkdown(summary, ready) {
|
|
|
411
483
|
'',
|
|
412
484
|
'### Not reflected in the execution report',
|
|
413
485
|
'',
|
|
414
|
-
'| Test | Status | Detail |
|
|
486
|
+
'| Test | Status | Detail | Result |',
|
|
415
487
|
'| --- | --- | --- | --- |',
|
|
416
|
-
...missing.map(row => {
|
|
417
|
-
const label = row.title?.trim() || row.testId;
|
|
418
|
-
const test = row.dashboardUrl
|
|
419
|
-
? `[${escapeMarkdownLinkText(label)}](${escapeMarkdownUrl(row.dashboardUrl)})`
|
|
420
|
-
: escapeTableCell(label);
|
|
421
|
-
const runId = row.runId ?? '';
|
|
422
|
-
const run = row.executionUrl && runId
|
|
423
|
-
? `[${escapeMarkdownLinkText(runId)}](${escapeMarkdownUrl(row.executionUrl)})`
|
|
424
|
-
: escapeTableCell(runId);
|
|
425
|
-
return `| ${test} | ${escapeTableCell(row.status)} | ${escapeTableCell(row.error ?? '')} | ${run} |`;
|
|
426
|
-
}),
|
|
488
|
+
...missing.map(row => `| ${testCell(row)} | ${escapeTableCell(row.status)} | ${escapeTableCell(row.error ?? '')} | ${resultCell(row)} |`),
|
|
427
489
|
'',
|
|
428
490
|
]
|
|
429
491
|
: [];
|
|
430
492
|
return [...banner, ready.markdown.replace(/\s+$/, ''), ...appendix, ''].join('\n');
|
|
431
493
|
}
|
|
432
|
-
/**
|
|
494
|
+
/** Keep the historical failed step output for existing Actions gates. */
|
|
433
495
|
export function emitCiStepOutputs(summary, io) {
|
|
434
496
|
const outputPath = io.env.GITHUB_OUTPUT;
|
|
435
497
|
if (!outputPath)
|
|
436
498
|
return;
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
.
|
|
499
|
+
const blocked = summary.blocked ?? 0;
|
|
500
|
+
const failedRuns = new Set(summary.results
|
|
501
|
+
.filter(row => ['failed', 'blocked', 'cancelled', 'error'].includes(row.status))
|
|
502
|
+
.map(row => row.runId));
|
|
503
|
+
const runFailures = summary.runFailures ?? [];
|
|
504
|
+
const additionalFailures = runFailures.filter(f => f.status !== 'timeout' && !failedRuns.has(f.runId)).length;
|
|
505
|
+
const additionalTimeouts = runFailures.filter(f => f.status === 'timeout').length;
|
|
506
|
+
const gateFailures = summary.failed +
|
|
507
|
+
blocked +
|
|
508
|
+
(summary.cancelled ?? 0) +
|
|
509
|
+
(summary.errors ?? 0) +
|
|
510
|
+
additionalFailures;
|
|
511
|
+
const content = [
|
|
512
|
+
`total=${summary.total}`,
|
|
513
|
+
`passed=${summary.passed}`,
|
|
514
|
+
`failed=${gateFailures}`,
|
|
515
|
+
`skipped=${summary.skipped}`,
|
|
516
|
+
`timedOut=${summary.timedOut + additionalTimeouts}`,
|
|
517
|
+
`blocked=${blocked}`,
|
|
518
|
+
`failedOnly=${summary.failed}`,
|
|
519
|
+
...(summary.running ? [`running=${summary.running}`] : []),
|
|
520
|
+
].join('\n') + '\n';
|
|
440
521
|
try {
|
|
441
522
|
// Runner-provided output file; only numeric counter values are appended.
|
|
442
523
|
// eslint-disable-next-line security/detect-non-literal-fs-filename -- GITHUB_OUTPUT is an explicit runner/operator-provided output path, not API/test content; only computed numeric counters are appended.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Give a CLI-owned .testsprite directory its default rules without replacing user rules. */
|
|
2
|
+
export declare function ensureStateGitignore(dir: string): void;
|
|
3
|
+
/** Result of an lstat call: `null` means the path does not exist. */
|
|
4
|
+
export type GitUtilsStat = {
|
|
5
|
+
isSymbolicLink: boolean;
|
|
6
|
+
} | null;
|
|
7
|
+
export interface GitUtilsDeps {
|
|
8
|
+
existsSync?: (p: string) => boolean;
|
|
9
|
+
exists?: (p: string) => Promise<boolean>;
|
|
10
|
+
/** lstat semantics (never follows symlinks); used to refuse writing through a symlinked .gitignore. */
|
|
11
|
+
lstat?: (p: string) => Promise<GitUtilsStat>;
|
|
12
|
+
/** Sync lstat for diagnostics; a symlinked .gitignore is not trusted (git does not follow it). */
|
|
13
|
+
lstatSync?: (p: string) => GitUtilsStat;
|
|
14
|
+
readFile?: (p: string) => Promise<string>;
|
|
15
|
+
readFileSync?: (p: string) => string;
|
|
16
|
+
/** Appends text to the file, creating it when missing. */
|
|
17
|
+
appendFile?: (p: string, text: string) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns the nearest directory at or above `dir` that contains `.git` (a directory,
|
|
21
|
+
* or a file as in worktrees and submodules), or null. `dir` is resolved to an absolute
|
|
22
|
+
* path first so relative inputs walk the real tree.
|
|
23
|
+
*/
|
|
24
|
+
export declare function findGitRoot(dir: string, deps?: GitUtilsDeps): string | null;
|
|
25
|
+
/** Async variant of {@link findGitRoot}. Errors from the existence check propagate. */
|
|
26
|
+
export declare function findGitRootAsync(dir: string, deps?: GitUtilsDeps): Promise<string | null>;
|
|
27
|
+
/** True when `dir` is inside a Git repository (`.git` directory or file found at or above it). */
|
|
28
|
+
export declare function isInsideGitRepo(dir: string, deps?: GitUtilsDeps): boolean;
|
|
29
|
+
/** Async variant of {@link isInsideGitRepo}. */
|
|
30
|
+
export declare function isInsideGitRepoAsync(dir: string, deps?: GitUtilsDeps): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if `.testsprite` is ignored given the raw content of a `.gitignore` file.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isTestspriteIgnored(content: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Returns true if a `.gitignore` exists in the target directory and ignores `.testsprite/`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function checkTestspriteIgnored(dir: string, deps?: GitUtilsDeps): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Synchronous check for diagnostics: is `dir` inside a Git repository, and is
|
|
41
|
+
* `.testsprite/` ignored by a `.gitignore` between `dir` and the repository root
|
|
42
|
+
* (inclusive)? Reads files only; never shells out to git and never throws.
|
|
43
|
+
*/
|
|
44
|
+
export declare function inspectTestspriteIgnore(dir: string, deps?: GitUtilsDeps): {
|
|
45
|
+
inRepo: boolean;
|
|
46
|
+
ignored: boolean;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Ensures that `.testsprite/` is ignored in the target directory's `.gitignore`.
|
|
50
|
+
* Does nothing outside a Git repository. If `.gitignore` is missing it is created;
|
|
51
|
+
* otherwise the entry is appended (never rewritten), so a concurrent edit is not lost.
|
|
52
|
+
* Refuses to write through a symlinked `.gitignore` (throws).
|
|
53
|
+
*
|
|
54
|
+
* Returns true if the file was modified or created, false if nothing was changed.
|
|
55
|
+
*/
|
|
56
|
+
export declare function ensureTestspriteIgnored(dir: string, deps?: GitUtilsDeps): Promise<boolean>;
|