@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.
Files changed (188) hide show
  1. package/dist/application.js +5 -1
  2. package/dist/bin/storm.js +6 -2
  3. package/dist/build-info.js +1 -1
  4. package/dist/chunks/{chunk-FK4RLDEK.js → chunk-27P2QSIM.js} +1 -1
  5. package/dist/chunks/{chunk-ODQHQJLE.js → chunk-5ED3IDUJ.js} +749 -1121
  6. package/dist/chunks/{chunk-FSP3SJ35.js → chunk-5TMHYH7G.js} +16 -46
  7. package/dist/chunks/{chunk-Y3BUNNRG.js → chunk-BFLYGMG3.js} +12 -7
  8. package/dist/chunks/{chunk-LQKNI3EG.js → chunk-BRUIATTR.js} +6 -6
  9. package/dist/chunks/{chunk-RYRJNHL7.js → chunk-HOKDKP5A.js} +3 -9
  10. package/dist/chunks/{chunk-SXW6XN4R.js → chunk-IVRRGGCD.js} +60 -20
  11. package/dist/chunks/{chunk-TMQQYHUX.js → chunk-QBR5VHJ7.js} +1 -1
  12. package/dist/chunks/{chunk-YT5OROR7.js → chunk-RA4L2ACU.js} +12 -2
  13. package/dist/chunks/{chunk-TEEZL3GA.js → chunk-RKONDLPS.js} +17 -71
  14. package/dist/chunks/{chunk-IYM44FUX.js → chunk-UC6DULWY.js} +2 -2
  15. package/dist/chunks/{chunk-4XT5RC5T.js → chunk-XPCUINWS.js} +6 -42
  16. package/dist/chunks/{chunk-U7M3ZB3Z.js → chunk-YBPTMJUM.js} +123 -180
  17. package/dist/chunks/{chunk-ISGQJIQM.js → chunk-Z5OXOZD3.js} +125 -83
  18. package/dist/chunks/{chunk-7D6LC5JY.js → chunk-ZH5R7W4A.js} +7 -39
  19. package/dist/chunks/{live-app-AZ5N5HBD.js → live-app-FBVWUUMT.js} +7 -7
  20. package/dist/commands/exec/command.d.ts +4 -90
  21. package/dist/commands/exec/command.js +15 -41
  22. package/dist/commands/exec/define-run-command.d.ts +19 -100
  23. package/dist/commands/exec/define-run-command.js +48 -15
  24. package/dist/commands/exec/driver-plan.d.ts +24 -16
  25. package/dist/commands/exec/driver-plan.js +34 -15
  26. package/dist/commands/exec/driver-refusals.js +7 -6
  27. package/dist/commands/exec/exec-words.d.ts +1 -1
  28. package/dist/commands/exec/exec-words.js +8 -2
  29. package/dist/commands/exec/final-results.d.ts +39 -0
  30. package/dist/commands/exec/final-results.js +29 -0
  31. package/dist/commands/exec/live-view.js +18 -22
  32. package/dist/commands/exec/metadata.js +1 -1
  33. package/dist/commands/exec/outcomes.d.ts +15 -109
  34. package/dist/commands/exec/outcomes.js +25 -39
  35. package/dist/commands/exec/plan-run.d.ts +11 -3
  36. package/dist/commands/exec/plan-run.js +3 -2
  37. package/dist/commands/exec/progress.d.ts +3 -19
  38. package/dist/commands/exec/progress.js +16 -60
  39. package/dist/commands/exec/run-command.d.ts +5 -24
  40. package/dist/commands/exec/run-command.js +32 -84
  41. package/dist/commands/exec/run-metadata.d.ts +0 -6
  42. package/dist/commands/exec/run-metadata.js +2 -8
  43. package/dist/commands/exec/snapshot-text.d.ts +7 -16
  44. package/dist/commands/exec/snapshot-text.js +9 -49
  45. package/dist/commands/exec/test-plan.d.ts +2 -1
  46. package/dist/commands/exec/test-plan.js +13 -4
  47. package/dist/commands/exec/tests-summary.d.ts +2 -2
  48. package/dist/commands/exec/view.js +2 -12
  49. package/dist/commands/exec/worker-chart.d.ts +1 -1
  50. package/dist/commands/playwright/command.d.ts +12 -97
  51. package/dist/commands/playwright/command.js +14 -14
  52. package/dist/commands/playwright/metadata.js +2 -2
  53. package/dist/commands/runs/facts.d.ts +1 -37
  54. package/dist/commands/runs/facts.js +4 -36
  55. package/dist/commands/runs/list/command.d.ts +0 -72
  56. package/dist/commands/runs/list/command.js +6 -6
  57. package/dist/commands/runs/list/outcomes.d.ts +0 -36
  58. package/dist/commands/runs/logs/command.js +6 -6
  59. package/dist/commands/runs/show/command.d.ts +2 -74
  60. package/dist/commands/runs/show/command.js +16 -43
  61. package/dist/commands/runs/show/metadata.js +1 -1
  62. package/dist/commands/runs/show/outcomes.d.ts +1 -37
  63. package/dist/commands/runs/show/outcomes.js +8 -42
  64. package/dist/commands/snapshots/build/command.d.ts +14 -411
  65. package/dist/commands/snapshots/build/command.js +59 -234
  66. package/dist/commands/snapshots/build/metadata.js +10 -7
  67. package/dist/commands/snapshots/build/outcomes.d.ts +11 -241
  68. package/dist/commands/snapshots/build/outcomes.js +29 -196
  69. package/dist/commands/snapshots/list/command.d.ts +2 -36
  70. package/dist/commands/snapshots/list/command.js +20 -56
  71. package/dist/commands/snapshots/list/metadata.js +1 -1
  72. package/dist/commands/snapshots/list/outcomes.d.ts +2 -37
  73. package/dist/commands/snapshots/list/outcomes.js +13 -53
  74. package/dist/commands/vitest/command.d.ts +14 -98
  75. package/dist/commands/vitest/command.js +14 -14
  76. package/dist/commands/vitest/metadata.js +2 -2
  77. package/dist/config/resolve.d.ts +1 -1
  78. package/dist/config/resolve.js +2 -1
  79. package/dist/config/schema.d.ts +8 -0
  80. package/dist/config/schema.js +5 -4
  81. package/dist/core/events.d.ts +5 -6
  82. package/dist/core/run-state.d.ts +7 -29
  83. package/dist/core/run-state.js +3 -26
  84. package/dist/core/run.d.ts +6 -14
  85. package/dist/core/run.js +17 -28
  86. package/dist/extensions/playwright/driver.js +17 -10
  87. package/dist/extensions/testserver/commands/pool/create/command.js +4 -4
  88. package/dist/extensions/testserver/commands/pool/list/command.js +2 -2
  89. package/dist/extensions/testserver/definition.d.ts +1 -1
  90. package/dist/extensions/testserver/extension.d.ts +1 -1
  91. package/dist/extensions/testserver/options/rules.d.ts +3 -3
  92. package/dist/extensions/testserver/options/rules.js +5 -5
  93. package/dist/extensions/testserver/resource.d.ts +1 -1
  94. package/dist/extensions/testserver/vercel-cli/index.d.ts +1 -0
  95. package/dist/extensions/testserver/vercel-cli/index.js +1 -0
  96. package/dist/extensions/testserver/vercel-cli/report.js +5 -2
  97. package/dist/extensions/testserver/vercel-cli/session-id.d.ts +8 -0
  98. package/dist/extensions/testserver/vercel-cli/session-id.js +16 -0
  99. package/dist/extensions/testserver/vitest/config.d.ts +2 -2
  100. package/dist/extensions/testserver/vitest/config.js +2 -2
  101. package/dist/extensions/testserver/vitest/container-scope.d.ts +25 -16
  102. package/dist/extensions/testserver/vitest/container-scope.js +32 -13
  103. package/dist/extensions/testserver/vitest/diagnostics.d.ts +5 -4
  104. package/dist/extensions/testserver/vitest/diagnostics.js +15 -8
  105. package/dist/extensions/testserver/vitest/fixtures.d.ts +10 -1
  106. package/dist/extensions/testserver/vitest/fixtures.js +36 -10
  107. package/dist/extensions/testserver/vitest/types.d.ts +9 -0
  108. package/dist/extensions/vitest/driver.js +28 -14
  109. package/dist/extensions/vitest/plan/gateways.d.ts +28 -5
  110. package/dist/extensions/vitest/plan/gateways.js +2 -2
  111. package/dist/extensions/vitest/plan/list-output.d.ts +5 -0
  112. package/dist/extensions/vitest/plan/list-output.js +23 -9
  113. package/dist/extensions/vitest/plan/live/list-gateway.d.ts +3 -2
  114. package/dist/extensions/vitest/plan/live/list-gateway.js +77 -64
  115. package/dist/extensions/vitest/plan/plan-over.d.ts +19 -7
  116. package/dist/extensions/vitest/plan/plan-over.js +18 -7
  117. package/dist/extensions/vitest/plan/plan.d.ts +14 -5
  118. package/dist/extensions/vitest/plan/plan.js +23 -9
  119. package/dist/extensions.d.ts +2 -2
  120. package/dist/run-directory/index.d.ts +1 -1
  121. package/dist/run-directory/index.js +0 -1
  122. package/dist/run-directory/plan.d.ts +3 -2
  123. package/dist/run-directory/plan.js +6 -3
  124. package/dist/run-directory/recording.js +2 -2
  125. package/dist/run-directory/run-record.d.ts +18 -135
  126. package/dist/run-directory/run-record.js +8 -68
  127. package/dist/runner/build-snapshots.d.ts +50 -114
  128. package/dist/runner/build-snapshots.js +70 -159
  129. package/dist/runner/events.d.ts +4 -88
  130. package/dist/runner/gateways.d.ts +5 -23
  131. package/dist/runner/index.d.ts +5 -6
  132. package/dist/runner/index.js +1 -1
  133. package/dist/runner/live/snapshot-records.js +7 -18
  134. package/dist/runner/prepare.d.ts +11 -22
  135. package/dist/runner/prepare.js +6 -17
  136. package/dist/runner/ready.d.ts +16 -45
  137. package/dist/runner/ready.js +34 -59
  138. package/dist/runner/recipe.d.ts +5 -45
  139. package/dist/runner/recipe.js +0 -41
  140. package/dist/runner/sandboxed-command.d.ts +5 -3
  141. package/dist/runner/sandboxed-command.js +10 -4
  142. package/dist/runner/scope.d.ts +8 -25
  143. package/dist/runner/scope.js +4 -8
  144. package/dist/runner/session.d.ts +18 -65
  145. package/dist/runner/session.js +15 -83
  146. package/dist/runner/snapshot-build.d.ts +2 -2
  147. package/dist/runner/snapshot-cache.d.ts +22 -74
  148. package/dist/runner/snapshot-cache.js +15 -107
  149. package/dist/runner/snapshot-inspect.d.ts +9 -13
  150. package/dist/runner/snapshot-inspect.js +48 -57
  151. package/dist/runner/snapshot-key.d.ts +9 -14
  152. package/dist/runner/snapshot-key.js +15 -22
  153. package/dist/sdk/extension/driver.d.ts +32 -6
  154. package/dist/sdk/extension/driver.js +12 -2
  155. package/dist/sdk/extension/index.d.ts +1 -1
  156. package/dist/sdk/extension/index.js +2 -1
  157. package/dist/sdk/extension/resource-definition.d.ts +6 -5
  158. package/dist/vendor/testserver-sdk/container/api-request.d.ts +2 -3
  159. package/dist/vendor/testserver-sdk/container/api-request.js +2 -3
  160. package/dist/vendor/testserver-sdk/container/container.d.ts +12 -2
  161. package/dist/vendor/testserver-sdk/container/container.js +10 -7
  162. package/dist/vendor/testserver-sdk/container/recorder.d.ts +29 -7
  163. package/dist/vendor/testserver-sdk/container/recorder.js +26 -14
  164. package/dist/vendor/testserver-sdk/index.d.ts +1 -1
  165. package/dist/vendor/testserver-sdk/index.js +1 -1
  166. package/dist/vendor/testserver-sdk/proxy/exchange.d.ts +24 -5
  167. package/dist/vendor/testserver-sdk/proxy/exchange.js +43 -25
  168. package/dist/vendor/testserver-sdk/proxy/faulted-exchange.js +15 -10
  169. package/dist/vendor/testserver-sdk/proxy/faults.d.ts +6 -5
  170. package/dist/vendor/testserver-sdk/proxy/proxy.d.ts +10 -1
  171. package/dist/vendor/testserver-sdk/proxy/proxy.js +5 -3
  172. package/dist/vendor/testserver-sdk/proxy/records.d.ts +17 -17
  173. package/dist/vendor/testserver-sdk/proxy/records.js +18 -17
  174. package/dist/vendor/testserver-sdk/records/body.d.ts +7 -9
  175. package/dist/vendor/testserver-sdk/records/body.js +10 -15
  176. package/dist/vendor/testserver-sdk/records/headers.d.ts +79 -0
  177. package/dist/vendor/testserver-sdk/records/headers.js +162 -0
  178. package/dist/vendor/testserver-sdk/records/index.d.ts +2 -1
  179. package/dist/vendor/testserver-sdk/records/index.js +4 -2
  180. package/dist/vendor/testserver-sdk/records/records.d.ts +19 -10
  181. package/package.json +5 -4
  182. package/skills/overview.md +5 -5
  183. package/skills/read-run-output.md +8 -9
  184. package/dist/runner/snapshot-save.d.ts +0 -70
  185. package/dist/runner/snapshot-save.js +0 -160
  186. package/dist/runner/snapshot-start.d.ts +0 -25
  187. package/dist/runner/snapshot-start.js +0 -16
  188. package/skills/testserver-builds.md +0 -82
