@cnc-tools/storm 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.js +1 -1
- package/dist/combine-errors.js +2 -2
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/{run → exec}/cleanup.d.ts +1 -1
- package/dist/commands/{run → exec}/cleanup.js +1 -1
- package/dist/commands/{run/outcomes.d.ts → exec/command.d.ts} +103 -112
- package/dist/commands/exec/command.js +23 -0
- package/dist/commands/{run → exec}/job-summary.d.ts +5 -1
- package/dist/commands/{run → exec}/job-summary.js +5 -2
- package/dist/commands/{run → exec}/live-view.js +29 -13
- package/dist/commands/exec/metadata.d.ts +69 -0
- package/dist/commands/exec/metadata.js +55 -0
- package/dist/commands/{run → exec}/mint-failed.js +4 -4
- package/dist/commands/exec/outcomes.d.ts +664 -0
- package/dist/commands/exec/outcomes.js +347 -0
- package/dist/commands/{run → exec}/progress.d.ts +14 -2
- package/dist/commands/{run → exec}/progress.js +54 -9
- package/dist/commands/exec/run-command.d.ts +227 -0
- package/dist/commands/exec/run-command.js +696 -0
- package/dist/commands/exec/run-metadata.d.ts +59 -0
- package/dist/commands/exec/run-metadata.js +61 -0
- package/dist/commands/{run → exec}/run-record.d.ts +110 -5
- package/dist/commands/{run → exec}/run-record.js +57 -1
- package/dist/commands/exec/testserver-flags.d.ts +48 -0
- package/dist/commands/exec/testserver-flags.js +80 -0
- package/dist/commands/{run → exec}/view.js +36 -4
- package/dist/commands/runs/facts.d.ts +25 -0
- package/dist/commands/runs/facts.js +38 -5
- package/dist/commands/runs/list/command.d.ts +25 -0
- package/dist/commands/runs/list/outcomes.d.ts +25 -0
- package/dist/commands/runs/logs/metadata.js +1 -1
- package/dist/commands/runs/logs/outcomes.js +4 -1
- package/dist/commands/runs/past-run.d.ts +2 -2
- package/dist/commands/runs/past-run.js +2 -2
- package/dist/commands/runs/show/command.d.ts +25 -0
- package/dist/commands/runs/show/metadata.js +2 -2
- package/dist/commands/runs/show/outcomes.d.ts +25 -0
- package/dist/commands/runs/show/outcomes.js +37 -5
- package/dist/commands/vitest/command.d.ts +325 -0
- package/dist/commands/vitest/command.js +138 -0
- package/dist/commands/vitest/metadata.d.ts +69 -0
- package/dist/commands/vitest/metadata.js +35 -0
- package/dist/commands/vitest/outcomes.d.ts +298 -0
- package/dist/commands/vitest/outcomes.js +77 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -0
- package/dist/config/resolve.d.ts +3 -3
- package/dist/config/resolve.js +3 -3
- package/dist/config/resource-config.d.ts +2 -2
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/set.d.ts +15 -4
- package/dist/config/set.js +28 -12
- package/dist/config-file/define.d.ts +8 -6
- package/dist/context.d.ts +6 -3
- package/dist/context.js +4 -2
- package/dist/core/command-provider.d.ts +1 -1
- package/dist/core/events.d.ts +9 -7
- package/dist/core/presentation.js +1 -1
- package/dist/core/presentations.js +1 -1
- package/dist/core/run-state.d.ts +30 -6
- package/dist/core/run-state.js +19 -4
- package/dist/core/run.d.ts +17 -4
- package/dist/core/run.js +61 -25
- package/dist/resources/testserver/command.d.ts +1 -1
- package/dist/resources/testserver/command.js +1 -1
- package/dist/resources/testserver/config.d.ts +1 -1
- package/dist/resources/testserver/config.js +3 -2
- package/dist/resources/testserver/credential-facts.js +1 -1
- package/dist/resources/testserver/resource.d.ts +2 -2
- package/dist/resources/testserver/sandbox/create.d.ts +2 -2
- package/dist/resources/testserver/sandbox/create.js +2 -2
- package/dist/resources.d.ts +9 -6
- package/dist/resources.js +3 -3
- package/dist/runner/events.d.ts +64 -1
- package/dist/runner/gateways.d.ts +17 -6
- package/dist/runner/index.d.ts +5 -4
- package/dist/runner/index.js +4 -3
- package/dist/runner/live/snapshot-records.js +18 -4
- package/dist/runner/prepare.d.ts +23 -4
- package/dist/runner/prepare.js +13 -3
- package/dist/runner/ready.d.ts +7 -3
- package/dist/runner/ready.js +11 -5
- package/dist/runner/scope.d.ts +17 -1
- package/dist/runner/scope.js +4 -0
- package/dist/runner/snapshot-build.d.ts +3 -1
- package/dist/runner/snapshot-build.js +12 -2
- package/dist/runner/snapshot-cache.d.ts +46 -8
- package/dist/runner/snapshot-cache.js +60 -11
- package/dist/runner/snapshot-key.d.ts +12 -1
- package/dist/runner/snapshot-key.js +17 -1
- package/dist/runner/snapshot-save.d.ts +53 -0
- package/dist/runner/snapshot-save.js +148 -0
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/payload/payload.d.ts +2 -2
- package/dist/sdk/payload/payload.js +2 -2
- package/dist/story/align.d.ts +1 -1
- package/dist/story/align.js +1 -1
- package/dist/story/definition.d.ts +22 -15
- package/dist/story/definition.js +2 -2
- package/dist/story/errors.js +1 -1
- package/dist/story/gateways.d.ts +45 -25
- package/dist/story/gateways.js +2 -2
- package/dist/story/host.d.ts +11 -8
- package/dist/story/host.js +37 -37
- package/dist/story/index.d.ts +1 -1
- package/dist/story/index.js +4 -4
- package/dist/story/json.d.ts +1 -1
- package/dist/story/json.js +2 -2
- package/dist/story/live/recording-gateway.d.ts +2 -0
- package/dist/story/live/{artifact-gateway.js → recording-gateway.js} +33 -12
- package/dist/story/mode.d.ts +2 -2
- package/dist/story/mode.js +1 -1
- package/dist/story/orphans.d.ts +23 -5
- package/dist/story/orphans.js +44 -8
- package/dist/story/recording.d.ts +62 -0
- package/dist/story/{artifact.js → recording.js} +31 -27
- package/dist/story/report.d.ts +21 -9
- package/dist/story/report.js +37 -25
- package/dist/story/settle.d.ts +23 -21
- package/dist/story/settle.js +17 -16
- package/dist/story/{run.d.ts → start.d.ts} +18 -17
- package/dist/story/{run.js → start.js} +66 -43
- package/dist/vercel-cli/driver.d.ts +1 -1
- package/dist/vercel-cli/entry.d.ts +1 -1
- package/dist/vercel-cli/entry.js +1 -1
- package/dist/vercel-cli/verbose.d.ts +2 -2
- package/dist/vercel-cli/verbose.js +2 -2
- package/dist/vitest/config.d.ts +5 -5
- package/dist/vitest/config.js +5 -5
- package/dist/vitest/find-vitest.d.ts +7 -0
- package/dist/vitest/find-vitest.js +28 -0
- package/dist/vitest/fixtures.d.ts +2 -2
- package/dist/vitest/fixtures.js +3 -3
- package/dist/vitest/gateways.d.ts +37 -6
- package/dist/vitest/gateways.js +3 -2
- package/dist/vitest/live/list-gateway.d.ts +7 -3
- package/dist/vitest/live/list-gateway.js +55 -8
- package/dist/vitest/plan.d.ts +41 -8
- package/dist/vitest/plan.js +47 -16
- package/dist/vitest/sandbox.d.ts +1 -1
- package/dist/vitest/sandbox.js +1 -1
- package/dist/vitest/test-events.d.ts +2 -2
- package/dist/vitest/test-events.js +3 -3
- package/dist/vitest/test-results.d.ts +1 -1
- package/dist/vitest/test-results.js +1 -1
- package/dist/vitest/types.d.ts +1 -1
- package/package.json +2 -2
- package/skills/overview.md +5 -4
- package/skills/read-run-output.md +1 -1
- package/dist/commands/run/command.d.ts +0 -327
- package/dist/commands/run/command.js +0 -620
- package/dist/commands/run/metadata.d.ts +0 -47
- package/dist/commands/run/metadata.js +0 -83
- package/dist/commands/run/outcomes.js +0 -332
- package/dist/story/artifact.d.ts +0 -60
- package/dist/story/live/artifact-gateway.d.ts +0 -2
- /package/dist/commands/{run → exec}/live-view.d.ts +0 -0
- /package/dist/commands/{run → exec}/mint-failed.d.ts +0 -0
- /package/dist/commands/{run → exec}/redaction.d.ts +0 -0
- /package/dist/commands/{run → exec}/redaction.js +0 -0
- /package/dist/commands/{run → exec}/run-collector.d.ts +0 -0
- /package/dist/commands/{run → exec}/run-collector.js +0 -0
- /package/dist/commands/{run → exec}/tests-summary.d.ts +0 -0
- /package/dist/commands/{run → exec}/tests-summary.js +0 -0
- /package/dist/commands/{run → exec}/text.d.ts +0 -0
- /package/dist/commands/{run → exec}/text.js +0 -0
- /package/dist/commands/{run → exec}/view.d.ts +0 -0
- /package/dist/commands/{run → exec}/waterfall.d.ts +0 -0
- /package/dist/commands/{run → exec}/waterfall.js +0 -0
- /package/dist/commands/{run → exec}/worker-chart.d.ts +0 -0
- /package/dist/commands/{run → exec}/worker-chart.js +0 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { defineErrors, defineOutcomes, renderOutcome } from "@vercel/clinkr";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { RUNNER_STEPS } from "../../core/index.js";
|
|
4
|
+
import { RESOURCE_ERRORS, RESOURCE_PRESENTATIONS, RESOURCE_REPORTS, RUN_CLEANUP } from "../../resources.js";
|
|
5
|
+
import { configErrors } from "../../config/index.js";
|
|
6
|
+
import { credentialErrors } from "../../credential/index.js";
|
|
7
|
+
import { keptText, runnerCleanupWarnings } from "./cleanup.js";
|
|
8
|
+
import { mintFailedErrors } from "./mint-failed.js";
|
|
9
|
+
import { saveSchema } from "./run-record.js";
|
|
10
|
+
/** Why the runner couldn't run the command. */
|
|
11
|
+
const runnerFailureSchema = z.union([
|
|
12
|
+
z.object({
|
|
13
|
+
kind: z.enum(["snapshot-build-step-failed", "apply-failed", "install-failed", "build-failed"]),
|
|
14
|
+
/** The step's label. */
|
|
15
|
+
label: z.string(),
|
|
16
|
+
/** Its exit code; null when it ended without one. */
|
|
17
|
+
exitCode: z.number().nullable(),
|
|
18
|
+
/** Its last 40 output lines. */
|
|
19
|
+
tail: z.array(z.string()),
|
|
20
|
+
}),
|
|
21
|
+
z.object({
|
|
22
|
+
kind: z.literal("sandbox-api-failed"),
|
|
23
|
+
/** The Sandbox call that failed. */
|
|
24
|
+
operation: z.string(),
|
|
25
|
+
/** The HTTP status the Sandbox API answered; null when it answered none. */
|
|
26
|
+
status: z.number().nullable(),
|
|
27
|
+
message: z.string(),
|
|
28
|
+
}),
|
|
29
|
+
z.object({
|
|
30
|
+
kind: z.literal("checkout-failed"),
|
|
31
|
+
/** What git or tar said. */
|
|
32
|
+
message: z.string(),
|
|
33
|
+
/** The failed command; null when there was none. */
|
|
34
|
+
command: z.string().nullable(),
|
|
35
|
+
}),
|
|
36
|
+
z.object({ kind: z.literal("credential-claims-missing"), team: z.string(), project: z.string() }),
|
|
37
|
+
]);
|
|
38
|
+
/** How a step ended, as a message says it. */
|
|
39
|
+
function stepEnded(exitCode) {
|
|
40
|
+
return exitCode === null ? "ended without an exit code" : `exited ${exitCode}`;
|
|
41
|
+
}
|
|
42
|
+
/** The headline and the next step for a runner failure. */
|
|
43
|
+
function runnerFailureText(failure) {
|
|
44
|
+
switch (failure.kind) {
|
|
45
|
+
case "snapshot-build-step-failed":
|
|
46
|
+
return {
|
|
47
|
+
message: `The runner snapshot build's step "${failure.label}" ${stepEnded(failure.exitCode)}. The command didn't run.`,
|
|
48
|
+
next: "Fix the step in the runner recipe, then retry. A failed build records no runner snapshot.",
|
|
49
|
+
};
|
|
50
|
+
case "apply-failed":
|
|
51
|
+
return {
|
|
52
|
+
message: `Couldn't apply your changes in the runner sandbox: "${failure.label}" ${stepEnded(failure.exitCode)}. The command didn't run.`,
|
|
53
|
+
next: "Check the output for the file that didn't apply, then retry.",
|
|
54
|
+
};
|
|
55
|
+
case "install-failed":
|
|
56
|
+
return {
|
|
57
|
+
message: `The runner's install, "${failure.label}", ${stepEnded(failure.exitCode)}. The command didn't run.`,
|
|
58
|
+
next: "Fix run.install in the runner recipe, or what it installs, then retry.",
|
|
59
|
+
};
|
|
60
|
+
case "build-failed":
|
|
61
|
+
return {
|
|
62
|
+
message: `The runner's build, "${failure.label}", ${stepEnded(failure.exitCode)}. The command didn't run.`,
|
|
63
|
+
next: "Fix the build, or run.build in the runner recipe, then retry.",
|
|
64
|
+
};
|
|
65
|
+
case "sandbox-api-failed":
|
|
66
|
+
return {
|
|
67
|
+
message: `A Vercel Sandbox call failed (${failure.operation}${failure.status === null ? "" : `, HTTP ${failure.status}`}): ${failure.message}. ${failure.operation === "run-command" ? "The command's outcome is unknown." : "The command didn't run."}`,
|
|
68
|
+
next: "Retry; if it keeps failing, check the Vercel Sandbox status and the project's Sandbox access.",
|
|
69
|
+
};
|
|
70
|
+
case "checkout-failed":
|
|
71
|
+
return {
|
|
72
|
+
message: `git or tar failed on this machine: ${failure.message}. The command didn't run.`,
|
|
73
|
+
next: "Fix the checkout, then retry.",
|
|
74
|
+
};
|
|
75
|
+
case "credential-claims-missing":
|
|
76
|
+
return {
|
|
77
|
+
message: `The credential minted for project ${failure.project} on team ${failure.team} names no team and project ids (its owner_id and project_id claims), so the runner sandbox can't use it. The command didn't run.`,
|
|
78
|
+
next: "Mint for a Vercel project whose development OIDC tokens carry owner_id and project_id, then retry.",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** The timeline's rows, in order: the mint, each resource lane in provider order, the runner, the tests, the cleanup. */
|
|
83
|
+
const ROW_NAMES = [
|
|
84
|
+
"mint",
|
|
85
|
+
...RESOURCE_PRESENTATIONS.lanes.map(({ lane }) => lane),
|
|
86
|
+
"runner",
|
|
87
|
+
"tests",
|
|
88
|
+
"cleanup",
|
|
89
|
+
];
|
|
90
|
+
/** The timeline's steps: each resource lane's, in provider order, then the runner's. */
|
|
91
|
+
const STEP_NAMES = [...RESOURCE_PRESENTATIONS.lanes.flatMap(({ steps }) => steps), ...RUNNER_STEPS];
|
|
92
|
+
/** How a lane or step ended in the timeline: still going when the run ended is `unfinished`. */
|
|
93
|
+
const timelineOutcomeSchema = z.enum(["done", "failed", "stopped", "unfinished"]);
|
|
94
|
+
/** A run's waterfall (`Timeline`), times in milliseconds since the run started, as `timeline.json` holds it too. */
|
|
95
|
+
export const timelineSchema = z.object({
|
|
96
|
+
/** When the run started, as an ISO time. */
|
|
97
|
+
startedAt: z.string(),
|
|
98
|
+
/** From the run's start to its last event. */
|
|
99
|
+
totalMs: z.number(),
|
|
100
|
+
/** The lanes in order: mint, each resource's lane, runner, tests, cleanup; each only when the run got that far. */
|
|
101
|
+
rows: z.array(z.object({
|
|
102
|
+
name: z.enum(ROW_NAMES),
|
|
103
|
+
startMs: z.number(),
|
|
104
|
+
endMs: z.number(),
|
|
105
|
+
outcome: timelineOutcomeSchema,
|
|
106
|
+
/** The lane's steps: a resource lane's, such as the Testserver side's lease and create, and the runner's snapshot, start, upload, apply, install and build. */
|
|
107
|
+
steps: z.array(z.object({
|
|
108
|
+
name: z.enum(STEP_NAMES),
|
|
109
|
+
startMs: z.number(),
|
|
110
|
+
endMs: z.number(),
|
|
111
|
+
outcome: timelineOutcomeSchema,
|
|
112
|
+
})),
|
|
113
|
+
/** How long the lane, once ready, waited for the other before the command started. */
|
|
114
|
+
idleMs: z.number(),
|
|
115
|
+
/** The runner lane's: whether it reused or built its runner snapshot. */
|
|
116
|
+
snapshot: z.enum(["reused", "built"]).optional(),
|
|
117
|
+
/** A resource lane's that counts them, such as the Testserver lane's: how many it reused and created. */
|
|
118
|
+
sandboxes: z.object({ reused: z.number(), created: z.number() }).optional(),
|
|
119
|
+
})),
|
|
120
|
+
/** The lanes the command waited on, then the command; empty when the command didn't start. */
|
|
121
|
+
criticalPath: z.array(z.enum(ROW_NAMES)),
|
|
122
|
+
});
|
|
123
|
+
/** What a `ran` outcome says of a run whose command ran and ended. No field carries the credential. */
|
|
124
|
+
export const ranSchema = z.object({
|
|
125
|
+
/** storm's version. */
|
|
126
|
+
version: z.string(),
|
|
127
|
+
/** The git commit storm was built from, as its version line shows it (`3f2a9c1b7d4e`, `-dirty` appended when built from a tree with uncommitted changes); null when unknown. */
|
|
128
|
+
commit: z.string().nullable(),
|
|
129
|
+
/** The config file the run's settings came from (its absolute path); null when none applied. */
|
|
130
|
+
configFile: z.string().nullable(),
|
|
131
|
+
/** What each acquired resource that reports something says of itself, keyed by resource name, such as the Testserver pool's sandboxes and build. */
|
|
132
|
+
resources: RESOURCE_REPORTS.ranSchema,
|
|
133
|
+
/** What the run's cleanup left: in a runner run, the runner sandbox it kept running and the runner's sandboxes it couldn't stop or delete (`runner`, null otherwise), and what releasing each resource it held couldn't do, keyed by resource name (`resources`, `{}` when it held none). */
|
|
134
|
+
cleanup: RUN_CLEANUP.schema,
|
|
135
|
+
/** How the command ended: its exit code, or the signal that ended it; both null for a remote command that ended without an exit code. */
|
|
136
|
+
command: z.object({ exitCode: z.number().nullable(), signal: z.string().nullable() }),
|
|
137
|
+
/** In a runner run, the runner sandbox the command ran in; null otherwise. */
|
|
138
|
+
runner: z
|
|
139
|
+
.object({
|
|
140
|
+
/** The runner snapshot it started from. */
|
|
141
|
+
snapshotId: z.string(),
|
|
142
|
+
/** The runner snapshot's base, a full SHA. */
|
|
143
|
+
base: z.string(),
|
|
144
|
+
/** For a branch snapshot, the local branch of the run that saved it; null for a base snapshot. */
|
|
145
|
+
snapshotBranch: z.string().nullable(),
|
|
146
|
+
/** For a branch snapshot, the HEAD commit of the run that saved it, a full SHA; null for a base snapshot. */
|
|
147
|
+
snapshotHead: z.string().nullable(),
|
|
148
|
+
/** Whether this run built the runner snapshot. */
|
|
149
|
+
built: z.boolean(),
|
|
150
|
+
vcpus: z.number(),
|
|
151
|
+
region: z.string(),
|
|
152
|
+
runtime: z.string(),
|
|
153
|
+
/** How long the build step took, in milliseconds. */
|
|
154
|
+
buildMs: z.number(),
|
|
155
|
+
/** How saving the runner sandbox as a branch snapshot ended (--save-snapshot); null without the flag. */
|
|
156
|
+
save: saveSchema.nullable(),
|
|
157
|
+
})
|
|
158
|
+
.nullable(),
|
|
159
|
+
/** The run's waterfall, as the run directory's timeline.json holds it: each lane's span and steps in milliseconds since the run started, how they ended, idle time, and the critical path. */
|
|
160
|
+
timeline: timelineSchema,
|
|
161
|
+
/** The run's run directory's run id, which `storm runs show` takes; null when the run couldn't make one. */
|
|
162
|
+
runId: z.string().nullable(),
|
|
163
|
+
});
|
|
164
|
+
/** What a `ran` outcome is, for its description. */
|
|
165
|
+
export const RAN_DESCRIPTION = "The command ran and ended. storm exits with its code, or 128 + n when signal n ended it, whatever this result's exit code.";
|
|
166
|
+
/** How a `ran` outcome renders: its warnings, and the runner sandbox the run kept running, if any. */
|
|
167
|
+
export function renderRan(ran) {
|
|
168
|
+
const warnings = [
|
|
169
|
+
...RESOURCE_REPORTS.ranWarnings(ran.resources),
|
|
170
|
+
...(ran.runner !== null && ran.command.exitCode === null && ran.command.signal === null
|
|
171
|
+
? [
|
|
172
|
+
{
|
|
173
|
+
reason: "remote_no_exit_code",
|
|
174
|
+
message: "The command ended in the runner sandbox without an exit code, so storm exits 1.",
|
|
175
|
+
},
|
|
176
|
+
]
|
|
177
|
+
: []),
|
|
178
|
+
...runnerCleanupWarnings(ran.cleanup.runner),
|
|
179
|
+
...RESOURCE_REPORTS.cleanupWarnings(ran.cleanup.resources),
|
|
180
|
+
];
|
|
181
|
+
// The waterfall, which the run prints on stderr before this, is the human summary; the kept runner sandbox
|
|
182
|
+
// follows it, so a person sees where to connect last.
|
|
183
|
+
const kept = ran.cleanup.runner?.kept ?? null;
|
|
184
|
+
return renderOutcome({
|
|
185
|
+
...(kept === null ? {} : { message: keptText(kept) }),
|
|
186
|
+
...(warnings.length === 0 ? {} : { warnings }),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/** The errors only a run ends with, beside the config's, the credential's, the resources' and the mint's. */
|
|
190
|
+
export const runErrors = defineErrors({
|
|
191
|
+
credentialUnused: {
|
|
192
|
+
exitCode: 2,
|
|
193
|
+
description: "--credential was given to a run that holds no resource that takes a credential.",
|
|
194
|
+
schema: z.object({
|
|
195
|
+
/** The flags given that no held resource takes, as typed, such as --credential. */
|
|
196
|
+
flags: z.array(z.string()),
|
|
197
|
+
/** The config file that applied; null when none did. */
|
|
198
|
+
configFile: z.string().nullable(),
|
|
199
|
+
}),
|
|
200
|
+
render: ({ flags }) => ({
|
|
201
|
+
message: `${flags.join(", ")} ${flags.length === 1 ? "applies" : "apply"} only to a run holding a resource that takes a credential, and this run holds none.`,
|
|
202
|
+
next: [
|
|
203
|
+
{
|
|
204
|
+
type: "text",
|
|
205
|
+
text: `Drop ${flags.join(" and ")}, or give the run a resource that takes a credential, in storm.config.ts or on the command line.`,
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
}),
|
|
209
|
+
},
|
|
210
|
+
missingRunner: {
|
|
211
|
+
exitCode: 2,
|
|
212
|
+
description: "A runner run (no --local) needs a runner recipe, and no storm.config.ts gives a runner key.",
|
|
213
|
+
schema: z.object({
|
|
214
|
+
/** The config file that applied; null when none did. */
|
|
215
|
+
configFile: z.string().nullable(),
|
|
216
|
+
}),
|
|
217
|
+
render: ({ configFile }) => ({
|
|
218
|
+
message: configFile === null
|
|
219
|
+
? "A runner run needs a runner recipe, and no storm.config.ts applies."
|
|
220
|
+
: `A runner run needs a runner recipe, and ${configFile} has no runner key.`,
|
|
221
|
+
next: [
|
|
222
|
+
{
|
|
223
|
+
type: "text",
|
|
224
|
+
text: "Add a runner recipe under the runner key of storm.config.ts, or run on this machine with --local.",
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
}),
|
|
228
|
+
},
|
|
229
|
+
noBaseRef: {
|
|
230
|
+
exitCode: 1,
|
|
231
|
+
description: "In a runner run, none of the runner recipe's baseRefs exists locally and shares history with HEAD, so there is no base. storm never fetches.",
|
|
232
|
+
schema: z.object({
|
|
233
|
+
/** Each ref in baseRefs, and why it gave no base. */
|
|
234
|
+
refs: z.array(z.object({ ref: z.string(), reason: z.enum(["missing", "unrelated"]) })),
|
|
235
|
+
}),
|
|
236
|
+
render: ({ refs }) => ({
|
|
237
|
+
message: `No base for the runner: none of ${refs.map(({ ref }) => ref).join(", ")} exists locally and shares history with HEAD. The command didn't run.`,
|
|
238
|
+
rows: [
|
|
239
|
+
[
|
|
240
|
+
"Base refs",
|
|
241
|
+
refs.map(({ ref, reason }) => reason === "missing" ? `${ref}: no such local ref` : `${ref}: shares no history with HEAD`),
|
|
242
|
+
],
|
|
243
|
+
],
|
|
244
|
+
next: [
|
|
245
|
+
{
|
|
246
|
+
type: "text",
|
|
247
|
+
text: refs.some(({ ref }) => ref === "main" || ref === "origin/main")
|
|
248
|
+
? "Run git fetch origin main, then retry."
|
|
249
|
+
: `Fetch or create one of ${refs.map(({ ref }) => ref).join(", ")}, then retry.`,
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
}),
|
|
253
|
+
},
|
|
254
|
+
submodulesRefused: {
|
|
255
|
+
exitCode: 1,
|
|
256
|
+
description: "In a runner run, the checkout has Git submodules, which neither the upload nor the base's files carry.",
|
|
257
|
+
schema: z.object({ paths: z.array(z.string()) }),
|
|
258
|
+
render: ({ paths }) => ({
|
|
259
|
+
message: `The checkout has Git submodules, which the runner can't carry: ${paths.join(", ")}. The command didn't run.`,
|
|
260
|
+
next: [{ type: "text", text: "Run on this machine with --local." }],
|
|
261
|
+
}),
|
|
262
|
+
},
|
|
263
|
+
snapshotGone: {
|
|
264
|
+
exitCode: 1,
|
|
265
|
+
description: "In a runner run, the cached runner snapshot the run picked was gone (the Sandbox API answered 410), so its cache entry was removed and the command didn't run. The next run picks another runner snapshot or builds one.",
|
|
266
|
+
schema: z.object({
|
|
267
|
+
snapshotId: z.string(),
|
|
268
|
+
/** The runner snapshot's base, a full SHA. */
|
|
269
|
+
base: z.string(),
|
|
270
|
+
/** Why its cache entry couldn't be removed; null when it was. */
|
|
271
|
+
removal: z.object({ path: z.string(), message: z.string() }).nullable(),
|
|
272
|
+
/** What the run couldn't clean up. */
|
|
273
|
+
cleanup: RUN_CLEANUP.schema,
|
|
274
|
+
}),
|
|
275
|
+
render: ({ snapshotId, removal, cleanup }) => {
|
|
276
|
+
const rows = RUN_CLEANUP.rows(cleanup);
|
|
277
|
+
return {
|
|
278
|
+
message: `Runner snapshot ${snapshotId} is gone, before its cache entry said it expires. ${removal === null ? "Removed its cache entry." : `Couldn't remove its cache entry at ${removal.path}: ${removal.message}.`} The command didn't run.`,
|
|
279
|
+
...(rows.length === 0 ? {} : { rows }),
|
|
280
|
+
next: [
|
|
281
|
+
{
|
|
282
|
+
type: "text",
|
|
283
|
+
text: removal === null
|
|
284
|
+
? "Run again: the next run picks another runner snapshot or builds one."
|
|
285
|
+
: `Remove ${removal.path}, then run again.`,
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
};
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
runnerFailed: {
|
|
292
|
+
exitCode: 1,
|
|
293
|
+
description: "In a runner run, the runner couldn't run the command: a snapshot build step, applying the changes, the install or the build failed (with the step's last 40 output lines), a Vercel Sandbox call failed, git or tar failed on this machine, or the credential names no team and project ids.",
|
|
294
|
+
schema: z.object({
|
|
295
|
+
failure: runnerFailureSchema,
|
|
296
|
+
/** What the run couldn't clean up; its `runner` is null when the run failed before it started a sandbox. */
|
|
297
|
+
cleanup: RUN_CLEANUP.schema,
|
|
298
|
+
}),
|
|
299
|
+
render: ({ failure, cleanup }) => {
|
|
300
|
+
const { message, next } = runnerFailureText(failure);
|
|
301
|
+
const rows = [
|
|
302
|
+
...("tail" in failure && failure.tail.length > 0 ? [["Last output", failure.tail]] : []),
|
|
303
|
+
...(failure.kind === "checkout-failed" && failure.command !== null
|
|
304
|
+
? [["Command", failure.command]]
|
|
305
|
+
: []),
|
|
306
|
+
...RUN_CLEANUP.rows(cleanup),
|
|
307
|
+
];
|
|
308
|
+
return { message, ...(rows.length === 0 ? {} : { rows }), next: [{ type: "text", text: next }] };
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
spawnFailed: {
|
|
312
|
+
exitCode: 1,
|
|
313
|
+
description: "The command couldn't start.",
|
|
314
|
+
schema: z.object({
|
|
315
|
+
/** The command's first argument: what storm tried to run. */
|
|
316
|
+
executable: z.string(),
|
|
317
|
+
/** What the OS said. */
|
|
318
|
+
message: z.string(),
|
|
319
|
+
/** What the run couldn't clean up; its `runner` is null, since only a local run spawns its command here. */
|
|
320
|
+
cleanup: RUN_CLEANUP.schema,
|
|
321
|
+
}),
|
|
322
|
+
render: ({ executable, message, cleanup }) => {
|
|
323
|
+
const rows = RUN_CLEANUP.rows(cleanup);
|
|
324
|
+
return {
|
|
325
|
+
message: `Couldn't start the command ${executable}: ${message}`,
|
|
326
|
+
...(rows.length === 0 ? {} : { rows }),
|
|
327
|
+
next: [
|
|
328
|
+
{ type: "text", text: "Check the command after --; it runs with no shell, as the argument list given." },
|
|
329
|
+
],
|
|
330
|
+
};
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
/** Every error a run ends with, in order: the config's, the credential's, each resource's, the mint's, the run's. */
|
|
335
|
+
export const RUN_ERRORS = {
|
|
336
|
+
...configErrors,
|
|
337
|
+
...credentialErrors,
|
|
338
|
+
// Every resource's errors, in provider order.
|
|
339
|
+
...RESOURCE_ERRORS,
|
|
340
|
+
...mintFailedErrors,
|
|
341
|
+
...runErrors,
|
|
342
|
+
};
|
|
343
|
+
/** How `exec` ends. No outcome carries the credential. */
|
|
344
|
+
export const outcomes = defineOutcomes({
|
|
345
|
+
results: { ran: { schema: ranSchema, description: RAN_DESCRIPTION, render: renderRan } },
|
|
346
|
+
errors: RUN_ERRORS,
|
|
347
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RanCommand } from "../../core/index.ts";
|
|
2
2
|
import { type StormRunLane, type StormRunObserver, type StormTimedRunEvent } from "../../resources.ts";
|
|
3
|
-
import type { RunnerSnapshotCacheFailure, SnapshotCacheNote } from "../../runner/index.ts";
|
|
3
|
+
import type { RunnerEvent, RunnerSnapshotCacheFailure, SnapshotCacheNote } from "../../runner/index.ts";
|
|
4
4
|
/** The lane a plain progress line names after its elapsed time: what part of the run it is about. */
|
|
5
5
|
export type ProgressLane = "run" | "mint" | StormRunLane | "command" | "cleanup";
|
|
6
6
|
/**
|
|
@@ -33,12 +33,24 @@ export declare function plainRenderer(options: LineProgressOptions): (timed: Sto
|
|
|
33
33
|
export declare function progressLine(elapsedMs: number, lane: ProgressLane, text: string): string;
|
|
34
34
|
/** The widest lane a plain line names: `command`, `cleanup`, or a resource's lane, such as `testserver`. */
|
|
35
35
|
export declare const LANE_WIDTH: number;
|
|
36
|
+
/** How saving a branch snapshot ended, as its line says. */
|
|
37
|
+
export declare function branchSnapshotSaveText(event: Extract<RunnerEvent, {
|
|
38
|
+
readonly kind: "branch-snapshot-saved" | "branch-snapshot-not-saved";
|
|
39
|
+
}>): string;
|
|
40
|
+
/** What `--rebuild-snapshot` did to the branch's branch snapshot entries, as its line says. */
|
|
41
|
+
export declare function branchSnapshotsDropText(event: Extract<RunnerEvent, {
|
|
42
|
+
readonly kind: "branch-snapshots-dropped" | "branch-snapshots-not-dropped";
|
|
43
|
+
}>): string;
|
|
36
44
|
/** How a command ended, as its end line and the live view say. */
|
|
37
45
|
export declare function commandEnd(outcome: RanCommand): string;
|
|
38
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* In a runner run, what the local checks noticed: nested Git repositories left out, the cache read's notes, and that
|
|
48
|
+
* `--save-snapshot` saves nothing on a detached HEAD.
|
|
49
|
+
*/
|
|
39
50
|
export declare function preparedNoteTexts(prepared: {
|
|
40
51
|
readonly nestedRepositories: readonly string[];
|
|
41
52
|
readonly notes: readonly SnapshotCacheNote[];
|
|
53
|
+
readonly saveSkipped: boolean;
|
|
42
54
|
}): string[];
|
|
43
55
|
/** The runner snapshot cache couldn't record a runner snapshot the run built. */
|
|
44
56
|
export declare function cacheWriteFailureText(failure: RunnerSnapshotCacheFailure): string;
|
|
@@ -119,7 +119,7 @@ function eventLines(event, now, state, line, options) {
|
|
|
119
119
|
case "cleanup-started":
|
|
120
120
|
state.cleanupStartedAt = now;
|
|
121
121
|
return [
|
|
122
|
-
line("cleanup", cleanupText(event.
|
|
122
|
+
line("cleanup", cleanupText(event.runnerSandbox, RESOURCE_PRESENTATIONS.releaseTexts(event.holdings, "doing"))),
|
|
123
123
|
];
|
|
124
124
|
case "cleanup-finished": {
|
|
125
125
|
const problems = [
|
|
@@ -150,7 +150,7 @@ function eventLines(event, now, state, line, options) {
|
|
|
150
150
|
function runnerLines(event, state, line, options) {
|
|
151
151
|
switch (event.kind) {
|
|
152
152
|
case "snapshot-reused":
|
|
153
|
-
return [line("runner",
|
|
153
|
+
return [line("runner", snapshotReusedText(event))];
|
|
154
154
|
case "snapshot-build-started":
|
|
155
155
|
return [
|
|
156
156
|
line("runner", `building a runner snapshot of base ${short(event.base)} (${event.reason === "rebuild" ? "--rebuild-snapshot" : "no cached runner snapshot fits"}); this takes a few minutes: ${event.summary}`),
|
|
@@ -204,8 +204,46 @@ function runnerLines(event, state, line, options) {
|
|
|
204
204
|
];
|
|
205
205
|
case "sandbox-kept":
|
|
206
206
|
return [line("cleanup", `kept the runner sandbox ${event.name} running until ${isoSecondsText(event.stopsAt)}`)];
|
|
207
|
+
// The cleanup line says the run saves a branch snapshot.
|
|
208
|
+
case "branch-snapshot-saving":
|
|
209
|
+
return [];
|
|
210
|
+
case "branch-snapshot-saved":
|
|
211
|
+
case "branch-snapshot-not-saved":
|
|
212
|
+
return [line("cleanup", branchSnapshotSaveText(event))];
|
|
213
|
+
case "branch-snapshots-dropped":
|
|
214
|
+
case "branch-snapshots-not-dropped":
|
|
215
|
+
return [line("runner", branchSnapshotsDropText(event))];
|
|
207
216
|
}
|
|
208
217
|
}
|
|
218
|
+
/** The line that says which runner snapshot the run starts from, and for a branch snapshot, which run saved it. */
|
|
219
|
+
function snapshotReusedText(event) {
|
|
220
|
+
const reused = `reusing runner snapshot ${event.snapshotId} of base ${short(event.base)}`;
|
|
221
|
+
return event.branch === null || event.head === null
|
|
222
|
+
? reused
|
|
223
|
+
: `${reused} (branch ${event.branch} at ${short(event.head)})`;
|
|
224
|
+
}
|
|
225
|
+
/** How saving a branch snapshot ended, as its line says. */
|
|
226
|
+
export function branchSnapshotSaveText(event) {
|
|
227
|
+
if (event.kind === "branch-snapshot-saved") {
|
|
228
|
+
return `saved branch snapshot ${event.snapshotId} for ${event.branch} at ${short(event.head)} in ${seconds(event.ms)} (${megabytesText(event.sizeBytes)})`;
|
|
229
|
+
}
|
|
230
|
+
return `not saving a branch snapshot: ${notSavedReason(event.save)}`;
|
|
231
|
+
}
|
|
232
|
+
function notSavedReason(save) {
|
|
233
|
+
switch (save.kind) {
|
|
234
|
+
case "failed":
|
|
235
|
+
return `the ${save.step === "scrub" ? "scrub" : "save"} failed: ${save.message}`;
|
|
236
|
+
case "stopped":
|
|
237
|
+
return "the run is stopping";
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/** What `--rebuild-snapshot` did to the branch's branch snapshot entries, as its line says. */
|
|
241
|
+
export function branchSnapshotsDropText(event) {
|
|
242
|
+
if (event.kind === "branch-snapshots-not-dropped")
|
|
243
|
+
return `couldn't drop a branch snapshot of ${event.branch} from the cache at ${event.failure.path}: ${event.failure.message}; a later run on the branch may start from it`;
|
|
244
|
+
const count = event.snapshotIds.length;
|
|
245
|
+
return `dropped ${count} branch ${count === 1 ? "snapshot" : "snapshots"} of ${event.branch} from the cache: ${event.snapshotIds.join(", ")}`;
|
|
246
|
+
}
|
|
209
247
|
/** What a stopping run says it releases of the resources it holds, such as ` and releasing the leases`. */
|
|
210
248
|
function releasingText(held) {
|
|
211
249
|
return RESOURCE_PRESENTATIONS.stoppingTexts(held)
|
|
@@ -220,15 +258,18 @@ function closeFold(state) {
|
|
|
220
258
|
return ["::endgroup::"];
|
|
221
259
|
}
|
|
222
260
|
/**
|
|
223
|
-
* What cleaning up does, as its first line says: in a runner run
|
|
224
|
-
*
|
|
261
|
+
* What cleaning up does, as its first line says: in a runner run (`sandbox`, null in a local run), saving the runner
|
|
262
|
+
* sandbox as a branch snapshot while the resources are released, or keeping it running when its keep time is above 0,
|
|
263
|
+
* else stopping and deleting the runner's sandboxes; then what releasing each resource does (`releases`).
|
|
225
264
|
*/
|
|
226
|
-
function cleanupText(
|
|
265
|
+
function cleanupText(sandbox, releases) {
|
|
227
266
|
const release = releases.length === 0 ? undefined : releases.join(", ");
|
|
228
|
-
if (
|
|
267
|
+
if (sandbox === null)
|
|
229
268
|
return release === undefined ? "nothing to release" : `${release}…`;
|
|
230
|
-
|
|
231
|
-
|
|
269
|
+
if (sandbox.kind === "save")
|
|
270
|
+
return `saving a branch snapshot of ${sandbox.branch}${release === undefined ? "" : ` while ${release}`}…`;
|
|
271
|
+
const sandboxes = sandbox.ms > 0
|
|
272
|
+
? `keeping the runner sandbox running ${keepTimeText(sandbox.ms)}`
|
|
232
273
|
: "stopping and deleting the runner's sandboxes";
|
|
233
274
|
return `${sandboxes}${release === undefined ? "" : `, then ${release}`}…`;
|
|
234
275
|
}
|
|
@@ -262,13 +303,17 @@ function targetText(target) {
|
|
|
262
303
|
// The notices: what a run reports that the live view's phases can't hold, so it prints them above the live region
|
|
263
304
|
// as plain lines, and plain progress prints among its other lines. Each builder answers the lines' text, which the
|
|
264
305
|
// caller prefixes with the time and the lane (`progressLine`). A resource's own notices are its presentation's.
|
|
265
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* In a runner run, what the local checks noticed: nested Git repositories left out, the cache read's notes, and that
|
|
308
|
+
* `--save-snapshot` saves nothing on a detached HEAD.
|
|
309
|
+
*/
|
|
266
310
|
export function preparedNoteTexts(prepared) {
|
|
267
311
|
return [
|
|
268
312
|
...(prepared.nestedRepositories.length === 0
|
|
269
313
|
? []
|
|
270
314
|
: [`leaving out untracked nested Git repositories: ${prepared.nestedRepositories.join(", ")}`]),
|
|
271
315
|
...prepared.notes.map(noteText),
|
|
316
|
+
...(prepared.saveSkipped ? ["not saving a branch snapshot: HEAD is detached"] : []),
|
|
272
317
|
];
|
|
273
318
|
}
|
|
274
319
|
/** The runner snapshot cache couldn't record a runner snapshot the run built. */
|