@cnc-tools/storm 0.12.0 → 0.14.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/dist/application.js +5 -1
- package/dist/bin/storm.js +6 -2
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-FK4RLDEK.js → chunk-27P2QSIM.js} +1 -1
- package/dist/chunks/{chunk-ODQHQJLE.js → chunk-5ED3IDUJ.js} +749 -1121
- package/dist/chunks/{chunk-FSP3SJ35.js → chunk-5TMHYH7G.js} +16 -46
- package/dist/chunks/{chunk-Y3BUNNRG.js → chunk-BFLYGMG3.js} +12 -7
- package/dist/chunks/{chunk-LQKNI3EG.js → chunk-BRUIATTR.js} +6 -6
- package/dist/chunks/{chunk-RYRJNHL7.js → chunk-HOKDKP5A.js} +3 -9
- package/dist/chunks/{chunk-SXW6XN4R.js → chunk-IVRRGGCD.js} +60 -20
- package/dist/chunks/{chunk-TMQQYHUX.js → chunk-QBR5VHJ7.js} +1 -1
- package/dist/chunks/{chunk-YT5OROR7.js → chunk-RA4L2ACU.js} +12 -2
- package/dist/chunks/{chunk-TEEZL3GA.js → chunk-RKONDLPS.js} +17 -71
- package/dist/chunks/{chunk-IYM44FUX.js → chunk-UC6DULWY.js} +2 -2
- package/dist/chunks/{chunk-4XT5RC5T.js → chunk-XPCUINWS.js} +6 -42
- package/dist/chunks/{chunk-U7M3ZB3Z.js → chunk-YBPTMJUM.js} +123 -180
- package/dist/chunks/{chunk-ISGQJIQM.js → chunk-Z5OXOZD3.js} +125 -83
- package/dist/chunks/{chunk-7D6LC5JY.js → chunk-ZH5R7W4A.js} +7 -39
- package/dist/chunks/{live-app-AZ5N5HBD.js → live-app-FBVWUUMT.js} +7 -7
- package/dist/commands/exec/command.d.ts +4 -90
- package/dist/commands/exec/command.js +15 -41
- package/dist/commands/exec/define-run-command.d.ts +19 -100
- package/dist/commands/exec/define-run-command.js +48 -15
- package/dist/commands/exec/driver-plan.d.ts +24 -16
- package/dist/commands/exec/driver-plan.js +34 -15
- package/dist/commands/exec/driver-refusals.js +7 -6
- package/dist/commands/exec/exec-words.d.ts +1 -1
- package/dist/commands/exec/exec-words.js +8 -2
- package/dist/commands/exec/final-results.d.ts +39 -0
- package/dist/commands/exec/final-results.js +29 -0
- package/dist/commands/exec/live-view.js +18 -22
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +15 -109
- package/dist/commands/exec/outcomes.js +25 -39
- package/dist/commands/exec/plan-run.d.ts +11 -3
- package/dist/commands/exec/plan-run.js +3 -2
- package/dist/commands/exec/progress.d.ts +3 -19
- package/dist/commands/exec/progress.js +16 -60
- package/dist/commands/exec/run-command.d.ts +5 -24
- package/dist/commands/exec/run-command.js +32 -84
- package/dist/commands/exec/run-metadata.d.ts +0 -6
- package/dist/commands/exec/run-metadata.js +2 -8
- package/dist/commands/exec/snapshot-text.d.ts +7 -16
- package/dist/commands/exec/snapshot-text.js +9 -49
- package/dist/commands/exec/test-plan.d.ts +2 -1
- package/dist/commands/exec/test-plan.js +13 -4
- package/dist/commands/exec/tests-summary.d.ts +2 -2
- package/dist/commands/exec/view.js +2 -12
- package/dist/commands/exec/worker-chart.d.ts +1 -1
- package/dist/commands/playwright/command.d.ts +12 -97
- package/dist/commands/playwright/command.js +14 -14
- package/dist/commands/playwright/metadata.js +2 -2
- package/dist/commands/runs/facts.d.ts +1 -37
- package/dist/commands/runs/facts.js +4 -36
- package/dist/commands/runs/list/command.d.ts +0 -72
- package/dist/commands/runs/list/command.js +6 -6
- package/dist/commands/runs/list/outcomes.d.ts +0 -36
- package/dist/commands/runs/logs/command.js +6 -6
- package/dist/commands/runs/show/command.d.ts +2 -74
- package/dist/commands/runs/show/command.js +16 -43
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +1 -37
- package/dist/commands/runs/show/outcomes.js +8 -42
- package/dist/commands/snapshots/build/command.d.ts +14 -411
- package/dist/commands/snapshots/build/command.js +59 -234
- package/dist/commands/snapshots/build/metadata.js +10 -7
- package/dist/commands/snapshots/build/outcomes.d.ts +11 -241
- package/dist/commands/snapshots/build/outcomes.js +29 -196
- package/dist/commands/snapshots/list/command.d.ts +2 -36
- package/dist/commands/snapshots/list/command.js +20 -56
- package/dist/commands/snapshots/list/metadata.js +1 -1
- package/dist/commands/snapshots/list/outcomes.d.ts +2 -37
- package/dist/commands/snapshots/list/outcomes.js +13 -53
- package/dist/commands/vitest/command.d.ts +14 -98
- package/dist/commands/vitest/command.js +14 -14
- package/dist/commands/vitest/metadata.js +2 -2
- package/dist/config/resolve.d.ts +1 -1
- package/dist/config/resolve.js +2 -1
- package/dist/config/schema.d.ts +8 -0
- package/dist/config/schema.js +5 -4
- package/dist/core/events.d.ts +5 -6
- package/dist/core/run-state.d.ts +7 -29
- package/dist/core/run-state.js +3 -26
- package/dist/core/run.d.ts +6 -14
- package/dist/core/run.js +17 -28
- package/dist/extensions/playwright/driver.js +17 -10
- package/dist/extensions/testserver/commands/pool/create/command.js +4 -4
- package/dist/extensions/testserver/commands/pool/list/command.js +2 -2
- package/dist/extensions/testserver/definition.d.ts +1 -1
- package/dist/extensions/testserver/extension.d.ts +1 -1
- package/dist/extensions/testserver/options/rules.d.ts +3 -3
- package/dist/extensions/testserver/options/rules.js +5 -5
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/vercel-cli/index.d.ts +1 -0
- package/dist/extensions/testserver/vercel-cli/index.js +1 -0
- package/dist/extensions/testserver/vercel-cli/report.js +5 -2
- package/dist/extensions/testserver/vercel-cli/session-id.d.ts +8 -0
- package/dist/extensions/testserver/vercel-cli/session-id.js +16 -0
- package/dist/extensions/testserver/vitest/config.d.ts +2 -2
- package/dist/extensions/testserver/vitest/config.js +2 -2
- package/dist/extensions/testserver/vitest/container-scope.d.ts +25 -16
- package/dist/extensions/testserver/vitest/container-scope.js +32 -13
- package/dist/extensions/testserver/vitest/diagnostics.d.ts +5 -4
- package/dist/extensions/testserver/vitest/diagnostics.js +15 -8
- package/dist/extensions/testserver/vitest/fixtures.d.ts +10 -1
- package/dist/extensions/testserver/vitest/fixtures.js +36 -10
- package/dist/extensions/testserver/vitest/types.d.ts +9 -0
- package/dist/extensions/vitest/driver.js +28 -14
- package/dist/extensions/vitest/plan/gateways.d.ts +28 -5
- package/dist/extensions/vitest/plan/gateways.js +2 -2
- package/dist/extensions/vitest/plan/list-output.d.ts +5 -0
- package/dist/extensions/vitest/plan/list-output.js +23 -9
- package/dist/extensions/vitest/plan/live/list-gateway.d.ts +3 -2
- package/dist/extensions/vitest/plan/live/list-gateway.js +77 -64
- package/dist/extensions/vitest/plan/plan-over.d.ts +19 -7
- package/dist/extensions/vitest/plan/plan-over.js +18 -7
- package/dist/extensions/vitest/plan/plan.d.ts +14 -5
- package/dist/extensions/vitest/plan/plan.js +23 -9
- package/dist/extensions.d.ts +2 -2
- package/dist/run-directory/index.d.ts +1 -1
- package/dist/run-directory/index.js +0 -1
- package/dist/run-directory/plan.d.ts +3 -2
- package/dist/run-directory/plan.js +6 -3
- package/dist/run-directory/recording.js +2 -2
- package/dist/run-directory/run-record.d.ts +18 -135
- package/dist/run-directory/run-record.js +8 -68
- package/dist/runner/build-snapshots.d.ts +50 -114
- package/dist/runner/build-snapshots.js +70 -159
- package/dist/runner/events.d.ts +4 -88
- package/dist/runner/gateways.d.ts +5 -23
- package/dist/runner/index.d.ts +5 -6
- package/dist/runner/index.js +1 -1
- package/dist/runner/live/snapshot-records.js +7 -18
- package/dist/runner/prepare.d.ts +11 -22
- package/dist/runner/prepare.js +6 -17
- package/dist/runner/ready.d.ts +16 -45
- package/dist/runner/ready.js +34 -59
- package/dist/runner/recipe.d.ts +5 -45
- package/dist/runner/recipe.js +0 -41
- package/dist/runner/sandboxed-command.d.ts +5 -3
- package/dist/runner/sandboxed-command.js +10 -4
- package/dist/runner/scope.d.ts +8 -25
- package/dist/runner/scope.js +4 -8
- package/dist/runner/session.d.ts +18 -65
- package/dist/runner/session.js +15 -83
- package/dist/runner/snapshot-build.d.ts +2 -2
- package/dist/runner/snapshot-cache.d.ts +22 -74
- package/dist/runner/snapshot-cache.js +15 -107
- package/dist/runner/snapshot-inspect.d.ts +9 -13
- package/dist/runner/snapshot-inspect.js +48 -57
- package/dist/runner/snapshot-key.d.ts +9 -14
- package/dist/runner/snapshot-key.js +15 -22
- package/dist/sdk/extension/driver.d.ts +32 -6
- package/dist/sdk/extension/driver.js +12 -2
- package/dist/sdk/extension/index.d.ts +1 -1
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +6 -5
- package/dist/vendor/testserver-sdk/container/api-request.d.ts +2 -3
- package/dist/vendor/testserver-sdk/container/api-request.js +2 -3
- package/dist/vendor/testserver-sdk/container/container.d.ts +12 -2
- package/dist/vendor/testserver-sdk/container/container.js +10 -7
- package/dist/vendor/testserver-sdk/container/recorder.d.ts +29 -7
- package/dist/vendor/testserver-sdk/container/recorder.js +26 -14
- package/dist/vendor/testserver-sdk/index.d.ts +1 -1
- package/dist/vendor/testserver-sdk/index.js +1 -1
- package/dist/vendor/testserver-sdk/proxy/exchange.d.ts +24 -5
- package/dist/vendor/testserver-sdk/proxy/exchange.js +43 -25
- package/dist/vendor/testserver-sdk/proxy/faulted-exchange.js +15 -10
- package/dist/vendor/testserver-sdk/proxy/faults.d.ts +6 -5
- package/dist/vendor/testserver-sdk/proxy/proxy.d.ts +10 -1
- package/dist/vendor/testserver-sdk/proxy/proxy.js +5 -3
- package/dist/vendor/testserver-sdk/proxy/records.d.ts +17 -17
- package/dist/vendor/testserver-sdk/proxy/records.js +18 -17
- package/dist/vendor/testserver-sdk/records/body.d.ts +7 -9
- package/dist/vendor/testserver-sdk/records/body.js +10 -15
- package/dist/vendor/testserver-sdk/records/headers.d.ts +79 -0
- package/dist/vendor/testserver-sdk/records/headers.js +162 -0
- package/dist/vendor/testserver-sdk/records/index.d.ts +2 -1
- package/dist/vendor/testserver-sdk/records/index.js +4 -2
- package/dist/vendor/testserver-sdk/records/records.d.ts +19 -10
- package/package.json +5 -4
- package/skills/overview.md +5 -5
- package/skills/read-run-output.md +8 -9
- package/dist/runner/snapshot-save.d.ts +0 -70
- package/dist/runner/snapshot-save.js +0 -160
- package/dist/runner/snapshot-start.d.ts +0 -25
- package/dist/runner/snapshot-start.js +0 -16
- package/skills/testserver-builds.md +0 -82
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
// commits, and for the checkout's recipe which one a run here starts from and why not from each other one. It reads
|
|
3
3
|
// the cache and Git, and changes nothing: no file is removed, nothing is minted, and no sandbox starts.
|
|
4
4
|
import { resolveBase } from "./base.js";
|
|
5
|
-
import {
|
|
6
|
-
import { builtAtCommit, classifySnapshotEntries, isDevEntry, isExpiredEntry, } from "./snapshot-cache.js";
|
|
5
|
+
import { classifySnapshotEntries, isExpiredEntry, pickSnapshot, } from "./snapshot-cache.js";
|
|
7
6
|
import { snapshotStepsAt } from "./snapshot-key.js";
|
|
8
|
-
import { chooseSnapshotStart } from "./snapshot-start.js";
|
|
9
7
|
/**
|
|
10
8
|
* Inspects the cache from `cwd` for `recipe`, the runner recipe that applies there, if any. With a recipe, in a Git
|
|
11
9
|
* checkout whose HEAD shares history with one of its base refs, it marks for each team and project the snapshot a run
|
|
12
|
-
* here starts from, by a run's own rule (`classifySnapshotEntries`, `
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* here starts from, by a run's own rule (`classifySnapshotEntries`, `pickSnapshot`), and gives each other
|
|
11
|
+
* snapshot of the recipe the reason it isn't picked. It runs the recipe's snapshot steps at the merge-base for the
|
|
12
|
+
* run's snapshot key, as a run does. Otherwise it picks none and
|
|
15
13
|
* says why. `all` adds the snapshots of other recipes, and of the recipe's other regions and runtimes, as
|
|
16
14
|
* `other-recipe`. It lists the cache once and classifies that listing, which removes no file, so an expired entry of
|
|
17
15
|
* the recipe stays and is `expired`. A git failure ends it with `checkout-failed`, as it ends a run.
|
|
@@ -39,13 +37,12 @@ export async function inspectSnapshotCache(context, request) {
|
|
|
39
37
|
directory,
|
|
40
38
|
checkout: null,
|
|
41
39
|
picking: { kind: "none", why: "no-checkout" },
|
|
42
|
-
snapshots: shown.map((entry) => unchecked(entry, now
|
|
40
|
+
snapshots: shown.map((entry) => unchecked(entry, now)),
|
|
43
41
|
unreadable,
|
|
44
42
|
},
|
|
45
43
|
};
|
|
46
44
|
}
|
|
47
45
|
const repoRoot = root.value;
|
|
48
|
-
const savedHere = (entry) => (isDevEntry(entry) ? entry.repoRoot === repoRoot : null);
|
|
49
46
|
const resolved = recipe === undefined ? undefined : await resolveBase(checkout, { repoRoot, baseRefs: recipe.baseRefs });
|
|
50
47
|
if (resolved?.kind === "failed")
|
|
51
48
|
return { kind: "checkout-failed", failure: resolved.failure };
|
|
@@ -56,7 +53,7 @@ export async function inspectSnapshotCache(context, request) {
|
|
|
56
53
|
directory,
|
|
57
54
|
checkout: { repoRoot, head: head.value, mergeBase: null },
|
|
58
55
|
picking: { kind: "none", why: recipe === undefined ? "no-recipe" : "no-base" },
|
|
59
|
-
snapshots: shown.map((entry) => unchecked(entry, now
|
|
56
|
+
snapshots: shown.map((entry) => unchecked(entry, now)),
|
|
60
57
|
unreadable,
|
|
61
58
|
},
|
|
62
59
|
};
|
|
@@ -69,78 +66,48 @@ export async function inspectSnapshotCache(context, request) {
|
|
|
69
66
|
if (!afterBase.ok)
|
|
70
67
|
return { kind: "checkout-failed", failure: afterBase.failure };
|
|
71
68
|
// The one listing above is classified as a run would, but nothing is removed: an expired entry is `expired`.
|
|
72
|
-
const
|
|
69
|
+
const read = classifySnapshotEntries(context, {
|
|
73
70
|
entries,
|
|
74
|
-
repoRoot,
|
|
75
71
|
recipe,
|
|
76
72
|
base: mergeBase,
|
|
77
73
|
snapshotKey: steps.key,
|
|
78
74
|
commitsAfterBase: afterBase.value,
|
|
79
|
-
devSnapshots: devSnapshotReuse(recipe, recipe.reuseDevSnapshot),
|
|
80
75
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const read = classified.value;
|
|
84
|
-
// The choice is per team and project, since the credential that names them isn't minted here. A candidate a run
|
|
85
|
-
// doesn't start from is `not-picked`, and every entry that isn't a candidate keeps the classification's reason,
|
|
86
|
-
// since it is ruled out whoever the run's credential names.
|
|
76
|
+
// The choice is per team and project, since the credential that names them isn't minted here. Every entry that isn't
|
|
77
|
+
// a candidate keeps the classification's reason, since it is ruled out whoever the run's credential names.
|
|
87
78
|
const owners = new Map(read.candidates.map(({ entry }) => [`${entry.teamId}\0${entry.projectId}`, entry]));
|
|
88
79
|
const picked = new Set();
|
|
89
80
|
for (const owner of owners.values()) {
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
picked.add(
|
|
81
|
+
const pick = pickSnapshot(read.candidates, owner);
|
|
82
|
+
if (pick !== undefined)
|
|
83
|
+
picked.add(pick);
|
|
93
84
|
}
|
|
94
|
-
|
|
95
|
-
const inHistory = new Map();
|
|
96
|
-
const behind = new Map();
|
|
85
|
+
const place = historyPlacer(context, { repoRoot, mergeBase, commitsAfterBase: afterBase.value });
|
|
97
86
|
const snapshots = [];
|
|
98
87
|
for (const verdict of read.verdicts) {
|
|
99
88
|
const { entry } = verdict;
|
|
100
89
|
if (!shows(entry))
|
|
101
90
|
continue;
|
|
102
|
-
const builtAt = builtAtCommit(entry);
|
|
103
|
-
const kind = isDevEntry(entry) ? "dev" : "base";
|
|
104
91
|
const expired = isExpiredEntry(entry, now);
|
|
105
92
|
if (verdict.kind === "candidate") {
|
|
106
93
|
const { candidate } = verdict;
|
|
107
|
-
const isPicked = picked.has(candidate);
|
|
108
94
|
snapshots.push({
|
|
109
95
|
entry,
|
|
110
|
-
kind,
|
|
111
|
-
builtAt,
|
|
112
96
|
inHistory: true,
|
|
113
97
|
builtBehind: candidate.builtBehind,
|
|
114
|
-
savedHere: savedHere(entry),
|
|
115
98
|
expired,
|
|
116
|
-
picked:
|
|
117
|
-
reason:
|
|
99
|
+
picked: picked.has(candidate),
|
|
100
|
+
reason: null,
|
|
118
101
|
});
|
|
119
102
|
continue;
|
|
120
103
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return { kind: "checkout-failed", failure: asked.failure };
|
|
126
|
-
contained = asked.value;
|
|
127
|
-
inHistory.set(builtAt, contained);
|
|
128
|
-
}
|
|
129
|
-
let builtBehind = contained ? behind.get(builtAt) : undefined;
|
|
130
|
-
if (contained && builtBehind === undefined) {
|
|
131
|
-
const counted = await checkout.commitCount({ repoRoot, from: builtAt, to: "HEAD" });
|
|
132
|
-
if (!counted.ok)
|
|
133
|
-
return { kind: "checkout-failed", failure: counted.failure };
|
|
134
|
-
builtBehind = counted.value;
|
|
135
|
-
behind.set(builtAt, builtBehind);
|
|
136
|
-
}
|
|
104
|
+
// Where a snapshot no run here starts from sits in HEAD's history, for the list only.
|
|
105
|
+
const placed = await place(entry.base);
|
|
106
|
+
if (!placed.ok)
|
|
107
|
+
return { kind: "checkout-failed", failure: placed.failure };
|
|
137
108
|
snapshots.push({
|
|
138
109
|
entry,
|
|
139
|
-
|
|
140
|
-
builtAt,
|
|
141
|
-
inHistory: contained,
|
|
142
|
-
builtBehind: builtBehind ?? null,
|
|
143
|
-
savedHere: savedHere(entry),
|
|
110
|
+
...placed.value,
|
|
144
111
|
expired,
|
|
145
112
|
picked: false,
|
|
146
113
|
reason: verdict.kind === "rejected" ? verdict.rejection.reason : "other-recipe",
|
|
@@ -158,16 +125,40 @@ export async function inspectSnapshotCache(context, request) {
|
|
|
158
125
|
};
|
|
159
126
|
}
|
|
160
127
|
/** An entry storm checked nothing of: outside a Git checkout, or with no recipe or no base to pick for. */
|
|
161
|
-
function unchecked(entry, now
|
|
128
|
+
function unchecked(entry, now) {
|
|
162
129
|
return {
|
|
163
130
|
entry,
|
|
164
|
-
kind: isDevEntry(entry) ? "dev" : "base",
|
|
165
|
-
builtAt: builtAtCommit(entry),
|
|
166
131
|
inHistory: null,
|
|
167
132
|
builtBehind: null,
|
|
168
|
-
savedHere,
|
|
169
133
|
expired: isExpiredEntry(entry, now),
|
|
170
134
|
picked: false,
|
|
171
135
|
reason: null,
|
|
172
136
|
};
|
|
173
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Where a base sits in HEAD's history, for the list: whether HEAD is it or holds it, and if so how many commits HEAD
|
|
140
|
+
* has that it lacks. Git is asked at most once per base, and nothing for the merge-base, whose count the caller has.
|
|
141
|
+
*/
|
|
142
|
+
function historyPlacer(context, request) {
|
|
143
|
+
const { repoRoot } = request;
|
|
144
|
+
const known = new Map([
|
|
145
|
+
[request.mergeBase, { inHistory: true, builtBehind: request.commitsAfterBase }],
|
|
146
|
+
]);
|
|
147
|
+
return async (base) => {
|
|
148
|
+
const answer = known.get(base);
|
|
149
|
+
if (answer !== undefined)
|
|
150
|
+
return { ok: true, value: answer };
|
|
151
|
+
const contained = await context.checkout.contains({ repoRoot, ancestor: base, descendant: "HEAD" });
|
|
152
|
+
if (!contained.ok)
|
|
153
|
+
return contained;
|
|
154
|
+
let placed = { inHistory: false, builtBehind: null };
|
|
155
|
+
if (contained.value) {
|
|
156
|
+
const counted = await context.checkout.commitCount({ repoRoot, from: base, to: "HEAD" });
|
|
157
|
+
if (!counted.ok)
|
|
158
|
+
return counted;
|
|
159
|
+
placed = { inHistory: true, builtBehind: counted.value };
|
|
160
|
+
}
|
|
161
|
+
known.set(base, placed);
|
|
162
|
+
return { ok: true, value: placed };
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -3,9 +3,9 @@ import { type CheckedRecipe, type ResolvedRunnerStep, type RunnerStep } from "./
|
|
|
3
3
|
/**
|
|
4
4
|
* Bump when a runner snapshot changes in a way its steps' text doesn't show (the scripts between the steps, what is
|
|
5
5
|
* uploaded, the build sandbox), or the key's encoding changes, so earlier snapshots stop matching. 2 added each step's
|
|
6
|
-
* runner secret names.
|
|
6
|
+
* runner secret names. 3 dropped dev snapshots.
|
|
7
7
|
*/
|
|
8
|
-
export declare const SNAPSHOT_FORMAT =
|
|
8
|
+
export declare const SNAPSHOT_FORMAT = 3;
|
|
9
9
|
/** Where the repository lives in every runner and build sandbox. */
|
|
10
10
|
export declare const SANDBOX_ROOT = "/vercel/sandbox";
|
|
11
11
|
/** The names of the files uploaded to a sandbox's staging directory. */
|
|
@@ -16,14 +16,8 @@ export declare const STAGED_FILES: {
|
|
|
16
16
|
readonly untrackedTarball: "untracked.tgz";
|
|
17
17
|
readonly untrackedFileList: "untracked-files";
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
* commit isn't in a sandbox's repository. Then removes untracked files and directories, nested Git repositories
|
|
22
|
-
* included, keeping ignored ones such as `node_modules` and build outputs.
|
|
23
|
-
*/
|
|
24
|
-
export declare const RESET_TO_BASE: readonly string[];
|
|
25
|
-
/** A bash script that stops at the first failure and runs in the repository's root. */
|
|
26
|
-
export declare function bashScript(lines: readonly string[]): string;
|
|
19
|
+
/** A bash script that stops at the first failure and runs in the repository's root, `/vercel/sandbox` by default. */
|
|
20
|
+
export declare function bashScript(lines: readonly string[], root?: string): string;
|
|
27
21
|
/**
|
|
28
22
|
* Extracts the base's files from `<staging>/base.tgz` and commits exactly its tracked files
|
|
29
23
|
* (`<staging>/base-files`), before the prebuild steps. `git add -A` would drop tracked files `.gitignore` matches.
|
|
@@ -31,11 +25,12 @@ export declare function bashScript(lines: readonly string[]): string;
|
|
|
31
25
|
export declare function baseIndexScript(base: string, staging: string): string;
|
|
32
26
|
/**
|
|
33
27
|
* Applies and commits a run's patch and untracked files, uploaded to `staging`, in a runner sandbox. It first resets
|
|
34
|
-
* the repository to its root commit, the base's tracked files,
|
|
35
|
-
*
|
|
36
|
-
*
|
|
28
|
+
* the repository to its root commit, which holds the base's tracked files (`baseIndexScript`), since the real base
|
|
29
|
+
* commit isn't in a sandbox's repository, and removes untracked files and nested Git repositories `.gitignore`
|
|
30
|
+
* doesn't match, keeping ignored ones such as `node_modules` and build outputs. `root` is the repository, which an
|
|
31
|
+
* integration test points at a temporary checkout.
|
|
37
32
|
*/
|
|
38
|
-
export declare function applyScript(staging: string): string;
|
|
33
|
+
export declare function applyScript(staging: string, root?: string): string;
|
|
39
34
|
/**
|
|
40
35
|
* The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, each toolchain step's label, script and
|
|
41
36
|
* `secrets=<its runner secret names, sorted, joined with ",">`, the base-index script with the placeholders `<base>`
|
|
@@ -7,9 +7,9 @@ import { resolveSteps } from "./recipe.js";
|
|
|
7
7
|
/**
|
|
8
8
|
* Bump when a runner snapshot changes in a way its steps' text doesn't show (the scripts between the steps, what is
|
|
9
9
|
* uploaded, the build sandbox), or the key's encoding changes, so earlier snapshots stop matching. 2 added each step's
|
|
10
|
-
* runner secret names.
|
|
10
|
+
* runner secret names. 3 dropped dev snapshots.
|
|
11
11
|
*/
|
|
12
|
-
export const SNAPSHOT_FORMAT =
|
|
12
|
+
export const SNAPSHOT_FORMAT = 3;
|
|
13
13
|
/** Where the repository lives in every runner and build sandbox. */
|
|
14
14
|
export const SANDBOX_ROOT = "/vercel/sandbox";
|
|
15
15
|
/** The names of the files uploaded to a sandbox's staging directory. */
|
|
@@ -22,19 +22,9 @@ export const STAGED_FILES = {
|
|
|
22
22
|
};
|
|
23
23
|
/** The identity of the commits the scripts make, with no hook or signing in the way. */
|
|
24
24
|
const GIT_IDENTITY = "-c user.email=storm-runner@vercel.invalid -c user.name='storm runner' -c commit.gpgsign=false";
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* included, keeping ignored ones such as `node_modules` and build outputs.
|
|
29
|
-
*/
|
|
30
|
-
export const RESET_TO_BASE = [
|
|
31
|
-
"root=$(git rev-list --max-parents=0 HEAD)",
|
|
32
|
-
'git reset -q --hard "$root"',
|
|
33
|
-
"git clean -ffdq",
|
|
34
|
-
];
|
|
35
|
-
/** A bash script that stops at the first failure and runs in the repository's root. */
|
|
36
|
-
export function bashScript(lines) {
|
|
37
|
-
return ["set -euo pipefail", `cd ${SANDBOX_ROOT}`, ...lines].join("\n");
|
|
25
|
+
/** A bash script that stops at the first failure and runs in the repository's root, `/vercel/sandbox` by default. */
|
|
26
|
+
export function bashScript(lines, root = SANDBOX_ROOT) {
|
|
27
|
+
return ["set -euo pipefail", `cd ${root}`, ...lines].join("\n");
|
|
38
28
|
}
|
|
39
29
|
/**
|
|
40
30
|
* Extracts the base's files from `<staging>/base.tgz` and commits exactly its tracked files
|
|
@@ -54,26 +44,29 @@ export function baseIndexScript(base, staging) {
|
|
|
54
44
|
}
|
|
55
45
|
/**
|
|
56
46
|
* Applies and commits a run's patch and untracked files, uploaded to `staging`, in a runner sandbox. It first resets
|
|
57
|
-
* the repository to its root commit, the base's tracked files,
|
|
58
|
-
*
|
|
59
|
-
*
|
|
47
|
+
* the repository to its root commit, which holds the base's tracked files (`baseIndexScript`), since the real base
|
|
48
|
+
* commit isn't in a sandbox's repository, and removes untracked files and nested Git repositories `.gitignore`
|
|
49
|
+
* doesn't match, keeping ignored ones such as `node_modules` and build outputs. `root` is the repository, which an
|
|
50
|
+
* integration test points at a temporary checkout.
|
|
60
51
|
*/
|
|
61
|
-
export function applyScript(staging) {
|
|
52
|
+
export function applyScript(staging, root = SANDBOX_ROOT) {
|
|
62
53
|
const patch = `${staging}/${STAGED_FILES.patch}`;
|
|
63
54
|
const tarball = `${staging}/${STAGED_FILES.untrackedTarball}`;
|
|
64
55
|
const fileList = `${staging}/${STAGED_FILES.untrackedFileList}`;
|
|
65
56
|
return bashScript([
|
|
66
|
-
|
|
57
|
+
"root=$(git rev-list --max-parents=0 HEAD)",
|
|
58
|
+
'git reset -q --hard "$root"',
|
|
59
|
+
"git clean -ffdq",
|
|
67
60
|
// A build may have rewritten tracked files with the same content.
|
|
68
61
|
"git update-index -q --refresh || true",
|
|
69
62
|
`if [ -s ${patch} ]; then git apply --index --binary ${patch}; fi`,
|
|
70
63
|
`if [ -s ${tarball} ]; then`,
|
|
71
|
-
` tar --warning=no-unknown-keyword -xzf ${tarball} -C ${
|
|
64
|
+
` tar --warning=no-unknown-keyword -xzf ${tarball} -C ${root}`,
|
|
72
65
|
` git --literal-pathspecs add -f --pathspec-from-file=${fileList} --pathspec-file-nul`,
|
|
73
66
|
"fi",
|
|
74
67
|
`git ${GIT_IDENTITY} commit -q --no-verify --allow-empty -m run`,
|
|
75
68
|
`rm -f ${patch} ${tarball} ${fileList}`,
|
|
76
|
-
]);
|
|
69
|
+
], root);
|
|
77
70
|
}
|
|
78
71
|
/**
|
|
79
72
|
* The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, each toolchain step's label, script and
|
|
@@ -16,13 +16,27 @@ export interface DriverHelp {
|
|
|
16
16
|
readonly description: string;
|
|
17
17
|
}[];
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* A driver whose plan step counts only the test files by default: `--count-tests`'s help, in words that name the
|
|
21
|
+
* driver's program, which say what counting each test costs and what counting only the files gives up.
|
|
22
|
+
*/
|
|
23
|
+
export interface DriverTestCount {
|
|
24
|
+
readonly description: string;
|
|
25
|
+
}
|
|
26
|
+
/** What a run says to do next, in words that name the driver's program. */
|
|
20
27
|
export interface DriverHints {
|
|
21
28
|
/**
|
|
22
29
|
* What to do about a run whose tests reported no final result, such as how to list storm's reporter in the program's
|
|
23
30
|
* config. The summary's tests line says it after `no final test results: `.
|
|
24
31
|
*/
|
|
25
32
|
readonly noFinalResults: string;
|
|
33
|
+
/**
|
|
34
|
+
* The steps that make the program report each test's final result to storm, one sentence or more apiece, which
|
|
35
|
+
* the `no_final_test_results` warning lists as its next steps: a run whose program exited 0 and reported none warns it. Each
|
|
36
|
+
* step names the file to change and the exact code to put there, so an agent can follow it without reading storm's
|
|
37
|
+
* docs. At most two: text output shows only an error's first two next steps.
|
|
38
|
+
*/
|
|
39
|
+
readonly addReporter: readonly string[];
|
|
26
40
|
}
|
|
27
41
|
/** What a driver's plan step works from. */
|
|
28
42
|
export interface DriverPlanRequest {
|
|
@@ -32,6 +46,11 @@ export interface DriverPlanRequest {
|
|
|
32
46
|
readonly cwd: string;
|
|
33
47
|
/** The program's binary to start there: the path of the one the launcher found. */
|
|
34
48
|
readonly bin: string;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the plan step counts each test, not only the test files: true when the run took `--count-tests`, and
|
|
51
|
+
* always true for a driver with no `countTests`, whose plan step always counts each test.
|
|
52
|
+
*/
|
|
53
|
+
readonly countTests: boolean;
|
|
35
54
|
/** Aborts once the invocation is signaled: the plan step stops what it started and answers `canceled`. */
|
|
36
55
|
readonly signal: AbortSignal;
|
|
37
56
|
}
|
|
@@ -43,15 +62,15 @@ export declare const DRIVER_PLAN_FAILURE_KINDS: readonly ["start-failed", "timed
|
|
|
43
62
|
*/
|
|
44
63
|
export type DriverPlanFailureKind = (typeof DRIVER_PLAN_FAILURE_KINDS)[number];
|
|
45
64
|
/**
|
|
46
|
-
* What a plan step answers: the test plan, the
|
|
47
|
-
* couldn't say, already worded. `kind` is one of the ways it fails, or `canceled` when the request's signal stopped it,
|
|
65
|
+
* What a plan step answers: the test plan, the test files the program would run and, when it counted them, the tests in
|
|
66
|
+
* them (`tests`, absent when it counted only the files), or why it couldn't say, already worded. `kind` is one of the ways it fails, or `canceled` when the request's signal stopped it,
|
|
48
67
|
* which cancels the run. `message` says what went wrong in the driver's words, with the timeout, the exit code or the
|
|
49
68
|
* signal that ended the program in it; `driver_plan_failed` carries it, and the launcher reads none for `canceled`.
|
|
50
69
|
*/
|
|
51
70
|
export type DriverPlanAnswer = {
|
|
52
71
|
readonly ok: true;
|
|
53
72
|
readonly plan: {
|
|
54
|
-
readonly tests
|
|
73
|
+
readonly tests?: number;
|
|
55
74
|
readonly files: number;
|
|
56
75
|
};
|
|
57
76
|
} | {
|
|
@@ -69,7 +88,7 @@ export interface DriverPlanned {
|
|
|
69
88
|
* `--json-schema` shows.
|
|
70
89
|
*/
|
|
71
90
|
export interface DriverRefusalWords {
|
|
72
|
-
/** `no_matching_tests`: the plan step ran and counted no test. */
|
|
91
|
+
/** `no_matching_tests`: the plan step ran and counted no test, or no test file when it counted only the files. */
|
|
73
92
|
readonly noMatchingTests: {
|
|
74
93
|
readonly description: string;
|
|
75
94
|
/** What went wrong. */
|
|
@@ -100,7 +119,12 @@ export interface DriverRefusalWords {
|
|
|
100
119
|
* - `launch`: the argv that starts the program with `args`, such as `[bin, "run", ...args]`. `bin` is the path of the
|
|
101
120
|
* binary the launcher found, or the program's bare name where the runner's `PATH` finds it.
|
|
102
121
|
* - `plan`: its plan step, over its Context: asks the program what it would run with the request's arguments, without
|
|
103
|
-
* running it, and words its failure. The launcher calls it once, before anything is minted, acquired or started
|
|
122
|
+
* running it, and words its failure. The launcher calls it once, before anything is minted, acquired or started, and
|
|
123
|
+
* only for a run that counts: one whose config file sets `testPlan`, or that took `--count-tests`.
|
|
124
|
+
* - `countTests`: present for a driver whose plan step counts only the test files unless the run asks it to count each
|
|
125
|
+
* test, which is faster for a program that must load each test file to list its tests. Its command then takes
|
|
126
|
+
* `--count-tests`, which sets the plan request's `countTests`, and `description` is that flag's help, in the
|
|
127
|
+
* driver's words. Without it, the plan step always counts each test, and the command takes no such flag.
|
|
104
128
|
* - `help`: its part of its command's leaf help.
|
|
105
129
|
* - `hints`: what its run's summary says to do next.
|
|
106
130
|
* - `refusals`: what its two refusals say, beside the message its plan step answers.
|
|
@@ -113,6 +137,7 @@ export interface DriverSpec<Name extends string, Context> {
|
|
|
113
137
|
readonly context: () => Context;
|
|
114
138
|
readonly launch: (bin: string, args: readonly string[]) => readonly string[];
|
|
115
139
|
readonly plan: (context: NoInfer<Context>) => (request: DriverPlanRequest) => Promise<DriverPlanAnswer>;
|
|
140
|
+
readonly countTests?: DriverTestCount;
|
|
116
141
|
readonly help: DriverHelp;
|
|
117
142
|
readonly hints: DriverHints;
|
|
118
143
|
readonly refusals: DriverRefusalWords;
|
|
@@ -130,6 +155,7 @@ export interface Driver<Name extends string = string, Context = unknown> {
|
|
|
130
155
|
readonly context: () => Context;
|
|
131
156
|
readonly launch: (bin: string, args: readonly string[]) => readonly string[];
|
|
132
157
|
readonly plan: (context: unknown) => (request: DriverPlanRequest) => Promise<DriverPlanAnswer>;
|
|
158
|
+
readonly countTests?: DriverTestCount;
|
|
133
159
|
readonly help: DriverHelp;
|
|
134
160
|
readonly hints: DriverHints;
|
|
135
161
|
readonly refusals: DriverRefusalWords;
|
|
@@ -14,8 +14,18 @@ export const DRIVER_PLAN_FAILURE_KINDS = ["start-failed", "timed-out", "exited",
|
|
|
14
14
|
* from there. The launcher makes its run command from it.
|
|
15
15
|
*/
|
|
16
16
|
export function defineDriver(spec) {
|
|
17
|
-
const { name, program, context, launch, plan, help, hints, refusals } = spec;
|
|
18
|
-
const driver = {
|
|
17
|
+
const { name, program, context, launch, plan, countTests, help, hints, refusals } = spec;
|
|
18
|
+
const driver = {
|
|
19
|
+
name,
|
|
20
|
+
program,
|
|
21
|
+
context,
|
|
22
|
+
launch,
|
|
23
|
+
plan,
|
|
24
|
+
...(countTests === undefined ? {} : { countTests }),
|
|
25
|
+
help,
|
|
26
|
+
hints,
|
|
27
|
+
refusals,
|
|
28
|
+
};
|
|
19
29
|
// The one cast: the launcher's view of the driver's plan step, whose parameter is the driver's Context and which the
|
|
20
30
|
// launcher calls with `unknown`. Only the Context's routing is left for it to rest on: the launcher hands a Context
|
|
21
31
|
// only to the plan step of the driver that built it, by the driver's name (`planDriverCommand`,
|
|
@@ -5,7 +5,7 @@ export type { CredentialFailure, CredentialOrigin, CredentialOutcome, Credential
|
|
|
5
5
|
export { tokenRequestFailureFacts, tokenRequestFailureShape } from "./token-request-facts.ts";
|
|
6
6
|
export type { Clock, Timer } from "./time.ts";
|
|
7
7
|
export { defineResource, type ResourceSpec } from "./resource.ts";
|
|
8
|
-
export { argsText, defineDriver, type Driver, DRIVER_PLAN_FAILURE_KINDS, type DriverHelp, type DriverHints, type DriverPlanAnswer, type DriverPlanFailureKind, type DriverPlanned, type DriverPlanRequest, type DriverRefusalWords, type DriverSpec, } from "./driver.ts";
|
|
8
|
+
export { argsText, defineDriver, type Driver, DRIVER_PLAN_FAILURE_KINDS, type DriverHelp, type DriverHints, type DriverPlanAnswer, type DriverPlanFailureKind, type DriverPlanned, type DriverPlanRequest, type DriverRefusalWords, type DriverSpec, type DriverTestCount, } from "./driver.ts";
|
|
9
9
|
export type { Acquired, AcquireForRunAnswer, AcquireForRunInput, BeforeRunAnswer, BeforeRunInput, LifecycleTypes, MintFailed, NextStep, NoSecrets, Refusal, RefusalContent, ReleaseAfterRunAnswer, ReleaseAfterRunInput, Released, Report, ResourceLifecycle, ResourceUse, ResultAnswer, } from "./lifecycle.ts";
|
|
10
10
|
export type { LauncherContext, StateDirectory } from "./launcher-context.ts";
|
|
11
11
|
export type { LaneDraw, Paint, ResourceNotice } from "./presentation.ts";
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
// and the types its lifecycle reads its options by (`ResolvedOptions`, `OptionSources`);
|
|
17
17
|
// - how a driver is written: one `defineDriver` per driver (`driver.ts`), in its folder's `driver.ts`, which holds
|
|
18
18
|
// what the launcher knows of one program that the command starts (`Driver`): its name, its program, its Context,
|
|
19
|
-
// the argv that starts it, its plan step over its Context (`DriverPlanRequest`, `DriverPlanAnswer`)
|
|
19
|
+
// the argv that starts it, its plan step over its Context (`DriverPlanRequest`, `DriverPlanAnswer`), whether it
|
|
20
|
+
// counts only the test files unless asked (`DriverTestCount`) and its words,
|
|
20
21
|
// its part of its command's help (`DriverHelp`), what its run's summary says to do next (`DriverHints`) and what its
|
|
21
22
|
// two refusals say (`DriverRefusalWords`);
|
|
22
23
|
// - each lifecycle point's input and answer (`lifecycle.ts`), the refusal a lifecycle point words where it refuses
|
|
@@ -11,13 +11,14 @@ export interface Setting<T> {
|
|
|
11
11
|
readonly source: SettingSource;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* What a run counted before it started: `counted`, the
|
|
15
|
-
* `playwright test --list` lists and the
|
|
16
|
-
*
|
|
14
|
+
* What a run counted before it started: `counted`, the test files `storm vitest`'s `vitest list` or `storm
|
|
15
|
+
* playwright`'s `playwright test --list` lists, and the tests in them when the driver counted them too (`tests`, absent
|
|
16
|
+
* for a `storm vitest` run without `--count-tests`, which counts only the files); `not-counted` for a run that counts
|
|
17
|
+
* nothing, such as `storm exec`'s, and for a command that plans no run, such as an extension's own command.
|
|
17
18
|
*/
|
|
18
19
|
export type RunTestPlan = {
|
|
19
20
|
readonly kind: "counted";
|
|
20
|
-
readonly tests
|
|
21
|
+
readonly tests?: number;
|
|
21
22
|
readonly files: number;
|
|
22
23
|
} | {
|
|
23
24
|
readonly kind: "not-counted";
|
|
@@ -50,7 +51,7 @@ export interface FlagHelp {
|
|
|
50
51
|
* value, which a transform may normalize, such as a URL to a short form. Its error messages follow
|
|
51
52
|
* the option's key path, `must be …, not …` (`mustBe`), so the file and the flag say the same.
|
|
52
53
|
* - `default`: the value when neither the file nor a flag gives one; or a function of the planned run, such as one
|
|
53
|
-
* that sizes the option from the
|
|
54
|
+
* that sizes the option from the test files `storm vitest` counted, called once as the options resolve, whose value
|
|
54
55
|
* `schema` checks too. An option whose default is a function takes a string, number or boolean, and the run's test
|
|
55
56
|
* plan lists it with its value and where that came from.
|
|
56
57
|
* - `required`: a resource without this option is a problem.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiRequestRecord, type RecordedBody, type RequestOutcome } from "../records/index.ts";
|
|
1
|
+
import { type ApiRequestRecord, type RecordedBody, type RecordedHeaders, type RequestOutcome } from "../records/index.ts";
|
|
2
2
|
import { type TestserverFailure } from "../testserver/index.ts";
|
|
3
3
|
/**
|
|
4
4
|
* A request body `container.fetch` takes: one it can read whole at once, before it sends anything. A stream or an
|
|
@@ -13,9 +13,8 @@ export type ContainerRequestInit = Omit<RequestInit, "body"> & {
|
|
|
13
13
|
export declare function apiRequestRecord(request: {
|
|
14
14
|
readonly method: string;
|
|
15
15
|
readonly target: string;
|
|
16
|
-
readonly
|
|
16
|
+
readonly requestHeaders: RecordedHeaders;
|
|
17
17
|
readonly requestBody: RecordedBody | undefined;
|
|
18
|
-
readonly responseBody?: RecordedBody | undefined;
|
|
19
18
|
readonly startedAt: number;
|
|
20
19
|
readonly durationMs: number;
|
|
21
20
|
readonly outcome: RequestOutcome;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { splitTarget } from "../records/index.js";
|
|
1
|
+
import { splitTarget, } from "../records/index.js";
|
|
2
2
|
import { excerpt, httpFailure, TEST_ID_HEADER } from "../testserver/index.js";
|
|
3
3
|
/** Statuses whose answer has no body, so a `Response` can't be built with one. */
|
|
4
4
|
const NULL_BODY_STATUSES = new Set([101, 103, 204, 205, 304]);
|
|
@@ -8,9 +8,8 @@ export function apiRequestRecord(request) {
|
|
|
8
8
|
method: request.method,
|
|
9
9
|
url: request.target,
|
|
10
10
|
...splitTarget(request.target),
|
|
11
|
-
|
|
11
|
+
requestHeaders: request.requestHeaders,
|
|
12
12
|
...(request.requestBody === undefined ? {} : { requestBody: request.requestBody }),
|
|
13
|
-
...(request.responseBody === undefined ? {} : { responseBody: request.responseBody }),
|
|
14
13
|
startedAt: request.startedAt,
|
|
15
14
|
durationMs: request.durationMs,
|
|
16
15
|
...request.outcome,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FactoryCall, type FactoryOptions } from "../factories/index.ts";
|
|
2
|
-
import type
|
|
2
|
+
import { type ApiRequestRecord, type ExternalCallRecord } from "../records/index.ts";
|
|
3
3
|
import { type Clock, type ExternalServiceId, type GitProviderId, type SetupScriptId, type TestserverServiceId } from "../testserver/index.ts";
|
|
4
4
|
import { type ContainerRequestInit } from "./api-request.ts";
|
|
5
5
|
import { type ExternalService, type GitProvider, type SetupCall } from "./external.ts";
|
|
@@ -48,6 +48,15 @@ export interface ContainerOptions {
|
|
|
48
48
|
* know whether a service had already started.
|
|
49
49
|
*/
|
|
50
50
|
readonly featureFlags?: FeatureFlags;
|
|
51
|
+
/**
|
|
52
|
+
* The headers whose values its API request and external call records show as sent, in requests and responses,
|
|
53
|
+
* besides `DEFAULT_RECORD_HEADERS` (such as `content-type`), which it adds to: such as `["x-trace"]`; names are
|
|
54
|
+
* compared without regard to case. Every other header's value reads
|
|
55
|
+
* `<redacted>`, but `authorization` and `proxy-authorization`, which show their scheme, and `cookie` and
|
|
56
|
+
* `set-cookie`, which show each cookie's name; those four can't be listed. By default none beyond the defaults. A bad list is a
|
|
57
|
+
* `TypeError` before anything is sent.
|
|
58
|
+
*/
|
|
59
|
+
readonly recordHeaders?: readonly string[];
|
|
51
60
|
}
|
|
52
61
|
/** How one service answered a warmup: started, or why not, in `error`, redacted with the container's `redact`. */
|
|
53
62
|
export type ServiceWarmupOutcome = {
|
|
@@ -156,7 +165,8 @@ export interface Container {
|
|
|
156
165
|
/**
|
|
157
166
|
* `text` with every token secret the container has seen replaced by `<token>`: each string under a token field in
|
|
158
167
|
* its factory calls' inputs, options and responses, its API requests' and external calls' JSON bodies and its setup
|
|
159
|
-
* scripts' return values, and each
|
|
168
|
+
* scripts' return values, and the credentials of each `authorization` header its API requests and external calls
|
|
169
|
+
* sent, whatever the scheme. For printing what
|
|
160
170
|
* Testserver logged.
|
|
161
171
|
*/
|
|
162
172
|
redact(text: string): string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildUntypedFactory, } from "../factories/index.js";
|
|
2
|
+
import { checkRecordHeaders } from "../records/index.js";
|
|
2
3
|
import { checkTestId, describeFailure, generateTestId, redactFailure, routes, systemClock, TestserverCallError, testserverEndpoint, unroutable, } from "../testserver/index.js";
|
|
3
4
|
import { checkContainerRequest, hasNullBody, refusedAnswer } from "./api-request.js";
|
|
4
5
|
import { checkExternalServiceId, checkGitProviderId, checkSetupScriptId, failedAnswer, gitProviderLogs, } from "./external.js";
|
|
@@ -55,6 +56,7 @@ export async function startContainer(options, context = liveSdkContext()) {
|
|
|
55
56
|
checkTestId(options.testId);
|
|
56
57
|
if (options.featureFlags !== undefined)
|
|
57
58
|
checkFeatureFlags(options.featureFlags);
|
|
59
|
+
const recordHeaders = checkRecordHeaders(options.recordHeaders);
|
|
58
60
|
const featureFlags = normalizeFeatureFlags(options.featureFlags ?? {});
|
|
59
61
|
const { testserverUrl } = options;
|
|
60
62
|
const firstStartedAt = context.clock.now();
|
|
@@ -70,7 +72,7 @@ export async function startContainer(options, context = liveSdkContext()) {
|
|
|
70
72
|
});
|
|
71
73
|
if (started.ok) {
|
|
72
74
|
await setFeatureFlags(context, { testserverUrl, testId }, featureFlags);
|
|
73
|
-
return new RunningContainer(context, testserverUrl, testId, started.info, featureFlags);
|
|
75
|
+
return new RunningContainer(context, { testserverUrl, testId, info: started.info, featureFlags, recordHeaders });
|
|
74
76
|
}
|
|
75
77
|
first ??= started.failure;
|
|
76
78
|
const startError = new TestserverCallError({
|
|
@@ -193,18 +195,19 @@ export async function withContainer(options, body, context) {
|
|
|
193
195
|
}
|
|
194
196
|
class RunningContainer {
|
|
195
197
|
#context;
|
|
196
|
-
#recorder
|
|
198
|
+
#recorder;
|
|
197
199
|
#ended = false;
|
|
198
200
|
testserverUrl;
|
|
199
201
|
testId;
|
|
200
202
|
info;
|
|
201
203
|
featureFlags;
|
|
202
|
-
constructor(context,
|
|
204
|
+
constructor(context, started) {
|
|
203
205
|
this.#context = context;
|
|
204
|
-
this
|
|
205
|
-
this.
|
|
206
|
-
this.
|
|
207
|
-
this.
|
|
206
|
+
this.#recorder = new ContainerRecorder(started.recordHeaders);
|
|
207
|
+
this.testserverUrl = started.testserverUrl;
|
|
208
|
+
this.testId = started.testId;
|
|
209
|
+
this.info = started.info;
|
|
210
|
+
this.featureFlags = started.featureFlags;
|
|
208
211
|
}
|
|
209
212
|
get factoryCalls() {
|
|
210
213
|
return this.#recorder.factoryCalls;
|