@@ -1,70 +0,0 @@
1
- import type { RunnerContext } from "./context.ts";
2
- import type { RunnerProgress, RunnerSave } from "./events.ts";
3
- import type { RunnerSnapshotCacheFailure, RunnerSnapshotEntry } from "./gateways.ts";
4
- import type { ReadyRunner } from "./ready.ts";
5
- import type { RunnerSandboxScope } from "./scope.ts";
6
- /** The directories the temp scrub empties: `/tmp`, `/var/tmp`, and `$TMPDIR` when it is set. */
7
- export declare const TEMP_DIRECTORIES: readonly string[];
8
- /**
9
- * Resets the working tree in `root` to its root commit, the base's tracked files (`baseIndexScript`), and removes
10
- * untracked files and nested Git repositories that `.gitignore` doesn't match: the same reset the next run's apply
11
- * starts with (`RESET_TO_BASE`). Ignored files, such as `node_modules`, build outputs and the turbo cache, stay.
12
- *
13
- * It leaves `.git` alone, so the run's commit and anything else the command put in Git stay in the snapshot. Cleaning
14
- * history adds no correctness: the next run resets before it applies. Nor does it hide the run's changes: the ignored
15
- * files the snapshot keeps hold their build outputs. And `git prune` can't promise it either, since it removes only
16
- * loose objects, not packed ones.
17
- */
18
- export declare function scrubGitScript(root?: string): string;
19
- /**
20
- * Empties each of `directories`, shell words that may expand to nothing: deletes what it holds, then, for anything
21
- * left, tries again with `sudo -n`. Fails, naming the directory and what is left, when one still holds something.
22
- */
23
- export declare function scrubTempScript(directories?: readonly string[]): string;
24
- /** What saving a dev snapshot is asked to save: the ready runner sandbox, and the commit it is for. */
25
- export interface SaveDevSnapshotRequest {
26
- /** The runner sandbox the command ran in, and the runner snapshot it started from. */
27
- readonly ready: ReadyRunner;
28
- /** HEAD's branch as the run started, null when detached, which the entry records for display. */
29
- readonly branch: string | null;
30
- /** HEAD's commit as the run started, a full SHA. */
31
- readonly head: string;
32
- }
33
- /**
34
- * How saving a dev snapshot ended (`save`), with the cache entry it recorded for a saved one (`entry`, else null) and
35
- * why the cache couldn't write that entry (`cacheFailure`, else null). A run reads only `save`; `storm snapshots build`
36
- * reports the entry, and fails when it isn't cached.
37
- */
38
- export type DevSnapshotSave = {
39
- readonly save: Extract<RunnerSave, {
40
- readonly kind: "saved";
41
- }>;
42
- readonly entry: RunnerSnapshotEntry;
43
- readonly cacheFailure: RunnerSnapshotCacheFailure | null;
44
- } | {
45
- readonly save: Exclude<RunnerSave, {
46
- readonly kind: "saved";
47
- }>;
48
- readonly entry: null;
49
- readonly cacheFailure: null;
50
- };
51
- /**
52
- * Saves the runner sandbox, once the command ended, as a dev snapshot at the run's HEAD commit. The session gives the
53
- * scope no keep time once a save starts (`session.ts`), so however the save ends, closing stops and deletes the
54
- * sandbox. It resets the working tree to the base the sandbox started from, leaving `.git` alone, empties the temp
55
- * directories, saves the sandbox as a runner snapshot, which the scope then deletes, and records the entry: the
56
- * started-from entry's owner, recipe, snapshot key and base, with the HEAD commit, the checkout's root and, when HEAD
57
- * is on one, the branch. Its entry replaces only the entry this checkout saved at that commit; the snapshot it
58
- * replaces is left to expire, since a run on this machine may be starting from it. Nothing here changes the run's
59
- * outcome: each way it ends is a note.
60
- *
61
- * It searches nothing for the run's secrets: the snapshot keeps what the command and the recipe's steps wrote to
62
- * `$HOME`, the ignored files and `.git`, as a kept runner sandbox does. A resource's token is limited to one test
63
- * resource. A runner secret a step that got it left behind is not: the recipe must not leave one, since later steps
64
- * and commands on the snapshot can read it (`README.md`). Only a later run from this checkout, with that commit as
65
- * HEAD or in HEAD's history, starts from the snapshot.
66
- */
67
- export declare function saveDevSnapshot(context: Pick<RunnerContext, "runnerSandboxes" | "runnerSnapshots" | "clock">, request: SaveDevSnapshotRequest, control: {
68
- readonly scope: RunnerSandboxScope;
69
- readonly signal: AbortSignal;
70
- }, progress: RunnerProgress): Promise<DevSnapshotSave>;
@@ -1,160 +0,0 @@
1
- // Saving the runner sandbox as a dev snapshot once its command ended: reset the working tree to its base and empty
2
- // the temp directories, save the sandbox as a runner snapshot, and record it in the cache for the run's checkout at
3
- // HEAD's commit. The snapshot keeps the rest of what the command and the recipe's steps left, a resource's token or a
4
- // runner secret they wrote included.
5
- import { lineSplitter, outputTail, splitLines } from "./output.js";
6
- import { SNAPSHOT_EXPIRATION_MS } from "./snapshot-cache.js";
7
- import { SANDBOX_ROOT, RESET_TO_BASE } from "./snapshot-key.js";
8
- import { STEP_ENV } from "./steps.js";
9
- /** How many of a failed script's last output lines its note keeps. */
10
- const FAILURE_TAIL_LINES = 3;
11
- /** The directories the temp scrub empties: `/tmp`, `/var/tmp`, and `$TMPDIR` when it is set. */
12
- export const TEMP_DIRECTORIES = ["/tmp", "/var/tmp", '"${TMPDIR:-}"'];
13
- /**
14
- * Resets the working tree in `root` to its root commit, the base's tracked files (`baseIndexScript`), and removes
15
- * untracked files and nested Git repositories that `.gitignore` doesn't match: the same reset the next run's apply
16
- * starts with (`RESET_TO_BASE`). Ignored files, such as `node_modules`, build outputs and the turbo cache, stay.
17
- *
18
- * It leaves `.git` alone, so the run's commit and anything else the command put in Git stay in the snapshot. Cleaning
19
- * history adds no correctness: the next run resets before it applies. Nor does it hide the run's changes: the ignored
20
- * files the snapshot keeps hold their build outputs. And `git prune` can't promise it either, since it removes only
21
- * loose objects, not packed ones.
22
- */
23
- export function scrubGitScript(root = SANDBOX_ROOT) {
24
- return ["set -euo pipefail", `cd ${root}`, ...RESET_TO_BASE].join("\n");
25
- }
26
- /**
27
- * Empties each of `directories`, shell words that may expand to nothing: deletes what it holds, then, for anything
28
- * left, tries again with `sudo -n`. Fails, naming the directory and what is left, when one still holds something.
29
- */
30
- export function scrubTempScript(directories = TEMP_DIRECTORIES) {
31
- return [
32
- "set -euo pipefail",
33
- `for dir in ${directories.join(" ")}; do`,
34
- ' [ -n "$dir" ] && [ -d "$dir" ] || continue',
35
- ' find "$dir" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} + 2>/dev/null || true',
36
- ' if [ -n "$(find "$dir" -mindepth 1 -maxdepth 1 -print -quit)" ]; then',
37
- ' sudo -n find "$dir" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} + 2>/dev/null || true',
38
- " fi",
39
- ' left=$(find "$dir" -mindepth 1 -maxdepth 1 -print -quit)',
40
- ' if [ -n "$left" ]; then echo "couldn\'t empty $dir: $left is left" >&2; exit 1; fi',
41
- "done",
42
- ].join("\n");
43
- }
44
- /**
45
- * Saves the runner sandbox, once the command ended, as a dev snapshot at the run's HEAD commit. The session gives the
46
- * scope no keep time once a save starts (`session.ts`), so however the save ends, closing stops and deletes the
47
- * sandbox. It resets the working tree to the base the sandbox started from, leaving `.git` alone, empties the temp
48
- * directories, saves the sandbox as a runner snapshot, which the scope then deletes, and records the entry: the
49
- * started-from entry's owner, recipe, snapshot key and base, with the HEAD commit, the checkout's root and, when HEAD
50
- * is on one, the branch. Its entry replaces only the entry this checkout saved at that commit; the snapshot it
51
- * replaces is left to expire, since a run on this machine may be starting from it. Nothing here changes the run's
52
- * outcome: each way it ends is a note.
53
- *
54
- * It searches nothing for the run's secrets: the snapshot keeps what the command and the recipe's steps wrote to
55
- * `$HOME`, the ignored files and `.git`, as a kept runner sandbox does. A resource's token is limited to one test
56
- * resource. A runner secret a step that got it left behind is not: the recipe must not leave one, since later steps
57
- * and commands on the snapshot can read it (`README.md`). Only a later run from this checkout, with that commit as
58
- * HEAD or in HEAD's history, starts from the snapshot.
59
- */
60
- export async function saveDevSnapshot(context, request, control, progress) {
61
- const saved = await saveOnce(context, request, control, progress);
62
- if (saved.save.kind !== "saved")
63
- await progress.emit({ kind: "dev-snapshot-not-saved", save: saved.save });
64
- return saved;
65
- }
66
- async function saveOnce(context, request, control, progress) {
67
- const unsaved = (save) => ({
68
- save,
69
- entry: null,
70
- cacheFailure: null,
71
- });
72
- const { ready, branch, head } = request;
73
- const { scope, signal } = control;
74
- const stopped = () => signal.aborted || scope.closed;
75
- if (stopped())
76
- return unsaved({ kind: "stopped" });
77
- const { sandbox, startedFrom } = ready;
78
- const startedAt = context.clock.now().getTime();
79
- await progress.emit({ kind: "dev-snapshot-saving", branch });
80
- for (const script of [scrubGitScript(), scrubTempScript()]) {
81
- if (stopped())
82
- return unsaved({ kind: "stopped" });
83
- const ran = await runSaveScript(context, sandbox, script, signal);
84
- if (ran.kind === "stopped")
85
- return unsaved(ran);
86
- if (ran.kind === "failed")
87
- return unsaved({ kind: "failed", step: "scrub", message: ran.message });
88
- }
89
- if (stopped())
90
- return unsaved({ kind: "stopped" });
91
- const saved = await scope.saveSnapshot(sandbox, { expirationMs: SNAPSHOT_EXPIRATION_MS });
92
- if (!saved.ok)
93
- return unsaved(saved.failure.kind === "aborted"
94
- ? { kind: "stopped" }
95
- : { kind: "failed", step: "save-snapshot", message: saved.failure.message });
96
- // A signal while the snapshot saved: the snapshot exists, but the run records nothing more.
97
- if (signal.aborted)
98
- return unsaved({ kind: "stopped" });
99
- const savedAt = context.clock.now();
100
- const entry = {
101
- teamId: startedFrom.teamId,
102
- projectId: startedFrom.projectId,
103
- region: startedFrom.region,
104
- runtime: startedFrom.runtime,
105
- recipeName: startedFrom.recipeName,
106
- snapshotKey: startedFrom.snapshotKey,
107
- base: startedFrom.base,
108
- ...(branch === null ? {} : { branch }),
109
- head,
110
- repoRoot: ready.repoRoot,
111
- snapshotId: saved.value.snapshotId,
112
- createdAt: savedAt.toISOString(),
113
- expiresAt: saved.value.expiresAt ?? new Date(savedAt.getTime() + SNAPSHOT_EXPIRATION_MS).toISOString(),
114
- };
115
- const written = await context.runnerSnapshots.writeEntry(entry);
116
- if (!written.ok)
117
- await progress.emit({ kind: "snapshot-entry-not-written", failure: written.failure });
118
- const ms = savedAt.getTime() - startedAt;
119
- await progress.emit({
120
- kind: "dev-snapshot-saved",
121
- snapshotId: entry.snapshotId,
122
- branch,
123
- head,
124
- ms,
125
- sizeBytes: saved.value.sizeBytes,
126
- });
127
- return {
128
- save: {
129
- kind: "saved",
130
- snapshotId: entry.snapshotId,
131
- base: entry.base,
132
- branch,
133
- head,
134
- ms,
135
- sizeBytes: saved.value.sizeBytes,
136
- entryWritten: written.ok,
137
- },
138
- entry,
139
- cacheFailure: written.ok ? null : written.failure,
140
- };
141
- }
142
- async function runSaveScript(context, sandbox, script, signal) {
143
- const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
144
- const tail = outputTail(FAILURE_TAIL_LINES);
145
- const keep = (text) => {
146
- for (const line of splitLines(text))
147
- tail.add(line);
148
- };
149
- const ran = await context.runnerSandboxes.runScript(sandbox, { script, env: STEP_ENV }, ({ stream, data }) => keep(splitters[stream].push(data)), signal);
150
- keep(splitters.stdout.flush());
151
- keep(splitters.stderr.flush());
152
- if (!ran.ok)
153
- return ran.failure.kind === "aborted" ? { kind: "stopped" } : { kind: "failed", message: ran.failure.message };
154
- const { exitCode } = ran.value;
155
- if (exitCode === 0)
156
- return { kind: "ok" };
157
- const lines = tail.lines();
158
- const ended = exitCode === null ? "ended without an exit code" : `exited ${exitCode}`;
159
- return { kind: "failed", message: lines.length === 0 ? ended : `${ended}: ${lines.join(" / ")}` };
160
- }
@@ -1,25 +0,0 @@
1
- import type { SnapshotBuildReason } from "./events.ts";
2
- import { type RunnerSnapshotCandidate, type SnapshotCacheRead } from "./snapshot-cache.ts";
3
- /**
4
- * What a runner sandbox starts from: the cached `candidate` (`reuse`), or a base snapshot built at the merge-base
5
- * first, and why (`build`). `storm snapshots build --base` builds no start, so `base` is no reason here.
6
- */
7
- export type SnapshotStart = {
8
- readonly kind: "reuse";
9
- readonly candidate: RunnerSnapshotCandidate;
10
- } | {
11
- readonly kind: "build";
12
- readonly why: Exclude<SnapshotBuildReason, {
13
- readonly kind: "base";
14
- }>;
15
- };
16
- /**
17
- * Chooses what a runner sandbox for `owner`'s team and project starts from. Of the candidates it picks as a run does
18
- * (`pickSnapshot`): with no pick, it builds, saying why each cached snapshot of the recipe doesn't fit
19
- * (`no-snapshot`, `snapshotRejections`); otherwise it reuses the pick. `storm snapshots build --full` makes its own
20
- * `full` start instead of asking.
21
- */
22
- export declare function chooseSnapshotStart(read: SnapshotCacheRead, owner: {
23
- readonly teamId: string;
24
- readonly projectId: string;
25
- }): SnapshotStart;
@@ -1,16 +0,0 @@
1
- // The one rule that decides what a runner sandbox starts from, for a run, `storm snapshots build` and
2
- // `storm snapshots list`: reuse a cached runner snapshot, or build a base snapshot, and why. It reads a cache read and
3
- // changes nothing; carrying the choice out is `obtainSnapshot`'s (`ready.ts`).
4
- import { pickSnapshot, snapshotRejections, } from "./snapshot-cache.js";
5
- /**
6
- * Chooses what a runner sandbox for `owner`'s team and project starts from. Of the candidates it picks as a run does
7
- * (`pickSnapshot`): with no pick, it builds, saying why each cached snapshot of the recipe doesn't fit
8
- * (`no-snapshot`, `snapshotRejections`); otherwise it reuses the pick. `storm snapshots build --full` makes its own
9
- * `full` start instead of asking.
10
- */
11
- export function chooseSnapshotStart(read, owner) {
12
- const pick = pickSnapshot(read.candidates, owner);
13
- if (pick === undefined)
14
- return { kind: "build", why: { kind: "no-snapshot", rejected: snapshotRejections(read, owner) } };
15
- return { kind: "reuse", candidate: pick };
16
- }
@@ -1,82 +0,0 @@
1
- ---
2
- name: testserver-builds
3
- description: Choose the Testserver build that a run uses. Run against the build of a vercel/api pull request when a change needs API code that is not merged.
4
- commands: [vitest, exec]
5
- ---
6
-
7
- # Testserver builds
8
-
9
- Use this skill to choose the Testserver build of a run. Use it also when a change needs vercel/api code that is not merged.
10
-
11
- ## Concepts
12
-
13
- - A **build** is one version of Testserver, such as `20261105T041247Z__65203e5`. Its name is a UTC time and a short commit.
14
- - A **build channel** is a name that moves from build to build.
15
- - `stable` is the default. A cron job in vercel/front promotes the newest main build to `stable` every 20 minutes, when the Testserver tests of vercel/front pass.
16
- - `latest_main` is the newest build of the `main` branch of vercel/api.
17
- - A **PR build** is a build of one vercel/api pull request. The `Testserver` workflow of vercel/api makes one for each push to the pull request. It builds the pull request merged into its base branch. In a stack, the base branch is the pull request below. Thus the PR build of the top pull request contains all the pull requests of the stack.
18
- - The **head commit** of a pull request is the newest commit on its branch, such as `87343a6781b4f540893958e49e8eedaf5bb2b4ad`. Each PR build comes from the workflow run for one head commit.
19
- - A **PR build reference** gives a vercel/api pull request as the build. Write it as `pr:<N>`, such as `pr:104196`, or as the URL of the pull request, such as `https://github.com/vercel/api/pull/104196`. storm changes the URL to `pr:<N>`.
20
-
21
- A run with `pr:<N>` uses a PR build of the head commit of the pull request. If no PR build of that head commit exists, the run stops. It does not wait, and it does not use a PR build of an older head commit.
22
-
23
- storm reads the head commit from GitHub on this machine. If the pool has a Testserver sandbox that was made for `pr:<N>` on the head commit, storm uses the PR build of the newest such Testserver sandbox. It does this only if that PR build has not expired. Then storm reads only the head commit from GitHub. If the workflow ran again on the same head commit, storm can use an older PR build of that head commit from the pool. If the pool has no usable PR build, storm reads the runs of the `Testserver` workflow and uses the newest PR build of the head commit. storm uses the first GitHub token that it finds: `GITHUB_TOKEN`, `GH_TOKEN`, or the output of `gh auth token`. The token must be able to read vercel/api and its Actions. The token stays on this machine.
24
-
25
- ## Choose a build
26
-
27
- - Use `stable` for the required checks and in `storm.config.ts`.
28
- - Use `latest_main` for vercel/api code that is merged but is not in `stable` yet.
29
- - Use `pr:<N>` when the change needs vercel/api code in an open pull request.
30
- - Do not write a PR build reference in `storm.config.ts`. Do not commit a PR build reference.
31
-
32
- ## Know when you need a PR build
33
-
34
- - Tests skip with a note that a service "is not on this Testserver build". For example: `api-domains-registrar is not on this Testserver build`. The build does not have the service.
35
- - Tests fail on vercel/api behavior that an open vercel/api pull request adds.
36
-
37
- In each case, find the vercel/api pull request before you change the tests.
38
-
39
- ## Run against a vercel/api pull request
40
-
41
- 1. Find the number of the pull request. In a stack, use the top pull request. For example, run `gh pr list --repo vercel/api --author @me --json number,headRefName,baseRefName`. Or run `gh pr view <branch> --repo vercel/api --json number,headRefOid`.
42
- 2. Run `gh pr checks <N> --repo vercel/api`. Make sure that `Bundle & Publish` passed on the newest push.
43
- 3. Run `storm vitest --testserver-build pr:<N> --json`. Or run `storm exec --testserver-build pr:<N> --json -- <command>`.
44
- 4. Read `resources.testserverPool.facts.build` in the result. Make sure that `pullRequest.headSha` is the head commit of the pull request. `resolved` is the PR build.
45
- 5. After a new push to the pull request, wait for `Bundle & Publish`. Then run the same command again. The run finds the new PR build. Do not change the command.
46
-
47
- To make one Testserver sandbox on the PR build, run `storm ext testserver pool create --build pr:<N> --ttl 10m --json`. Read `pullRequest.headSha` and `resolvedBuild`. To see the Testserver sandboxes in the pool, run `storm ext testserver pool list --json`. Their `requestedBuild` is `pr:<N>`. For the options of these two commands, run `storm ext testserver pool create --help` and `storm ext testserver pool list --help`.
48
-
49
- With `--testserver-create=false`, a run with `pr:<N>` uses only the Testserver sandboxes in the pool on that PR build. It does not make new ones.
50
-
51
- To make runs more reliable, for example before a demo, make the Testserver sandboxes first. Run `storm pool create --build pr:<N> --json` one time for each Testserver sandbox. Then a run with `pr:<N>` reads only the head commit from GitHub. Its line `Build: …` ends with `(from the pool)`. A Testserver sandbox lives for its TTL, 5 hours or less. After a new push to the pull request, the runs do not use these Testserver sandboxes.
52
-
53
- ## If a run stops
54
-
55
- A run that stops on a PR build ends with the error `resource_refused`. Read `data.refusal` in the error document: it is the reason. Read the facts of the refusal in `data.data`. The `pool create` command ends with the reason itself in `reason`, and its facts in `data`.
56
-
57
- - `pull_request_unreadable`: storm could not read the pull request from GitHub. In the facts, read `kind` and `tokenOrigin`.
58
- 1. Run `gh auth status`.
59
- 2. Run `gh auth login`, or set `GITHUB_TOKEN` to a token that can read vercel/api.
60
- 3. Run the command again.
61
- - `pr_build_not_ready`: the newest PR build is not from the head commit. In the facts, read `headSha` and `newest`.
62
- 1. Run `gh pr checks <N> --repo vercel/api`.
63
- 2. If `Bundle & Publish` runs, wait until it passes. Then run the command again.
64
- 3. If `Bundle & Publish` failed, read its log, and tell the user. Do not run the command again until a PR build passes.
65
- - `pr_build_expired`: the PR build is 7 days old or more. The Testserver control plane does not use it. Push to the pull request, or run its `Testserver` workflow again. Then run the command again.
66
- - `pr_builds_unlisted`: storm could not read the runs of the `Testserver` workflow from GitHub. In the facts, read `failure`.
67
- 1. Run `gh auth status`. Make sure that the token can read vercel/api.
68
- 2. Run the command again one time. If it fails again, tell the user.
69
-
70
- Do not give a build name to get past one of these errors, unless the user tells you to.
71
-
72
- ## Land the change
73
-
74
- 1. Merge the vercel/api pull request or stack.
75
- 2. Wait until `stable` contains the change.
76
- 1. Run `gh pr view <N> --repo vercel/api --json mergedAt`.
77
- 2. Run `storm ext testserver pool create --build stable --ttl 10m --json`, and read `resolvedBuild`.
78
- 3. The time at the start of `resolvedBuild` is in UTC. If it is after `mergedAt`, `stable` contains the change. If you are not sure, ask the user.
79
- 3. Run the required check of the client pull request again, on `stable`.
80
- 4. Merge the client pull request.
81
-
82
- Do not merge the client pull request while its tests pass only on `pr:<N>`.