@cnc-tools/storm 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.js +5 -1
- package/dist/bin/storm.js +6 -2
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-FK4RLDEK.js → chunk-27P2QSIM.js} +1 -1
- package/dist/chunks/{chunk-ODQHQJLE.js → chunk-5ED3IDUJ.js} +749 -1121
- package/dist/chunks/{chunk-FSP3SJ35.js → chunk-5TMHYH7G.js} +16 -46
- package/dist/chunks/{chunk-Y3BUNNRG.js → chunk-BFLYGMG3.js} +12 -7
- package/dist/chunks/{chunk-LQKNI3EG.js → chunk-BRUIATTR.js} +6 -6
- package/dist/chunks/{chunk-RYRJNHL7.js → chunk-HOKDKP5A.js} +3 -9
- package/dist/chunks/{chunk-SXW6XN4R.js → chunk-IVRRGGCD.js} +60 -20
- package/dist/chunks/{chunk-TMQQYHUX.js → chunk-QBR5VHJ7.js} +1 -1
- package/dist/chunks/{chunk-YT5OROR7.js → chunk-RA4L2ACU.js} +12 -2
- package/dist/chunks/{chunk-TEEZL3GA.js → chunk-RKONDLPS.js} +17 -71
- package/dist/chunks/{chunk-IYM44FUX.js → chunk-UC6DULWY.js} +2 -2
- package/dist/chunks/{chunk-4XT5RC5T.js → chunk-XPCUINWS.js} +6 -42
- package/dist/chunks/{chunk-U7M3ZB3Z.js → chunk-YBPTMJUM.js} +123 -180
- package/dist/chunks/{chunk-ISGQJIQM.js → chunk-Z5OXOZD3.js} +125 -83
- package/dist/chunks/{chunk-7D6LC5JY.js → chunk-ZH5R7W4A.js} +7 -39
- package/dist/chunks/{live-app-AZ5N5HBD.js → live-app-FBVWUUMT.js} +7 -7
- package/dist/commands/exec/command.d.ts +4 -90
- package/dist/commands/exec/command.js +15 -41
- package/dist/commands/exec/define-run-command.d.ts +19 -100
- package/dist/commands/exec/define-run-command.js +48 -15
- package/dist/commands/exec/driver-plan.d.ts +24 -16
- package/dist/commands/exec/driver-plan.js +34 -15
- package/dist/commands/exec/driver-refusals.js +7 -6
- package/dist/commands/exec/exec-words.d.ts +1 -1
- package/dist/commands/exec/exec-words.js +8 -2
- package/dist/commands/exec/final-results.d.ts +39 -0
- package/dist/commands/exec/final-results.js +29 -0
- package/dist/commands/exec/live-view.js +18 -22
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +15 -109
- package/dist/commands/exec/outcomes.js +25 -39
- package/dist/commands/exec/plan-run.d.ts +11 -3
- package/dist/commands/exec/plan-run.js +3 -2
- package/dist/commands/exec/progress.d.ts +3 -19
- package/dist/commands/exec/progress.js +16 -60
- package/dist/commands/exec/run-command.d.ts +5 -24
- package/dist/commands/exec/run-command.js +32 -84
- package/dist/commands/exec/run-metadata.d.ts +0 -6
- package/dist/commands/exec/run-metadata.js +2 -8
- package/dist/commands/exec/snapshot-text.d.ts +7 -16
- package/dist/commands/exec/snapshot-text.js +9 -49
- package/dist/commands/exec/test-plan.d.ts +2 -1
- package/dist/commands/exec/test-plan.js +13 -4
- package/dist/commands/exec/tests-summary.d.ts +2 -2
- package/dist/commands/exec/view.js +2 -12
- package/dist/commands/exec/worker-chart.d.ts +1 -1
- package/dist/commands/playwright/command.d.ts +12 -97
- package/dist/commands/playwright/command.js +14 -14
- package/dist/commands/playwright/metadata.js +2 -2
- package/dist/commands/runs/facts.d.ts +1 -37
- package/dist/commands/runs/facts.js +4 -36
- package/dist/commands/runs/list/command.d.ts +0 -72
- package/dist/commands/runs/list/command.js +6 -6
- package/dist/commands/runs/list/outcomes.d.ts +0 -36
- package/dist/commands/runs/logs/command.js +6 -6
- package/dist/commands/runs/show/command.d.ts +2 -74
- package/dist/commands/runs/show/command.js +16 -43
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +1 -37
- package/dist/commands/runs/show/outcomes.js +8 -42
- package/dist/commands/snapshots/build/command.d.ts +14 -411
- package/dist/commands/snapshots/build/command.js +59 -234
- package/dist/commands/snapshots/build/metadata.js +10 -7
- package/dist/commands/snapshots/build/outcomes.d.ts +11 -241
- package/dist/commands/snapshots/build/outcomes.js +29 -196
- package/dist/commands/snapshots/list/command.d.ts +2 -36
- package/dist/commands/snapshots/list/command.js +20 -56
- package/dist/commands/snapshots/list/metadata.js +1 -1
- package/dist/commands/snapshots/list/outcomes.d.ts +2 -37
- package/dist/commands/snapshots/list/outcomes.js +13 -53
- package/dist/commands/vitest/command.d.ts +14 -98
- package/dist/commands/vitest/command.js +14 -14
- package/dist/commands/vitest/metadata.js +2 -2
- package/dist/config/resolve.d.ts +1 -1
- package/dist/config/resolve.js +2 -1
- package/dist/config/schema.d.ts +8 -0
- package/dist/config/schema.js +5 -4
- package/dist/core/events.d.ts +5 -6
- package/dist/core/run-state.d.ts +7 -29
- package/dist/core/run-state.js +3 -26
- package/dist/core/run.d.ts +6 -14
- package/dist/core/run.js +17 -28
- package/dist/extensions/playwright/driver.js +17 -10
- package/dist/extensions/testserver/commands/pool/create/command.js +4 -4
- package/dist/extensions/testserver/commands/pool/list/command.js +2 -2
- package/dist/extensions/testserver/definition.d.ts +1 -1
- package/dist/extensions/testserver/extension.d.ts +1 -1
- package/dist/extensions/testserver/options/rules.d.ts +3 -3
- package/dist/extensions/testserver/options/rules.js +5 -5
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/vercel-cli/index.d.ts +1 -0
- package/dist/extensions/testserver/vercel-cli/index.js +1 -0
- package/dist/extensions/testserver/vercel-cli/report.js +5 -2
- package/dist/extensions/testserver/vercel-cli/session-id.d.ts +8 -0
- package/dist/extensions/testserver/vercel-cli/session-id.js +16 -0
- package/dist/extensions/testserver/vitest/config.d.ts +2 -2
- package/dist/extensions/testserver/vitest/config.js +2 -2
- package/dist/extensions/testserver/vitest/container-scope.d.ts +25 -16
- package/dist/extensions/testserver/vitest/container-scope.js +32 -13
- package/dist/extensions/testserver/vitest/diagnostics.d.ts +5 -4
- package/dist/extensions/testserver/vitest/diagnostics.js +15 -8
- package/dist/extensions/testserver/vitest/fixtures.d.ts +10 -1
- package/dist/extensions/testserver/vitest/fixtures.js +36 -10
- package/dist/extensions/testserver/vitest/types.d.ts +9 -0
- package/dist/extensions/vitest/driver.js +28 -14
- package/dist/extensions/vitest/plan/gateways.d.ts +28 -5
- package/dist/extensions/vitest/plan/gateways.js +2 -2
- package/dist/extensions/vitest/plan/list-output.d.ts +5 -0
- package/dist/extensions/vitest/plan/list-output.js +23 -9
- package/dist/extensions/vitest/plan/live/list-gateway.d.ts +3 -2
- package/dist/extensions/vitest/plan/live/list-gateway.js +77 -64
- package/dist/extensions/vitest/plan/plan-over.d.ts +19 -7
- package/dist/extensions/vitest/plan/plan-over.js +18 -7
- package/dist/extensions/vitest/plan/plan.d.ts +14 -5
- package/dist/extensions/vitest/plan/plan.js +23 -9
- package/dist/extensions.d.ts +2 -2
- package/dist/run-directory/index.d.ts +1 -1
- package/dist/run-directory/index.js +0 -1
- package/dist/run-directory/plan.d.ts +3 -2
- package/dist/run-directory/plan.js +6 -3
- package/dist/run-directory/recording.js +2 -2
- package/dist/run-directory/run-record.d.ts +18 -135
- package/dist/run-directory/run-record.js +8 -68
- package/dist/runner/build-snapshots.d.ts +50 -114
- package/dist/runner/build-snapshots.js +70 -159
- package/dist/runner/events.d.ts +4 -88
- package/dist/runner/gateways.d.ts +5 -23
- package/dist/runner/index.d.ts +5 -6
- package/dist/runner/index.js +1 -1
- package/dist/runner/live/snapshot-records.js +7 -18
- package/dist/runner/prepare.d.ts +11 -22
- package/dist/runner/prepare.js +6 -17
- package/dist/runner/ready.d.ts +16 -45
- package/dist/runner/ready.js +34 -59
- package/dist/runner/recipe.d.ts +5 -45
- package/dist/runner/recipe.js +0 -41
- package/dist/runner/sandboxed-command.d.ts +5 -3
- package/dist/runner/sandboxed-command.js +10 -4
- package/dist/runner/scope.d.ts +8 -25
- package/dist/runner/scope.js +4 -8
- package/dist/runner/session.d.ts +18 -65
- package/dist/runner/session.js +15 -83
- package/dist/runner/snapshot-build.d.ts +2 -2
- package/dist/runner/snapshot-cache.d.ts +22 -74
- package/dist/runner/snapshot-cache.js +15 -107
- package/dist/runner/snapshot-inspect.d.ts +9 -13
- package/dist/runner/snapshot-inspect.js +48 -57
- package/dist/runner/snapshot-key.d.ts +9 -14
- package/dist/runner/snapshot-key.js +15 -22
- package/dist/sdk/extension/driver.d.ts +32 -6
- package/dist/sdk/extension/driver.js +12 -2
- package/dist/sdk/extension/index.d.ts +1 -1
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +6 -5
- package/dist/vendor/testserver-sdk/container/api-request.d.ts +2 -3
- package/dist/vendor/testserver-sdk/container/api-request.js +2 -3
- package/dist/vendor/testserver-sdk/container/container.d.ts +12 -2
- package/dist/vendor/testserver-sdk/container/container.js +10 -7
- package/dist/vendor/testserver-sdk/container/recorder.d.ts +29 -7
- package/dist/vendor/testserver-sdk/container/recorder.js +26 -14
- package/dist/vendor/testserver-sdk/index.d.ts +1 -1
- package/dist/vendor/testserver-sdk/index.js +1 -1
- package/dist/vendor/testserver-sdk/proxy/exchange.d.ts +24 -5
- package/dist/vendor/testserver-sdk/proxy/exchange.js +43 -25
- package/dist/vendor/testserver-sdk/proxy/faulted-exchange.js +15 -10
- package/dist/vendor/testserver-sdk/proxy/faults.d.ts +6 -5
- package/dist/vendor/testserver-sdk/proxy/proxy.d.ts +10 -1
- package/dist/vendor/testserver-sdk/proxy/proxy.js +5 -3
- package/dist/vendor/testserver-sdk/proxy/records.d.ts +17 -17
- package/dist/vendor/testserver-sdk/proxy/records.js +18 -17
- package/dist/vendor/testserver-sdk/records/body.d.ts +7 -9
- package/dist/vendor/testserver-sdk/records/body.js +10 -15
- package/dist/vendor/testserver-sdk/records/headers.d.ts +79 -0
- package/dist/vendor/testserver-sdk/records/headers.js +162 -0
- package/dist/vendor/testserver-sdk/records/index.d.ts +2 -1
- package/dist/vendor/testserver-sdk/records/index.js +4 -2
- package/dist/vendor/testserver-sdk/records/records.d.ts +19 -10
- package/package.json +5 -4
- package/skills/overview.md +5 -5
- package/skills/read-run-output.md +8 -9
- package/dist/runner/snapshot-save.d.ts +0 -70
- package/dist/runner/snapshot-save.js +0 -160
- package/dist/runner/snapshot-start.d.ts +0 -25
- package/dist/runner/snapshot-start.js +0 -16
- package/skills/testserver-builds.md +0 -82
|
@@ -1,66 +1,45 @@
|
|
|
1
1
|
import type { RunnerContext } from "./context.ts";
|
|
2
2
|
import type { RunnerFailure, RunnerProgress } from "./events.ts";
|
|
3
3
|
import type { CheckoutHead, RunnerSnapshotCacheFailure, RunnerSnapshotEntry, SandboxAccess } from "./gateways.ts";
|
|
4
|
-
import
|
|
5
|
-
import type { CheckedRecipe
|
|
4
|
+
import type { PrepareRunnerOutcome, RunnerPrepareContext } from "./prepare.ts";
|
|
5
|
+
import type { CheckedRecipe } from "./recipe.ts";
|
|
6
6
|
import { type RunnerScopeFacts } from "./scope.ts";
|
|
7
7
|
import type { RunnerSecrets } from "./secrets.ts";
|
|
8
8
|
import { type BaseSnapshotPlan } from "./snapshot-build.ts";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* What `storm snapshots build` builds: for this checkout (`checkout`), what the next run starts from, a base snapshot
|
|
12
|
-
* when none fits and then a dev snapshot at HEAD's commit; or only a base snapshot at the commit `ref` names (`base`).
|
|
13
|
-
* `full` uses nothing from the cache.
|
|
14
|
-
*/
|
|
15
|
-
export type SnapshotBuildMode = {
|
|
16
|
-
readonly kind: "checkout";
|
|
17
|
-
readonly full: boolean;
|
|
18
|
-
} | {
|
|
19
|
-
readonly kind: "base";
|
|
20
|
-
readonly ref: string;
|
|
21
|
-
readonly full: boolean;
|
|
22
|
-
};
|
|
23
|
-
/** What `prepareSnapshotBuild` checks: where, which recipe, the run `vcpus` is called with, and what to build. */
|
|
24
|
-
export interface SnapshotBuildRequest<Run> {
|
|
9
|
+
/** What `prepareSnapshotBuild` checks: where, which recipe, and what to build. */
|
|
10
|
+
export interface SnapshotBuildRequest {
|
|
25
11
|
/** The directory the command started in, inside the checkout. */
|
|
26
12
|
readonly cwd: string;
|
|
27
|
-
readonly recipe: CheckedRecipe
|
|
28
|
-
/**
|
|
29
|
-
readonly
|
|
30
|
-
|
|
13
|
+
readonly recipe: CheckedRecipe;
|
|
14
|
+
/** The ref `--base` names; undefined builds at the merge-base. */
|
|
15
|
+
readonly ref: string | undefined;
|
|
16
|
+
/** `--full`: build whatever the cache holds. */
|
|
17
|
+
readonly full: boolean;
|
|
31
18
|
}
|
|
32
19
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
20
|
+
* A build, checked on this machine: the base snapshot it builds (`plan`), HEAD, whose `dirty` says the working tree
|
|
21
|
+
* has uncommitted changes, which a base snapshot doesn't hold, the ref `--base` named (null for the merge-base), HEAD's
|
|
22
|
+
* merge-base and its ref (null for a `--base` build in a checkout where no base ref shares history with HEAD), whether
|
|
23
|
+
* the commit it builds at is that merge-base (`atMergeBase`: a run here starts only from a snapshot at its merge-base,
|
|
24
|
+
* though a run in another checkout, or after a later merge-base, still might), and the base snapshots of `plan`'s base
|
|
25
|
+
* and key the cache holds with more than an hour left (`cached`, before the team and project filter).
|
|
36
26
|
*/
|
|
37
|
-
export
|
|
38
|
-
readonly kind: "uncommitted";
|
|
39
|
-
} | {
|
|
40
|
-
readonly kind: "not-on-base-ref";
|
|
41
|
-
readonly refs: readonly string[];
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* A build, checked on this machine. `checkout`: the run's own local checks (`prepareRunner`); unless its
|
|
45
|
-
* `devSnapshots` is `reuse`, it says why the build saves no dev snapshot (the recipe doesn't trust dev snapshots, or
|
|
46
|
-
* reuses none, so no run would start from one). `base`: the commit `ref` names, its snapshot steps and key, HEAD, the base snapshots of
|
|
47
|
-
* that commit the cache holds with more than an hour left (`cached`, before the team and project filter), and what to
|
|
48
|
-
* warn about.
|
|
49
|
-
*/
|
|
50
|
-
export type PreparedSnapshotBuild = {
|
|
51
|
-
readonly kind: "checkout";
|
|
52
|
-
readonly prepared: PreparedRunner;
|
|
53
|
-
readonly full: boolean;
|
|
54
|
-
} | {
|
|
55
|
-
readonly kind: "base";
|
|
27
|
+
export interface PreparedSnapshotBuild {
|
|
56
28
|
readonly plan: BaseSnapshotPlan;
|
|
57
|
-
readonly ref: string;
|
|
58
29
|
readonly head: CheckoutHead;
|
|
30
|
+
readonly ref: string | null;
|
|
31
|
+
readonly mergeBase: {
|
|
32
|
+
readonly commit: string;
|
|
33
|
+
readonly ref: string;
|
|
34
|
+
} | null;
|
|
35
|
+
readonly atMergeBase: boolean;
|
|
59
36
|
readonly cached: readonly RunnerSnapshotEntry[];
|
|
60
37
|
readonly full: boolean;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* How a build's local checks ended: a run's refusals, but `submodules`'s and `invalid-recipe`'s and `checkout-failed`'s
|
|
41
|
+
* that the build shares, or `ref-not-found` when `--base` names no local commit.
|
|
42
|
+
*/
|
|
64
43
|
export type PrepareSnapshotBuildOutcome = {
|
|
65
44
|
readonly kind: "ok";
|
|
66
45
|
readonly build: PreparedSnapshotBuild;
|
|
@@ -71,12 +50,12 @@ export type PrepareSnapshotBuildOutcome = {
|
|
|
71
50
|
readonly ref: string;
|
|
72
51
|
};
|
|
73
52
|
/**
|
|
74
|
-
* Runs a build's local checks, before anything is minted or started
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* base
|
|
53
|
+
* Runs a build's local checks, before anything is minted or started: the repository's root, HEAD, the submodule
|
|
54
|
+
* refusal, HEAD's merge-base (`resolveBase`, which refuses with `no-base-ref` only without `--base`), the commit
|
|
55
|
+
* `--base` resolves to locally, the snapshot steps and key at the commit it builds, the cache's base snapshots of it,
|
|
56
|
+
* and, when it builds at the merge-base, HEAD's count of commits after it. It never mints, acquires or creates, and removes no cache file.
|
|
78
57
|
*/
|
|
79
|
-
export declare function prepareSnapshotBuild
|
|
58
|
+
export declare function prepareSnapshotBuild(context: RunnerPrepareContext, request: SnapshotBuildRequest): Promise<PrepareSnapshotBuildOutcome>;
|
|
80
59
|
/** What `buildSnapshots` is handed: the checked build, where its sandboxes run, who starts them, and the secrets. */
|
|
81
60
|
export interface BuildSnapshotsRequest {
|
|
82
61
|
readonly build: PreparedSnapshotBuild;
|
|
@@ -90,89 +69,46 @@ export interface BuildSnapshotsRequest {
|
|
|
90
69
|
/**
|
|
91
70
|
* How a build ended, before its sandbox scope closed.
|
|
92
71
|
*
|
|
93
|
-
* - `up-to-date`:
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* - `
|
|
97
|
-
* `devSnapshot` the dev snapshot it saved and cached, null when it saved none.
|
|
98
|
-
* - `dev-snapshot-not-saved`: the scrub or the save of the dev snapshot failed (`step`), with `message`.
|
|
99
|
-
* - `not-cached`: it saved `snapshot`, the snapshot the build ends with (the dev snapshot, or the base snapshot of a
|
|
100
|
-
* build that saves no dev snapshot), but the cache couldn't write its entry (`failure`), so no run finds it.
|
|
101
|
-
* - `snapshot-gone`: starting from cached runner snapshot `entry` answered that it is gone, so its entry was removed;
|
|
102
|
-
* `removal` is why it couldn't be, if it couldn't.
|
|
72
|
+
* - `up-to-date`: the cache holds `snapshot`, a base snapshot at the commit for the access's team and project, so
|
|
73
|
+
* nothing started.
|
|
74
|
+
* - `built`: it built `snapshot` in `ms` (`sizeBytes`), and the cache recorded it.
|
|
75
|
+
* - `not-cached`: it built `snapshot`, but the cache couldn't write its entry (`failure`), so no run finds it.
|
|
103
76
|
* - `failed`: a step, a Sandbox call or the checkout failed.
|
|
104
|
-
* - `aborted`: the signal aborted
|
|
105
|
-
*
|
|
106
|
-
* replacement still drops the dev snapshots on the base snapshot it replaced before the build stops.
|
|
107
|
-
*
|
|
108
|
-
* In `built`, `dev-snapshot-not-saved`, `not-cached`, and `aborted`, `baseSnapshot` is the base snapshot this build
|
|
109
|
-
* built, with whether the cache wrote its entry (`SavedBaseSnapshot`), null when it built none. In `built`,
|
|
110
|
-
* `not-cached`, and `aborted`, `dropped` is what `--full` dropped, null when it dropped nothing: without `--full`, or
|
|
111
|
-
* when the base snapshot it built isn't cached, so the one it replaces stays usable, and so do the dev snapshots built
|
|
112
|
-
* on it.
|
|
77
|
+
* - `aborted`: the signal aborted. A base snapshot's save runs to its end once started, so a signal during it still
|
|
78
|
+
* leaves a saved snapshot, which `snapshot` names with whether the cache wrote its entry; null when it saved none.
|
|
113
79
|
*/
|
|
114
80
|
export type SnapshotBuildEnd = {
|
|
115
81
|
readonly kind: "up-to-date";
|
|
116
82
|
readonly snapshot: RunnerSnapshotEntry;
|
|
117
83
|
} | {
|
|
118
84
|
readonly kind: "built";
|
|
119
|
-
readonly
|
|
120
|
-
readonly
|
|
121
|
-
readonly
|
|
122
|
-
readonly dropped: DevSnapshotDrop | null;
|
|
123
|
-
} | {
|
|
124
|
-
readonly kind: "dev-snapshot-not-saved";
|
|
125
|
-
readonly step: "scrub" | "save-snapshot";
|
|
126
|
-
readonly message: string;
|
|
127
|
-
readonly baseSnapshot: SavedBaseSnapshot | null;
|
|
85
|
+
readonly snapshot: RunnerSnapshotEntry;
|
|
86
|
+
readonly ms: number;
|
|
87
|
+
readonly sizeBytes: number;
|
|
128
88
|
} | {
|
|
129
89
|
readonly kind: "not-cached";
|
|
130
90
|
readonly snapshot: RunnerSnapshotEntry;
|
|
131
91
|
readonly failure: RunnerSnapshotCacheFailure;
|
|
132
|
-
readonly baseSnapshot: SavedBaseSnapshot | null;
|
|
133
|
-
readonly dropped: DevSnapshotDrop | null;
|
|
134
|
-
} | {
|
|
135
|
-
readonly kind: "snapshot-gone";
|
|
136
|
-
readonly entry: RunnerSnapshotEntry;
|
|
137
|
-
readonly removal: RunnerSnapshotCacheFailure | undefined;
|
|
138
92
|
} | {
|
|
139
93
|
readonly kind: "failed";
|
|
140
94
|
readonly failure: RunnerFailure;
|
|
141
95
|
} | {
|
|
142
96
|
readonly kind: "aborted";
|
|
143
|
-
readonly
|
|
144
|
-
|
|
97
|
+
readonly snapshot: {
|
|
98
|
+
readonly entry: RunnerSnapshotEntry;
|
|
99
|
+
readonly cached: boolean;
|
|
100
|
+
} | null;
|
|
145
101
|
};
|
|
146
|
-
/** A base snapshot a build built and saved: its entry, and whether the cache wrote it, so a run finds it. */
|
|
147
|
-
export interface SavedBaseSnapshot {
|
|
148
|
-
readonly entry: RunnerSnapshotEntry;
|
|
149
|
-
readonly cached: boolean;
|
|
150
|
-
}
|
|
151
|
-
/** A dev snapshot a build saved: the cache entry it wrote, how long the save took, and the snapshot's size. */
|
|
152
|
-
export interface SavedDevSnapshot {
|
|
153
|
-
readonly entry: RunnerSnapshotEntry;
|
|
154
|
-
readonly ms: number;
|
|
155
|
-
readonly sizeBytes: number;
|
|
156
|
-
}
|
|
157
102
|
/** How a build ended (`SnapshotBuildEnd`), with what closing its sandbox scope left (`cleanup`). */
|
|
158
103
|
export type SnapshotBuildOutcome = SnapshotBuildEnd & {
|
|
159
104
|
readonly cleanup: RunnerScopeFacts;
|
|
160
105
|
};
|
|
161
106
|
/**
|
|
162
|
-
* Builds
|
|
163
|
-
* keeping none.
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* saves no dev snapshot, any snapshot, it is up to date. Otherwise it obtains the start (`obtainSnapshot`), building a
|
|
168
|
-
* base snapshot at the merge-base when it chose to; under `full`, once the cache holds the new base snapshot's entry,
|
|
169
|
-
* it then drops the dev snapshots built on the base snapshot it replaced (`dropDevSnapshotsOn`), before any runner
|
|
170
|
-
* sandbox starts. A build that saves no dev snapshot ends there. Otherwise it readies a runner sandbox on the start
|
|
171
|
-
* (`readyRunner`) and saves it as a dev snapshot at HEAD's commit (`saveDevSnapshot`). For `--base`: a cached base
|
|
172
|
-
* snapshot of the commit for the access's team and project is up to date, unless `full`; otherwise it builds one, and
|
|
173
|
-
* under `full`, once its entry is cached, drops the dev snapshots built on the one it replaced. A base snapshot's save
|
|
174
|
-
* isn't stopped by the signal, so after it the build checks the signal once, after any drop, and ends `aborted` with
|
|
175
|
-
* what it saved.
|
|
107
|
+
* Builds the checked build's base snapshot, reporting to `progress`, and closes every sandbox it started however it
|
|
108
|
+
* ends, keeping none. A cached base snapshot at the commit for the access's team and project is up to date, unless
|
|
109
|
+
* `full`, which builds a new one that replaces its cache entry. `signal` stops it in any stage: it says so, then
|
|
110
|
+
* closes the scope at once. A base snapshot's save isn't stopped by the signal, so after it the build checks the signal
|
|
111
|
+
* once and ends `aborted` with what it saved.
|
|
176
112
|
*/
|
|
177
113
|
export declare function buildSnapshots(context: RunnerContext, request: BuildSnapshotsRequest, control: {
|
|
178
114
|
readonly signal: AbortSignal;
|
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
// `storm snapshots build`: building
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// resource, runs no command, and keeps no sandbox.
|
|
5
|
-
import {
|
|
6
|
-
import { obtainSnapshot, readyRunner } from "./ready.js";
|
|
1
|
+
// `storm snapshots build`: building one base snapshot that the runner snapshot cache lacks, with no run: at the
|
|
2
|
+
// merge-base by default, or at the commit `--base <ref>` names, which a run starts from only once that commit is its
|
|
3
|
+
// merge-base. It owns its sandbox scope from its first stage to its end, as a run's runner session does. It
|
|
4
|
+
// acquires no resource, runs no command, and keeps no sandbox.
|
|
5
|
+
import { resolveBase } from "./base.js";
|
|
7
6
|
import { runnerSandboxScope } from "./scope.js";
|
|
8
7
|
import { buildSnapshot } from "./snapshot-build.js";
|
|
9
|
-
import {
|
|
8
|
+
import { hasTimeLeft } from "./snapshot-cache.js";
|
|
10
9
|
import { snapshotStepsAt } from "./snapshot-key.js";
|
|
11
|
-
import { saveDevSnapshot } from "./snapshot-save.js";
|
|
12
|
-
import { chooseSnapshotStart } from "./snapshot-start.js";
|
|
13
10
|
/**
|
|
14
|
-
* Runs a build's local checks, before anything is minted or started
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* base
|
|
11
|
+
* Runs a build's local checks, before anything is minted or started: the repository's root, HEAD, the submodule
|
|
12
|
+
* refusal, HEAD's merge-base (`resolveBase`, which refuses with `no-base-ref` only without `--base`), the commit
|
|
13
|
+
* `--base` resolves to locally, the snapshot steps and key at the commit it builds, the cache's base snapshots of it,
|
|
14
|
+
* and, when it builds at the merge-base, HEAD's count of commits after it. It never mints, acquires or creates, and removes no cache file.
|
|
18
15
|
*/
|
|
19
16
|
export async function prepareSnapshotBuild(context, request) {
|
|
20
|
-
const { recipe, mode } = request;
|
|
21
|
-
if (mode.kind === "checkout") {
|
|
22
|
-
const prepared = await prepareRunner(context, {
|
|
23
|
-
cwd: request.cwd,
|
|
24
|
-
recipe,
|
|
25
|
-
vcpusRun: request.vcpusRun,
|
|
26
|
-
reuseDevSnapshots: recipe.reuseDevSnapshot,
|
|
27
|
-
});
|
|
28
|
-
if (prepared.kind !== "ok")
|
|
29
|
-
return prepared;
|
|
30
|
-
return { kind: "ok", build: { kind: "checkout", prepared: prepared.prepared, full: mode.full } };
|
|
31
|
-
}
|
|
32
17
|
const { checkout } = context;
|
|
18
|
+
const { recipe, ref } = request;
|
|
33
19
|
const root = await checkout.repositoryRoot({ cwd: request.cwd });
|
|
34
20
|
if (!root.ok)
|
|
35
21
|
return { kind: "checkout-failed", failure: root.failure };
|
|
@@ -37,47 +23,53 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
37
23
|
const head = await checkout.head({ repoRoot });
|
|
38
24
|
if (!head.ok)
|
|
39
25
|
return { kind: "checkout-failed", failure: head.failure };
|
|
26
|
+
const resolved = await resolveBase(checkout, { repoRoot, baseRefs: recipe.baseRefs });
|
|
27
|
+
if (resolved.kind === "failed")
|
|
28
|
+
return { kind: "checkout-failed", failure: resolved.failure };
|
|
29
|
+
const mergeBase = resolved.kind === "resolved" ? { commit: resolved.base, ref: resolved.ref } : null;
|
|
40
30
|
const submodules = await checkout.submodules({ repoRoot });
|
|
41
31
|
if (!submodules.ok)
|
|
42
32
|
return { kind: "checkout-failed", failure: submodules.failure };
|
|
43
33
|
if (submodules.value.length > 0)
|
|
44
34
|
return { kind: "submodules", paths: [...submodules.value] };
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
let base;
|
|
36
|
+
if (ref === undefined) {
|
|
37
|
+
if (resolved.kind !== "resolved")
|
|
38
|
+
return resolved;
|
|
39
|
+
base = resolved.base;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const commit = await checkout.resolveCommit({ repoRoot, ref });
|
|
43
|
+
if (!commit.ok)
|
|
44
|
+
return { kind: "checkout-failed", failure: commit.failure };
|
|
45
|
+
if (commit.value === null)
|
|
46
|
+
return { kind: "ref-not-found", ref };
|
|
47
|
+
base = commit.value;
|
|
48
|
+
}
|
|
51
49
|
const steps = await snapshotStepsAt(checkout, { repoRoot, base, recipe });
|
|
52
50
|
if (!steps.ok)
|
|
53
51
|
return { kind: "invalid-recipe", path: steps.path, problem: steps.problem };
|
|
54
52
|
// An unreadable cache holds nothing to reuse: the build goes on, and builds.
|
|
55
53
|
const listed = await context.runnerSnapshots.listEntries();
|
|
56
54
|
const now = context.clock.now();
|
|
57
|
-
const cached = (listed.ok ? listed.value.entries : []).filter((entry) =>
|
|
58
|
-
entry.base === base &&
|
|
55
|
+
const cached = (listed.ok ? listed.value.entries : []).filter((entry) => entry.base === base &&
|
|
59
56
|
entry.recipeName === recipe.name &&
|
|
60
57
|
entry.region === recipe.region &&
|
|
61
58
|
entry.runtime === recipe.runtime &&
|
|
62
59
|
entry.snapshotKey === steps.key &&
|
|
63
60
|
hasTimeLeft(entry, now));
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
const atMergeBase = base === mergeBase?.commit;
|
|
62
|
+
// The built snapshot's count behind HEAD, for a build at the merge-base, the one snapshot a run here starts from.
|
|
63
|
+
let commitsAfterBase = null;
|
|
64
|
+
if (atMergeBase) {
|
|
65
|
+
const counted = await checkout.commitCount({ repoRoot, from: base, to: "HEAD" });
|
|
66
|
+
if (!counted.ok)
|
|
67
|
+
return { kind: "checkout-failed", failure: counted.failure };
|
|
68
|
+
commitsAfterBase = counted.value;
|
|
72
69
|
}
|
|
73
|
-
if (!onBaseRef)
|
|
74
|
-
warnings.push({ kind: "not-on-base-ref", refs: recipe.baseRefs });
|
|
75
|
-
const inHistory = await checkout.contains({ repoRoot, ancestor: base, descendant: "HEAD" });
|
|
76
|
-
const afterBase = inHistory.ok && inHistory.value ? await checkout.commitCount({ repoRoot, from: base, to: "HEAD" }) : undefined;
|
|
77
70
|
return {
|
|
78
71
|
kind: "ok",
|
|
79
72
|
build: {
|
|
80
|
-
kind: "base",
|
|
81
73
|
plan: {
|
|
82
74
|
recipe,
|
|
83
75
|
repoRoot,
|
|
@@ -85,37 +77,27 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
85
77
|
toolchains: steps.toolchains,
|
|
86
78
|
prebuild: steps.prebuild,
|
|
87
79
|
snapshotKey: steps.key,
|
|
88
|
-
commitsAfterBase
|
|
80
|
+
commitsAfterBase,
|
|
89
81
|
},
|
|
90
|
-
ref: mode.ref,
|
|
91
82
|
head: head.value,
|
|
83
|
+
ref: ref ?? null,
|
|
84
|
+
mergeBase,
|
|
85
|
+
atMergeBase,
|
|
92
86
|
cached,
|
|
93
|
-
full:
|
|
94
|
-
warnings,
|
|
87
|
+
full: request.full,
|
|
95
88
|
},
|
|
96
89
|
};
|
|
97
90
|
}
|
|
98
|
-
/** A build that stopped on the signal before it saved anything. */
|
|
99
|
-
const ABORTED_EARLY = { kind: "aborted", baseSnapshot: null, dropped: null };
|
|
100
91
|
/**
|
|
101
|
-
* Builds
|
|
102
|
-
* keeping none.
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* saves no dev snapshot, any snapshot, it is up to date. Otherwise it obtains the start (`obtainSnapshot`), building a
|
|
107
|
-
* base snapshot at the merge-base when it chose to; under `full`, once the cache holds the new base snapshot's entry,
|
|
108
|
-
* it then drops the dev snapshots built on the base snapshot it replaced (`dropDevSnapshotsOn`), before any runner
|
|
109
|
-
* sandbox starts. A build that saves no dev snapshot ends there. Otherwise it readies a runner sandbox on the start
|
|
110
|
-
* (`readyRunner`) and saves it as a dev snapshot at HEAD's commit (`saveDevSnapshot`). For `--base`: a cached base
|
|
111
|
-
* snapshot of the commit for the access's team and project is up to date, unless `full`; otherwise it builds one, and
|
|
112
|
-
* under `full`, once its entry is cached, drops the dev snapshots built on the one it replaced. A base snapshot's save
|
|
113
|
-
* isn't stopped by the signal, so after it the build checks the signal once, after any drop, and ends `aborted` with
|
|
114
|
-
* what it saved.
|
|
92
|
+
* Builds the checked build's base snapshot, reporting to `progress`, and closes every sandbox it started however it
|
|
93
|
+
* ends, keeping none. A cached base snapshot at the commit for the access's team and project is up to date, unless
|
|
94
|
+
* `full`, which builds a new one that replaces its cache entry. `signal` stops it in any stage: it says so, then
|
|
95
|
+
* closes the scope at once. A base snapshot's save isn't stopped by the signal, so after it the build checks the signal
|
|
96
|
+
* once and ends `aborted` with what it saved.
|
|
115
97
|
*/
|
|
116
98
|
export async function buildSnapshots(context, request, control, progress) {
|
|
117
99
|
const { signal } = control;
|
|
118
|
-
const scope = runnerSandboxScope(context, progress, { keepMs:
|
|
100
|
+
const scope = runnerSandboxScope(context, progress, { keepMs: 0 });
|
|
119
101
|
const stop = () => {
|
|
120
102
|
void progress.emit({ kind: "stopping", commandRunning: false, keepMs: 0 }).catch(() => undefined);
|
|
121
103
|
void scope.close().catch(() => undefined);
|
|
@@ -139,97 +121,26 @@ async function buildIn(context, request, control, progress) {
|
|
|
139
121
|
const { build, access, user, secrets } = request;
|
|
140
122
|
const { signal } = control;
|
|
141
123
|
if (signal.aborted)
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const {
|
|
159
|
-
const start = build.full
|
|
160
|
-
? { kind: "build", why: { kind: "full" } }
|
|
161
|
-
: chooseSnapshotStart(prepared, access);
|
|
162
|
-
if (start.kind === "reuse") {
|
|
163
|
-
const { entry } = start.candidate;
|
|
164
|
-
if (isDevEntry(entry) && entry.head === prepared.head.commit && !prepared.head.dirty)
|
|
165
|
-
return { kind: "up-to-date", snapshot: entry };
|
|
166
|
-
// A build that saves no dev snapshot needs only a snapshot that fits.
|
|
167
|
-
if (prepared.devSnapshots !== "reuse")
|
|
168
|
-
return { kind: "up-to-date", snapshot: entry };
|
|
169
|
-
}
|
|
170
|
-
const obtained = await obtainSnapshot(context, { prepared, access, user, secrets, start }, control, progress);
|
|
171
|
-
if (obtained.kind === "aborted")
|
|
172
|
-
return ABORTED_EARLY;
|
|
173
|
-
if (obtained.kind !== "ok")
|
|
174
|
-
return obtained;
|
|
175
|
-
const { built } = obtained.value;
|
|
176
|
-
// The base snapshot this build built, if any. Only a cached one replaces the old one.
|
|
177
|
-
const baseSnapshot = built === null ? null : savedBaseOf(built);
|
|
178
|
-
const dropped = build.full && baseSnapshot?.cached === true ? await dropOn(context, baseSnapshot.entry, progress) : null;
|
|
179
|
-
const aborted = { kind: "aborted", baseSnapshot, dropped };
|
|
124
|
+
return { kind: "aborted", snapshot: null };
|
|
125
|
+
const cached = build.cached.find((entry) => entry.teamId === access.teamId && entry.projectId === access.projectId);
|
|
126
|
+
if (!build.full && cached !== undefined)
|
|
127
|
+
return { kind: "up-to-date", snapshot: cached };
|
|
128
|
+
const why = build.full ? "full" : build.ref === null ? "no-snapshot" : "base";
|
|
129
|
+
const built = await buildSnapshot(context, {
|
|
130
|
+
prepared: build.plan,
|
|
131
|
+
access,
|
|
132
|
+
user,
|
|
133
|
+
secrets,
|
|
134
|
+
why: why === "no-snapshot" ? { kind: why, rejected: [] } : { kind: why },
|
|
135
|
+
}, control, progress);
|
|
136
|
+
if (built.kind === "aborted")
|
|
137
|
+
return { kind: "aborted", snapshot: null };
|
|
138
|
+
if (built.kind !== "ok")
|
|
139
|
+
return built;
|
|
140
|
+
const { entry, cacheFailure, ms, sizeBytes } = built.value;
|
|
180
141
|
if (signal.aborted)
|
|
181
|
-
return aborted;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const ready = await readyRunner(context, { prepared, access, user, secrets, start: obtained.value }, control, progress);
|
|
186
|
-
if (ready.kind === "aborted")
|
|
187
|
-
return aborted;
|
|
188
|
-
if (ready.kind !== "ready")
|
|
189
|
-
return ready;
|
|
190
|
-
const { runner } = ready;
|
|
191
|
-
const saved = await saveDevSnapshot(context, { ready: runner, branch: prepared.head.branch, head: prepared.head.commit }, control, progress);
|
|
192
|
-
if (saved.entry === null) {
|
|
193
|
-
const { save } = saved;
|
|
194
|
-
// Only a signal stops a save: its handler is what closes the scope.
|
|
195
|
-
return save.kind === "stopped"
|
|
196
|
-
? aborted
|
|
197
|
-
: { kind: "dev-snapshot-not-saved", step: save.step, message: save.message, baseSnapshot };
|
|
198
|
-
}
|
|
199
|
-
const { entry, cacheFailure, save } = saved;
|
|
200
|
-
if (cacheFailure !== null)
|
|
201
|
-
return { kind: "not-cached", snapshot: entry, failure: cacheFailure, baseSnapshot, dropped };
|
|
202
|
-
return {
|
|
203
|
-
kind: "built",
|
|
204
|
-
baseSnapshot,
|
|
205
|
-
startedFrom: runner.startedFrom,
|
|
206
|
-
devSnapshot: { entry, ms: save.ms, sizeBytes: save.sizeBytes },
|
|
207
|
-
dropped,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
/** A base snapshot this build built, and whether the cache wrote its entry. */
|
|
211
|
-
function savedBaseOf(built) {
|
|
212
|
-
return { entry: built.entry, cached: built.cacheFailure === null };
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* How a build that saves no dev snapshot ends once it built base snapshot `built`: `built` when the cache wrote its
|
|
216
|
-
* entry, else `not-cached`, since no run finds it. It takes the base snapshot it built, never one it reused.
|
|
217
|
-
*/
|
|
218
|
-
function baseOnlyEnd(built, dropped) {
|
|
219
|
-
const baseSnapshot = savedBaseOf(built);
|
|
220
|
-
return built.cacheFailure === null
|
|
221
|
-
? { kind: "built", baseSnapshot, startedFrom: null, devSnapshot: null, dropped }
|
|
222
|
-
: { kind: "not-cached", snapshot: built.entry, failure: built.cacheFailure, baseSnapshot, dropped };
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Drops the dev snapshots built on the base snapshot `built` replaced, the cache entry of the same identity, and
|
|
226
|
-
* reports what it dropped and what it couldn't.
|
|
227
|
-
*/
|
|
228
|
-
async function dropOn(context, built, progress) {
|
|
229
|
-
const dropped = await dropDevSnapshotsOn(context, built);
|
|
230
|
-
if (dropped.snapshotIds.length > 0)
|
|
231
|
-
await progress.emit({ kind: "dev-snapshots-dropped", snapshotIds: dropped.snapshotIds });
|
|
232
|
-
for (const { message } of dropped.failures)
|
|
233
|
-
await progress.emit({ kind: "dev-snapshots-not-dropped", message });
|
|
234
|
-
return dropped;
|
|
142
|
+
return { kind: "aborted", snapshot: { entry, cached: cacheFailure === null } };
|
|
143
|
+
return cacheFailure === null
|
|
144
|
+
? { kind: "built", snapshot: entry, ms, sizeBytes }
|
|
145
|
+
: { kind: "not-cached", snapshot: entry, failure: cacheFailure };
|
|
235
146
|
}
|