@cnc-tools/storm 0.6.0 → 0.8.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/commands/exec/cleanup.d.ts +3 -3
- package/dist/commands/exec/cleanup.js +1 -1
- package/dist/commands/exec/command.d.ts +797 -1
- package/dist/commands/exec/command.js +1 -1
- package/dist/commands/exec/live-view.js +32 -15
- package/dist/commands/exec/metadata.d.ts +5 -2
- package/dist/commands/exec/metadata.js +4 -0
- package/dist/commands/exec/mint-failed.d.ts +28 -0
- package/dist/commands/exec/outcomes.d.ts +526 -0
- package/dist/commands/exec/outcomes.js +9 -0
- package/dist/commands/exec/progress.d.ts +14 -2
- package/dist/commands/exec/progress.js +57 -14
- package/dist/commands/exec/run-command.d.ts +10 -4
- package/dist/commands/exec/run-command.js +41 -8
- package/dist/commands/exec/run-metadata.d.ts +6 -3
- package/dist/commands/exec/run-metadata.js +6 -3
- package/dist/commands/exec/run-record.d.ts +83 -4
- package/dist/commands/exec/run-record.js +49 -1
- package/dist/commands/exec/tests-summary.d.ts +1 -1
- package/dist/commands/exec/tests-summary.js +1 -1
- package/dist/commands/exec/view.js +36 -4
- package/dist/commands/runs/facts.d.ts +25 -0
- package/dist/commands/runs/facts.js +36 -3
- package/dist/commands/runs/list/command.d.ts +154 -1
- package/dist/commands/runs/list/command.js +1 -1
- package/dist/commands/runs/list/outcomes.d.ts +41 -0
- package/dist/commands/runs/logs/command.d.ts +263 -1
- package/dist/commands/runs/logs/command.js +1 -1
- package/dist/commands/runs/logs/outcomes.d.ts +105 -0
- package/dist/commands/runs/show/command.d.ts +354 -1
- package/dist/commands/runs/show/command.js +1 -1
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +96 -0
- package/dist/commands/runs/show/outcomes.js +30 -1
- package/dist/commands/vitest/command.d.ts +912 -1
- package/dist/commands/vitest/command.js +1 -1
- package/dist/commands/vitest/metadata.d.ts +5 -2
- package/dist/commands/vitest/metadata.js +4 -0
- package/dist/commands/vitest/outcomes.d.ts +320 -0
- package/dist/config/errors.d.ts +73 -0
- package/dist/config/schema.d.ts +1 -1
- package/dist/config-file/define.d.ts +4 -3
- package/dist/config-file/define.js +1 -1
- package/dist/config-file/toolchain.js +1 -1
- package/dist/core/command-slots.d.ts +8 -2
- package/dist/core/command-slots.js +6 -2
- package/dist/core/events.d.ts +9 -7
- package/dist/core/index.d.ts +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/credential/index.d.ts +1 -0
- package/dist/credential/index.js +1 -0
- package/dist/credential/settle.d.ts +20 -0
- package/dist/credential/target.d.ts +6 -0
- package/dist/credential/target.js +7 -0
- package/dist/resources/github/command.d.ts +54 -2
- package/dist/resources/github/config.js +1 -1
- package/dist/resources/github/index.js +1 -1
- package/dist/resources/github/resource.js +2 -2
- package/dist/resources/testserver/command.d.ts +208 -10
- package/dist/resources/testserver/command.js +7 -0
- package/dist/resources/testserver/commands/create/command.d.ts +808 -1
- package/dist/resources/testserver/commands/create/command.js +64 -23
- package/dist/resources/testserver/commands/create/metadata.js +6 -2
- package/dist/resources/testserver/commands/create/outcomes.d.ts +347 -0
- package/dist/resources/testserver/commands/create/outcomes.js +14 -1
- package/dist/resources/testserver/commands/list/command.d.ts +84 -1
- package/dist/resources/testserver/commands/list/command.js +1 -1
- package/dist/resources/testserver/commands/list/outcomes.d.ts +16 -0
- package/dist/resources/testserver/config.js +14 -4
- package/dist/resources/testserver/events.d.ts +9 -0
- package/dist/resources/testserver/index.js +8 -7
- package/dist/resources/testserver/lane.js +1 -0
- package/dist/resources/testserver/live/gateways.d.ts +2 -0
- package/dist/resources/testserver/live/gateways.js +16 -3
- package/dist/resources/testserver/pool/channels.d.ts +5 -2
- package/dist/resources/testserver/pool/channels.js +1 -1
- package/dist/resources/testserver/pool/create.d.ts +6 -2
- package/dist/resources/testserver/pool/create.js +6 -5
- package/dist/resources/testserver/pool/index.d.ts +1 -0
- package/dist/resources/testserver/pool/index.js +1 -0
- package/dist/resources/testserver/pool/pull-request.d.ts +89 -0
- package/dist/resources/testserver/pool/pull-request.js +85 -0
- package/dist/resources/testserver/pr-build-facts.d.ts +130 -0
- package/dist/resources/testserver/pr-build-facts.js +261 -0
- package/dist/resources/testserver/presentation.d.ts +2 -2
- package/dist/resources/testserver/presentation.js +12 -3
- package/dist/resources/testserver/provider.d.ts +16 -6
- package/dist/resources/testserver/provider.js +46 -15
- package/dist/resources/testserver/pull-request/gateways.d.ts +117 -0
- package/dist/resources/testserver/pull-request/gateways.js +5 -0
- package/dist/resources/testserver/pull-request/index.d.ts +5 -0
- package/dist/resources/testserver/pull-request/index.js +6 -0
- package/dist/resources/testserver/pull-request/live/github-rest.d.ts +28 -0
- package/dist/resources/testserver/pull-request/live/github-rest.js +114 -0
- package/dist/resources/testserver/pull-request/live/github-token-gateway.d.ts +12 -0
- package/dist/resources/testserver/pull-request/live/github-token-gateway.js +39 -0
- package/dist/resources/testserver/pull-request/live/pull-request-gateway.d.ts +10 -0
- package/dist/resources/testserver/pull-request/live/pull-request-gateway.js +27 -0
- package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.d.ts +21 -0
- package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.js +64 -0
- package/dist/resources/testserver/ran.d.ts +5 -0
- package/dist/resources/testserver/ran.js +19 -3
- package/dist/resources/testserver/resource.d.ts +5 -1
- package/dist/resources/testserver/resource.js +2 -2
- package/dist/resources/testserver/sandbox/build-reference.d.ts +38 -0
- package/dist/resources/testserver/sandbox/build-reference.js +79 -0
- package/dist/resources/testserver/sandbox/index.d.ts +1 -0
- package/dist/resources/testserver/sandbox/index.js +1 -0
- package/dist/resources.d.ts +265 -15
- 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 +2 -2
- package/dist/story/align.d.ts +1 -1
- package/dist/story/align.js +1 -1
- package/dist/story/command-line.d.ts +34 -0
- package/dist/story/command-line.js +100 -0
- 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 +2 -1
- package/dist/story/index.js +6 -5
- 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/context.js +1 -1
- package/dist/vercel-cli/index.js +1 -1
- package/dist/vitest/config.js +2 -2
- package/dist/vitest/fixtures.d.ts +1 -1
- package/dist/vitest/fixtures.js +1 -1
- package/dist/vitest/index.js +3 -3
- package/dist/vitest/plan.js +1 -1
- package/package.json +3 -3
- package/skills/overview.md +2 -0
- package/skills/testserver-builds.md +80 -0
- package/dist/story/artifact.d.ts +0 -60
- package/dist/story/live/artifact-gateway.d.ts +0 -2
package/dist/core/run-state.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MintTarget } from "../credential/index.ts";
|
|
2
|
-
import type { KeptSandbox } from "../runner/index.ts";
|
|
2
|
+
import type { KeptSandbox, RunnerSandboxPlan } from "../runner/index.ts";
|
|
3
3
|
import type { TimedRunEvent } from "./events.ts";
|
|
4
4
|
import type { LaneStates, ResourceLanes } from "./lane.ts";
|
|
5
5
|
import type { ResourceHoldings, RunLane } from "./resource.ts";
|
|
@@ -30,15 +30,35 @@ export interface RunnerStepState {
|
|
|
30
30
|
/** The last line the step printed, while it runs. */
|
|
31
31
|
readonly latest: string | undefined;
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* What the runner did with its runner snapshot: reused or built one, of the base it holds, or is building one. A reused
|
|
35
|
+
* branch snapshot names the branch and HEAD commit of the run that saved it; each is null for a base snapshot.
|
|
36
|
+
*/
|
|
34
37
|
export type RunnerSnapshotState = {
|
|
35
38
|
readonly kind: "reused" | "built";
|
|
36
39
|
readonly id: string;
|
|
37
40
|
readonly base: string;
|
|
41
|
+
readonly branch: string | null;
|
|
42
|
+
readonly head: string | null;
|
|
38
43
|
} | {
|
|
39
44
|
readonly kind: "building";
|
|
40
45
|
readonly summary: string;
|
|
41
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Saving the runner sandbox as a branch snapshot of `branch` (`--save-snapshot`): under way, saved as runner snapshot
|
|
49
|
+
* `id` at HEAD commit `head`, or not saved.
|
|
50
|
+
*/
|
|
51
|
+
export type BranchSnapshotSaveState = {
|
|
52
|
+
readonly kind: "saving";
|
|
53
|
+
readonly branch: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "saved";
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly branch: string;
|
|
58
|
+
readonly head: string;
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: "not-saved";
|
|
61
|
+
};
|
|
42
62
|
/** One vitest worker, as its test events show it. */
|
|
43
63
|
export interface TestWorkerState {
|
|
44
64
|
readonly worker: number;
|
|
@@ -73,6 +93,8 @@ export interface RunnerState extends Span {
|
|
|
73
93
|
readonly activity: "saving-snapshot" | "waiting-for-snapshot" | undefined;
|
|
74
94
|
/** The runner sandbox the run kept running once it ended, once closing kept it. */
|
|
75
95
|
readonly kept: KeptSandbox | undefined;
|
|
96
|
+
/** Saving the runner sandbox as a branch snapshot, once it began. */
|
|
97
|
+
readonly save: BranchSnapshotSaveState | undefined;
|
|
76
98
|
}
|
|
77
99
|
/** The command: its argument list and how it ended; `stopped` when the run killed it. */
|
|
78
100
|
export interface CommandState extends Span {
|
|
@@ -81,10 +103,12 @@ export interface CommandState extends Span {
|
|
|
81
103
|
}
|
|
82
104
|
/** The cleanup over the registry's kinds `K`: what it stops and releases, and what it couldn't. */
|
|
83
105
|
export interface CleanupState<K> extends Span {
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
106
|
+
/**
|
|
107
|
+
* In a runner run, what it does with the runner sandbox while it stops and deletes the runner's other sandboxes: keeps
|
|
108
|
+
* it running `ms` (`keep`, stopping and deleting it at 0) or saves it as a branch snapshot (`save`); null in a local
|
|
109
|
+
* run.
|
|
110
|
+
*/
|
|
111
|
+
readonly runnerSandbox: RunnerSandboxPlan | null;
|
|
88
112
|
/** What the run held of each resource as cleanup started, which each resource's presentation names. */
|
|
89
113
|
readonly holdings: ResourceHoldings<K>;
|
|
90
114
|
/** What releasing the resources the run held couldn't do, summed over them, such as leases not released. */
|
package/dist/core/run-state.js
CHANGED
|
@@ -71,6 +71,7 @@ function applyEvent(lanes, state, event, at) {
|
|
|
71
71
|
uploadBytes: undefined,
|
|
72
72
|
activity: undefined,
|
|
73
73
|
kept: undefined,
|
|
74
|
+
save: undefined,
|
|
74
75
|
},
|
|
75
76
|
};
|
|
76
77
|
case "minting":
|
|
@@ -125,8 +126,7 @@ function applyEvent(lanes, state, event, at) {
|
|
|
125
126
|
status: "running",
|
|
126
127
|
startedAt: at,
|
|
127
128
|
endedAt: undefined,
|
|
128
|
-
|
|
129
|
-
keepSandboxMs: event.keepSandboxMs,
|
|
129
|
+
runnerSandbox: event.runnerSandbox,
|
|
130
130
|
holdings: event.holdings,
|
|
131
131
|
resourceFailures: 0,
|
|
132
132
|
notStopped: 0,
|
|
@@ -210,11 +210,16 @@ function runnerEnded(state, outcome, at) {
|
|
|
210
210
|
function applyRunnerEvent(state, event, at) {
|
|
211
211
|
switch (event.kind) {
|
|
212
212
|
case "snapshot-reused":
|
|
213
|
-
return withRunner(withStep(state, "snapshot", () => ({ status: "done", startedAt: at, endedAt: at })), () => ({
|
|
213
|
+
return withRunner(withStep(state, "snapshot", () => ({ status: "done", startedAt: at, endedAt: at })), () => ({
|
|
214
|
+
snapshot: { kind: "reused", id: event.snapshotId, base: event.base, branch: event.branch, head: event.head },
|
|
215
|
+
}));
|
|
214
216
|
case "snapshot-build-started":
|
|
215
217
|
return withRunner(withStep(state, "snapshot", () => ({ status: "running", startedAt: at })), () => ({ snapshot: { kind: "building", summary: event.summary } }));
|
|
216
218
|
case "snapshot-built":
|
|
217
|
-
return withRunner(withStep(state, "snapshot", () => ({ status: "done", endedAt: at, latest: undefined })), () => ({
|
|
219
|
+
return withRunner(withStep(state, "snapshot", () => ({ status: "done", endedAt: at, latest: undefined })), () => ({
|
|
220
|
+
snapshot: { kind: "built", id: event.snapshotId, base: event.base, branch: null, head: null },
|
|
221
|
+
activity: undefined,
|
|
222
|
+
}));
|
|
218
223
|
case "snapshot-saving":
|
|
219
224
|
return withRunner(state, () => ({ activity: "saving-snapshot" }));
|
|
220
225
|
case "runner-sandbox-starting":
|
|
@@ -248,11 +253,21 @@ function applyRunnerEvent(state, event, at) {
|
|
|
248
253
|
return withRunner(state.cleanup === undefined ? state : { ...state, cleanup: { ...state.cleanup, waiting: true } }, () => ({ activity: "waiting-for-snapshot" }));
|
|
249
254
|
case "sandbox-kept":
|
|
250
255
|
return withRunner(state, () => ({ kept: { name: event.name, stopsAt: event.stopsAt } }));
|
|
256
|
+
case "branch-snapshot-saving":
|
|
257
|
+
return withRunner(state, () => ({ save: { kind: "saving", branch: event.branch } }));
|
|
258
|
+
case "branch-snapshot-saved":
|
|
259
|
+
return withRunner(state, () => ({
|
|
260
|
+
save: { kind: "saved", id: event.snapshotId, branch: event.branch, head: event.head },
|
|
261
|
+
}));
|
|
262
|
+
case "branch-snapshot-not-saved":
|
|
263
|
+
return withRunner(state, () => ({ save: { kind: "not-saved" } }));
|
|
251
264
|
// A step's outcome comes from its lane's end, not from the end of its output.
|
|
252
265
|
case "output-started":
|
|
253
266
|
case "output-ended":
|
|
254
267
|
case "snapshot-entry-not-written":
|
|
255
268
|
case "command-output-started":
|
|
269
|
+
case "branch-snapshots-dropped":
|
|
270
|
+
case "branch-snapshots-not-dropped":
|
|
256
271
|
return state;
|
|
257
272
|
}
|
|
258
273
|
}
|
package/dist/core/run.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CredentialGateway, type CredentialSourceChoice, type GitHubActionsTokenGateway, type MintFailure, type MintTarget } from "../credential/index.ts";
|
|
2
|
-
import { type PreparedRunner, type RunnerContext, type RunnerFailure, type RunnerScopeReport, type RunnerSnapshotCacheFailure, type RunnerSnapshotEntry } from "../runner/index.ts";
|
|
2
|
+
import { type PreparedRunner, type RunnerContext, type RunnerFailure, type RunnerSandboxPlan, type RunnerSave, type RunnerScopeReport, type RunnerSnapshotCacheFailure, type RunnerSnapshotEntry } from "../runner/index.ts";
|
|
3
3
|
import type { RunProgress } from "./events.ts";
|
|
4
4
|
import type { CommandGateway } from "./gateways.ts";
|
|
5
5
|
import type { CoreContext, RunProviders, ResourceCanceledFacts, ResourceCleanup, ResourceFacts, ResourceRefusal, ResourceRequests, ResourceUnprepared } from "./resource.ts";
|
|
@@ -23,8 +23,12 @@ export interface RunRunnerRequest {
|
|
|
23
23
|
readonly target: MintTarget;
|
|
24
24
|
/** The local user name, for each sandbox's `user` tag. */
|
|
25
25
|
readonly user: string;
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/**
|
|
27
|
+
* What the run does with the runner sandbox once it ends, decided before it starts: keep it running for the keep time
|
|
28
|
+
* (0 stops and deletes it), or, under `--save-snapshot` on a branch, save it as a branch snapshot once the command
|
|
29
|
+
* ends on its own (`saveBranchSnapshot`), never keeping it.
|
|
30
|
+
*/
|
|
31
|
+
readonly sandbox: RunnerSandboxPlan;
|
|
28
32
|
}
|
|
29
33
|
/** What every run was asked to do, local or in a runner run. */
|
|
30
34
|
interface RunRequestBase {
|
|
@@ -88,13 +92,21 @@ export type RunRunnerFailure = RunnerFailure | {
|
|
|
88
92
|
};
|
|
89
93
|
/** What a runner run got from the runner sandbox, once the command ran in it. */
|
|
90
94
|
export interface RanRunner {
|
|
95
|
+
/** The runner snapshot it started from, and its base. */
|
|
91
96
|
readonly snapshotId: string;
|
|
92
97
|
readonly base: string;
|
|
98
|
+
/** For a branch snapshot it started from, the branch and HEAD commit of the run that saved it; null otherwise. */
|
|
99
|
+
readonly snapshotBranch: string | null;
|
|
100
|
+
readonly snapshotHead: string | null;
|
|
93
101
|
/** Whether this run built the runner snapshot. */
|
|
94
102
|
readonly built: boolean;
|
|
95
103
|
readonly vcpus: number;
|
|
96
104
|
readonly region: string;
|
|
97
105
|
readonly runtime: string;
|
|
106
|
+
/** How long the build step took, in milliseconds. */
|
|
107
|
+
readonly buildMs: number;
|
|
108
|
+
/** How saving the runner sandbox as a branch snapshot ended; null without `--save-snapshot`. */
|
|
109
|
+
readonly save: RunnerSave | null;
|
|
98
110
|
}
|
|
99
111
|
/**
|
|
100
112
|
* How a run ended, over the registry's kinds `K`.
|
|
@@ -181,7 +193,8 @@ export type RunStopped<K> = ResourceRefusal<K> | {
|
|
|
181
193
|
*
|
|
182
194
|
* Release happens in `finally`, however the run ended, a throw included: once the command has stopped and, in a
|
|
183
195
|
* runner run, the runner's sandboxes are closed, each resource is released in reverse order, even when the
|
|
184
|
-
* `cleanup-started` event can't be reported.
|
|
196
|
+
* `cleanup-started` event can't be reported. A runner run that saves the runner sandbox as a branch snapshot releases
|
|
197
|
+
* them while the save runs, since the command is done with them.
|
|
185
198
|
*/
|
|
186
199
|
export declare function executeRun<K, C extends RunContext>(providers: RunProviders<K, C>, context: C, request: RunRequest<K>, control: RunControl, progress: RunProgress<K>): Promise<RunOutcome<K>>;
|
|
187
200
|
export {};
|
package/dist/core/run.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
2
|
import { credentialSourceFor, mintSource, } from "../credential/index.js";
|
|
3
|
-
import { readyRunner, runnerSandboxScope, REMOTE_TEST_EVENTS_PATH, lineSplitter, runRemote, } from "../runner/index.js";
|
|
3
|
+
import { readyRunner, runnerSandboxScope, REMOTE_TEST_EVENTS_PATH, keptMs, lineSplitter, runRemote, saveBranchSnapshot, } from "../runner/index.js";
|
|
4
4
|
import { parseTestEvent } from "../sdk/index.js";
|
|
5
5
|
import { mintReported, mintSourceReported } from "./mint.js";
|
|
6
6
|
import { colorEnvironment, commandEnvironment, runPayload } from "./payload.js";
|
|
@@ -17,7 +17,8 @@ import { acquireResources, canceledHolding, heldLanes, heldResources, prepareRes
|
|
|
17
17
|
*
|
|
18
18
|
* Release happens in `finally`, however the run ended, a throw included: once the command has stopped and, in a
|
|
19
19
|
* runner run, the runner's sandboxes are closed, each resource is released in reverse order, even when the
|
|
20
|
-
* `cleanup-started` event can't be reported.
|
|
20
|
+
* `cleanup-started` event can't be reported. A runner run that saves the runner sandbox as a branch snapshot releases
|
|
21
|
+
* them while the save runs, since the command is done with them.
|
|
21
22
|
*/
|
|
22
23
|
export async function executeRun(providers, context, request, control, progress) {
|
|
23
24
|
const slots = resourceSlots(providers, context, request.resources);
|
|
@@ -37,6 +38,7 @@ export async function executeRun(providers, context, request, control, progress)
|
|
|
37
38
|
baseRef: prepared.baseRef,
|
|
38
39
|
nestedRepositories: prepared.upload.nestedRepositories,
|
|
39
40
|
notes: prepared.notes,
|
|
41
|
+
saveSkipped: prepared.save?.kind === "skipped",
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
const unprepared = await prepareResources(slots, progress);
|
|
@@ -44,35 +46,38 @@ export async function executeRun(providers, context, request, control, progress)
|
|
|
44
46
|
return unprepared;
|
|
45
47
|
// Each slot keeps what its resource holds, pushed as it is acquired: the run releases all of it however it ends.
|
|
46
48
|
let cleanupStarted = false;
|
|
47
|
-
// Said once, before the runner's sandboxes are stopped in a runner run, else before the resources are released
|
|
48
|
-
|
|
49
|
+
// Said once, before the runner's sandboxes are stopped in a runner run, else before the resources are released, with
|
|
50
|
+
// what cleanup does with the runner sandbox (`runnerSandbox`). The first call's says it: a runner run that saves a
|
|
51
|
+
// branch snapshot calls `release` with its `save` before anything else starts cleanup.
|
|
52
|
+
const startCleanup = async (runnerSandbox) => {
|
|
49
53
|
if (cleanupStarted)
|
|
50
54
|
return;
|
|
51
55
|
cleanupStarted = true;
|
|
52
|
-
await progress.emit({
|
|
53
|
-
kind: "cleanup-started",
|
|
54
|
-
runner: request.runner !== undefined,
|
|
55
|
-
keepSandboxMs: request.runner?.keepSandboxMs ?? 0,
|
|
56
|
-
holdings: resourceHoldings(slots),
|
|
57
|
-
});
|
|
56
|
+
await progress.emit({ kind: "cleanup-started", runnerSandbox, holdings: resourceHoldings(slots) });
|
|
58
57
|
};
|
|
58
|
+
let resourceCleanup = {};
|
|
59
|
+
let releasing;
|
|
60
|
+
// Once: reporting cleanup's start can fail, and releasing what the run holds must not depend on it.
|
|
61
|
+
const release = (runnerSandbox) => (releasing ??= (async () => {
|
|
62
|
+
try {
|
|
63
|
+
await startCleanup(runnerSandbox);
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
resourceCleanup = await releaseResources(slots, progress);
|
|
67
|
+
}
|
|
68
|
+
})());
|
|
69
|
+
// What cleanup does with the runner sandbox when no save runs: the plan's keep time, 0 for a save that didn't run.
|
|
70
|
+
const unsaved = request.runner === undefined ? null : { kind: "keep", ms: keptMs(request.runner.sandbox) };
|
|
59
71
|
let ended;
|
|
60
72
|
let runnerCleanup = null;
|
|
61
|
-
let resourceCleanup = {};
|
|
62
73
|
try {
|
|
63
74
|
({ ended, runnerCleanup } =
|
|
64
75
|
request.runner === undefined
|
|
65
76
|
? { ended: await provisionAndRun(context, request, slots, control, progress), runnerCleanup: null }
|
|
66
|
-
: await provisionAndRunRemote(context, request, slots, control, progress, startCleanup));
|
|
77
|
+
: await provisionAndRunRemote(context, request, slots, control, progress, { startCleanup, release }));
|
|
67
78
|
}
|
|
68
79
|
finally {
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
await startCleanup();
|
|
72
|
-
}
|
|
73
|
-
finally {
|
|
74
|
-
resourceCleanup = await releaseResources(slots, progress);
|
|
75
|
-
}
|
|
80
|
+
await release(unsaved);
|
|
76
81
|
}
|
|
77
82
|
await progress.emit({
|
|
78
83
|
kind: "cleanup-finished",
|
|
@@ -179,10 +184,16 @@ function runnerStopped(outcome) {
|
|
|
179
184
|
* for a create in flight and a snapshot still saving run while readying winds down; the close the run awaits later
|
|
180
185
|
* gets that close's report, or its error. A runner run always mints, whatever resources it holds, so its request names
|
|
181
186
|
* no credential source: the command layer refuses `--credential github-actions` with it.
|
|
187
|
+
*
|
|
188
|
+
* The run's plan (`request.runner.sandbox`) gives the scope its keep time, which is 0 for a `save` plan: such a run
|
|
189
|
+
* never keeps its runner sandbox, however it ends. Under a `save` plan, once the command ended on its own and no signal
|
|
190
|
+
* arrived, it saves the runner sandbox as a branch snapshot (`saveBranchSnapshot`) while the resources are released,
|
|
191
|
+
* and closes the scope once the save is done, even when releasing them threw.
|
|
182
192
|
*/
|
|
183
|
-
async function provisionAndRunRemote(context, request, slots, control, progress,
|
|
193
|
+
async function provisionAndRunRemote(context, request, slots, control, progress, cleanup) {
|
|
184
194
|
const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
|
|
185
|
-
const
|
|
195
|
+
const plan = request.runner.sandbox;
|
|
196
|
+
const keepMs = keptMs(plan);
|
|
186
197
|
const scope = runnerSandboxScope(context, runnerProgress, { keepMs });
|
|
187
198
|
let commandRunning = false;
|
|
188
199
|
// Said before the close starts, so the stopping line comes before any line the close's waits print.
|
|
@@ -202,9 +213,29 @@ async function provisionAndRunRemote(context, request, slots, control, progress,
|
|
|
202
213
|
commandRunning = true;
|
|
203
214
|
},
|
|
204
215
|
}, progress, runnerProgress);
|
|
205
|
-
|
|
216
|
+
commandRunning = false;
|
|
217
|
+
const unsaved = { kind: "keep", ms: keepMs };
|
|
218
|
+
if (ended.kind !== "command-ended") {
|
|
219
|
+
await cleanup.startCleanup(unsaved);
|
|
220
|
+
return { ended, runnerCleanup: { ...(await scope.close()), target: request.runner.target } };
|
|
221
|
+
}
|
|
222
|
+
const { ready, ...rest } = ended;
|
|
223
|
+
const { prepared } = request.runner;
|
|
224
|
+
let save = prepared.save?.kind === "skipped" ? prepared.save : null;
|
|
225
|
+
const action = plan.kind === "save" && !control.signal.aborted ? plan : unsaved;
|
|
226
|
+
if (action.kind === "save") {
|
|
227
|
+
const saving = saveBranchSnapshot(context, { ready, branch: action.branch, head: prepared.head.commit }, { scope, signal: control.signal }, runnerProgress);
|
|
228
|
+
// The save settles before the scope closes, even when releasing the resources threw.
|
|
229
|
+
try {
|
|
230
|
+
await cleanup.release(action);
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
save = await saving;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
await cleanup.startCleanup(action);
|
|
206
237
|
const runnerCleanup = { ...(await scope.close()), target: request.runner.target };
|
|
207
|
-
return { ended, runnerCleanup };
|
|
238
|
+
return { ended: { ...rest, runner: { ...rest.runner, save } }, runnerCleanup };
|
|
208
239
|
}
|
|
209
240
|
finally {
|
|
210
241
|
control.signal.removeEventListener("abort", stop);
|
|
@@ -290,13 +321,18 @@ async function mintAndRunRemote(context, request, slots, control, progress, runn
|
|
|
290
321
|
resources: resourcesFacts(slots),
|
|
291
322
|
command,
|
|
292
323
|
runner: {
|
|
293
|
-
snapshotId: ready.snapshotId,
|
|
294
|
-
base: ready.base,
|
|
324
|
+
snapshotId: ready.startedFrom.snapshotId,
|
|
325
|
+
base: ready.startedFrom.base,
|
|
326
|
+
snapshotBranch: ready.startedFrom.branch ?? null,
|
|
327
|
+
snapshotHead: ready.startedFrom.head ?? null,
|
|
295
328
|
built: ready.built,
|
|
296
329
|
vcpus: ready.vcpus,
|
|
297
330
|
region: ready.region,
|
|
298
331
|
runtime: ready.runtime,
|
|
332
|
+
buildMs: ready.buildMs,
|
|
333
|
+
save: null,
|
|
299
334
|
},
|
|
335
|
+
ready,
|
|
300
336
|
};
|
|
301
337
|
}
|
|
302
338
|
/**
|
|
@@ -5,3 +5,4 @@ export { liveGitHubActionsTokenGateway } from "./live/github-actions-token-gatew
|
|
|
5
5
|
export { liveCredentialGateway } from "./live/vercel-cli-gateway.ts";
|
|
6
6
|
export { credentialErrors, requireTarget, settleCredential } from "./settle.ts";
|
|
7
7
|
export { type CredentialFailure, type CredentialOrigin, type CredentialOutcome, type CredentialSource, type CredentialSourceChoice, credentialSourceFor, githubActionsSource, mintSource, type TokenRequestFailure, } from "./source.ts";
|
|
8
|
+
export { mintTargetText } from "./target.ts";
|
package/dist/credential/index.js
CHANGED
|
@@ -5,3 +5,4 @@ export { liveGitHubActionsTokenGateway } from "./live/github-actions-token-gatew
|
|
|
5
5
|
export { liveCredentialGateway } from "./live/vercel-cli-gateway.js";
|
|
6
6
|
export { credentialErrors, requireTarget, settleCredential } from "./settle.js";
|
|
7
7
|
export { credentialSourceFor, githubActionsSource, mintSource, } from "./source.js";
|
|
8
|
+
export { mintTargetText } from "./target.js";
|
|
@@ -10,6 +10,26 @@ export declare const credentialErrors: import("@vercel/clinkr").SharedErrors<{
|
|
|
10
10
|
scope: "scope";
|
|
11
11
|
}>>;
|
|
12
12
|
}, z.core.$strip>;
|
|
13
|
+
}, {
|
|
14
|
+
readonly missingTarget: {
|
|
15
|
+
readonly exitCode: 2;
|
|
16
|
+
readonly description: "The command may mint a credential, and neither a flag nor storm.config.ts names the control plane team or project.";
|
|
17
|
+
readonly schema: z.ZodObject<{
|
|
18
|
+
missing: z.ZodArray<z.ZodEnum<{
|
|
19
|
+
project: "project";
|
|
20
|
+
scope: "scope";
|
|
21
|
+
}>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
readonly render: ({ missing }: {
|
|
24
|
+
missing: ("project" | "scope")[];
|
|
25
|
+
}) => {
|
|
26
|
+
message: string;
|
|
27
|
+
next: {
|
|
28
|
+
type: "text";
|
|
29
|
+
text: string;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
13
33
|
}>;
|
|
14
34
|
type MissingTarget = ReturnType<typeof credentialErrors.missingTarget>;
|
|
15
35
|
/** A setting a command resolved, from a flag or the config file; only its value matters here. */
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MintTarget } from "./gateways.ts";
|
|
2
|
+
/**
|
|
3
|
+
* How progress names a mint target: the Vercel project and its team, each labeled, such as `Vercel project vercel on
|
|
4
|
+
* team vercel`, so it can't be read as a GitHub `owner/repo`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mintTargetText(target: MintTarget): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How progress names a mint target: the Vercel project and its team, each labeled, such as `Vercel project vercel on
|
|
3
|
+
* team vercel`, so it can't be read as a GitHub `owner/repo`.
|
|
4
|
+
*/
|
|
5
|
+
export function mintTargetText(target) {
|
|
6
|
+
return `Vercel project ${target.project} on team ${target.team}`;
|
|
7
|
+
}
|
|
@@ -13,6 +13,32 @@ export declare const githubFixtureRepoSettleErrors: import("@vercel/clinkr").Sha
|
|
|
13
13
|
set: "set";
|
|
14
14
|
}>;
|
|
15
15
|
}, z.core.$strip>;
|
|
16
|
+
}, {
|
|
17
|
+
readonly githubTokenMissing: {
|
|
18
|
+
readonly exitCode: 2;
|
|
19
|
+
readonly description: "The run holds resources.githubFixtureRepo, required (optional is false: in the file, by --set resources.githubFixtureRepo.optional=false, or by default), and the host environment variable its tokenEnv names is unset or empty, so the run didn't start.";
|
|
20
|
+
readonly schema: z.ZodObject<{
|
|
21
|
+
tokenEnv: z.ZodString;
|
|
22
|
+
repo: z.ZodString;
|
|
23
|
+
configFile: z.ZodNullable<z.ZodString>;
|
|
24
|
+
requiredBy: z.ZodEnum<{
|
|
25
|
+
config: "config";
|
|
26
|
+
set: "set";
|
|
27
|
+
}>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
readonly render: ({ tokenEnv, repo, requiredBy }: {
|
|
30
|
+
tokenEnv: string;
|
|
31
|
+
repo: string;
|
|
32
|
+
configFile: string | null;
|
|
33
|
+
requiredBy: "config" | "set";
|
|
34
|
+
}) => {
|
|
35
|
+
message: string;
|
|
36
|
+
next: {
|
|
37
|
+
type: "text";
|
|
38
|
+
text: string;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
16
42
|
}>;
|
|
17
43
|
/** What deleting the branches under a canceled run's prefix did, for a person; nothing when it held no repository. */
|
|
18
44
|
export declare function fixtureRepoCanceledLines(cleanup: FixtureRepoCleanup | undefined): string[];
|
|
@@ -25,7 +51,7 @@ export declare const githubFixtureRepoRefusalErrors: {
|
|
|
25
51
|
repo: z.ZodString;
|
|
26
52
|
status: z.ZodNullable<z.ZodNumber>;
|
|
27
53
|
message: z.ZodString;
|
|
28
|
-
}, z.core.$strip
|
|
54
|
+
}, z.core.$strip>, readonly []>;
|
|
29
55
|
};
|
|
30
56
|
/**
|
|
31
57
|
* The GitHub fixture repository resource's command half, `resources.githubFixtureRepo`, with its errors: its settle's,
|
|
@@ -42,13 +68,39 @@ export declare const githubFixtureRepoCommand: {
|
|
|
42
68
|
set: "set";
|
|
43
69
|
}>;
|
|
44
70
|
}, z.core.$strip>;
|
|
71
|
+
}, {
|
|
72
|
+
readonly githubTokenMissing: {
|
|
73
|
+
readonly exitCode: 2;
|
|
74
|
+
readonly description: "The run holds resources.githubFixtureRepo, required (optional is false: in the file, by --set resources.githubFixtureRepo.optional=false, or by default), and the host environment variable its tokenEnv names is unset or empty, so the run didn't start.";
|
|
75
|
+
readonly schema: z.ZodObject<{
|
|
76
|
+
tokenEnv: z.ZodString;
|
|
77
|
+
repo: z.ZodString;
|
|
78
|
+
configFile: z.ZodNullable<z.ZodString>;
|
|
79
|
+
requiredBy: z.ZodEnum<{
|
|
80
|
+
config: "config";
|
|
81
|
+
set: "set";
|
|
82
|
+
}>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
readonly render: ({ tokenEnv, repo, requiredBy }: {
|
|
85
|
+
tokenEnv: string;
|
|
86
|
+
repo: string;
|
|
87
|
+
configFile: string | null;
|
|
88
|
+
requiredBy: "config" | "set";
|
|
89
|
+
}) => {
|
|
90
|
+
message: string;
|
|
91
|
+
next: {
|
|
92
|
+
type: "text";
|
|
93
|
+
text: string;
|
|
94
|
+
}[];
|
|
95
|
+
};
|
|
96
|
+
};
|
|
45
97
|
}>;
|
|
46
98
|
refusalErrors: {
|
|
47
99
|
readonly githubFixtureRepoUnavailable: import("@vercel/clinkr").DataErrorDefinition<z.ZodObject<{
|
|
48
100
|
repo: z.ZodString;
|
|
49
101
|
status: z.ZodNullable<z.ZodNumber>;
|
|
50
102
|
message: z.ZodString;
|
|
51
|
-
}, z.core.$strip
|
|
103
|
+
}, z.core.$strip>, readonly []>;
|
|
52
104
|
};
|
|
53
105
|
settle: ({ options, env, configFile }: import("../../core/command-provider.ts").ResourceSettleInput<GitHubFixtureRepoKind>) => {
|
|
54
106
|
readonly ok: false;
|
|
@@ -24,7 +24,7 @@ const KIND = "githubFixtureRepo";
|
|
|
24
24
|
*/
|
|
25
25
|
export const githubFixtureRepoConfig = {
|
|
26
26
|
name: "githubFixtureRepo",
|
|
27
|
-
factory: { kind: KIND, call: "githubFixtureRepo({ … })", subpath: "@
|
|
27
|
+
factory: { kind: KIND, call: "githubFixtureRepo({ … })", subpath: "@vercel/storm/github" },
|
|
28
28
|
options: {
|
|
29
29
|
repo: { check: repoName, readText: readTextAsIs, required: true },
|
|
30
30
|
tokenEnv: { check: envName, readText: readTextAsIs, required: true },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The GitHub fixture repository resource's folder: the repository the run opens before its command and cleans up after
|
|
2
2
|
// it, its kind and run half, its resource config, its command half with its settle, its cleanup report, its gateway
|
|
3
|
-
// and live gateways, and the `@
|
|
3
|
+
// and live gateways, and the `@vercel/storm/github` config helper (`resource.ts`). Its provider value
|
|
4
4
|
// (`resource-provider.ts`) carries them to the registry (`src/resources.ts`), the one place outside this folder that
|
|
5
5
|
// takes it; `src/config-file/` imports its types through this file. The rest of what it exports is for tests.
|
|
6
6
|
export { fixtureRepoCleanupFailureText, githubFixtureRepoCleanupReport, } from "./cleanup.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The GitHub fixture repository resource's published surface, `@
|
|
2
|
-
// `storm.config.ts` imports it, so, like `@
|
|
1
|
+
// The GitHub fixture repository resource's published surface, `@vercel/storm/github`. A user's
|
|
2
|
+
// `storm.config.ts` imports it, so, like `@vercel/storm/config`, it imports nothing at run time: loading a
|
|
3
3
|
// config file pulls in no Clinkr, zod or CLI code.
|
|
4
4
|
/**
|
|
5
5
|
* The GitHub fixture repository resource for `resources.githubFixtureRepo` in `storm.config.ts`. A run with it
|