@cnc-tools/storm 0.16.0 → 0.17.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.d.ts +22 -13
- package/dist/application.js +21 -10
- package/dist/bin/run.d.ts +18 -0
- package/dist/bin/run.js +31 -0
- package/dist/bin/storm.js +42 -26
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
- package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
- package/dist/chunks/{chunk-P357TZAY.js → chunk-4O5C2XGJ.js} +18 -15
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-6UHIJXZG.js} +3 -3
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-7DZE67QM.js} +2 -2
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-CKGZA25H.js} +1 -18
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-DADEYJDW.js} +24 -17
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/chunk-F4MOYHRY.js +198 -0
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FNBB6V4R.js} +1 -1
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-GRT3UIBV.js} +18 -1
- package/dist/chunks/chunk-HP3CURSZ.js +88 -0
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-HWIQ2S7K.js} +5 -5
- package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-M7EKRGVD.js} +8 -8
- package/dist/chunks/chunk-MR77L2GK.js +340 -0
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-RNAS7JHE.js} +1438 -445
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-RWIXDDCK.js} +4 -189
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-YEPFSLQR.js} +480 -375
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-R76JQXZL.js} +15 -13
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
- package/dist/commands/exec/across-sandboxes-outcomes.js +2 -2
- package/dist/commands/exec/before-run.d.ts +123 -0
- package/dist/commands/exec/before-run.js +105 -0
- package/dist/commands/exec/command.d.ts +31 -2
- package/dist/commands/exec/command.js +31 -95
- package/dist/commands/exec/driver-plan.d.ts +9 -4
- package/dist/commands/exec/driver-plan.js +8 -8
- package/dist/commands/exec/exec-words.js +1 -1
- package/dist/commands/exec/execute-run.d.ts +39 -0
- package/dist/commands/exec/execute-run.js +325 -0
- package/dist/commands/exec/live-view.d.ts +3 -3
- package/dist/commands/exec/live-view.js +16 -15
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/mint-failed.d.ts +38 -0
- package/dist/commands/exec/mint-failed.js +27 -4
- package/dist/commands/exec/outcomes.d.ts +34 -8
- package/dist/commands/exec/outcomes.js +30 -23
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +232 -88
- package/dist/commands/exec/progress.d.ts +10 -6
- package/dist/commands/exec/progress.js +38 -25
- package/dist/commands/exec/run-bin.d.ts +11 -11
- package/dist/commands/exec/run-bin.js +9 -9
- package/dist/commands/exec/run-flags.d.ts +69 -0
- package/dist/commands/exec/run-flags.js +58 -0
- package/dist/commands/exec/run-metadata.js +4 -4
- package/dist/commands/exec/run-summary.d.ts +58 -0
- package/dist/commands/exec/run-summary.js +205 -0
- package/dist/commands/exec/runner-refusals.d.ts +82 -0
- package/dist/commands/exec/runner-refusals.js +71 -0
- package/dist/commands/exec/sandbox-progress.js +3 -0
- package/dist/commands/exec/stopped-outcome.d.ts +12 -0
- package/dist/commands/exec/stopped-outcome.js +77 -0
- package/dist/commands/exec/view.d.ts +20 -11
- package/dist/commands/exec/view.js +103 -47
- package/dist/commands/runs/facts.d.ts +7 -3
- package/dist/commands/runs/facts.js +17 -8
- package/dist/commands/runs/list/command.d.ts +14 -6
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +7 -3
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +14 -6
- package/dist/commands/runs/show/command.js +30 -28
- package/dist/commands/runs/show/outcomes.d.ts +7 -3
- package/dist/commands/runs/show/outcomes.js +7 -5
- package/dist/commands/snapshots/access.d.ts +111 -0
- package/dist/commands/snapshots/access.js +96 -0
- package/dist/commands/snapshots/build/command.d.ts +360 -93
- package/dist/commands/snapshots/build/command.js +446 -150
- package/dist/commands/snapshots/build/metadata.d.ts +10 -0
- package/dist/commands/snapshots/build/metadata.js +31 -11
- package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +366 -25
- package/dist/commands/snapshots/list/command.js +296 -66
- package/dist/commands/snapshots/list/metadata.d.ts +16 -0
- package/dist/commands/snapshots/list/metadata.js +29 -6
- package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
- package/dist/commands/snapshots/list/outcomes.js +221 -50
- package/dist/commands/snapshots/metadata.js +1 -1
- package/dist/commands/snapshots/prune/command.d.ts +430 -0
- package/dist/commands/snapshots/prune/command.js +161 -0
- package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
- package/dist/commands/snapshots/prune/metadata.js +39 -0
- package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
- package/dist/commands/snapshots/prune/outcomes.js +78 -0
- package/dist/commands/suites/list/command.js +17 -17
- package/dist/commands/suites/list/outcomes.js +2 -2
- package/dist/commands/test/command.d.ts +31 -2
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +15 -1
- package/dist/config/check-runner.d.ts +3 -3
- package/dist/config/check-runner.js +8 -7
- package/dist/config/credential-resolver.d.ts +50 -5
- package/dist/config/credential-resolver.js +51 -19
- package/dist/config/credential-settle.d.ts +6 -2
- package/dist/config/credential-settle.js +11 -5
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/config/runner.d.ts +5 -5
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +1 -1
- package/dist/config-file/define.d.ts +1 -1
- package/dist/config-file/define.js +1 -1
- package/dist/config-file/runner.d.ts +5 -5
- package/dist/config-file/toolchain.d.ts +1 -1
- package/dist/config-file/toolchain.js +2 -2
- package/dist/context.d.ts +8 -6
- package/dist/context.js +7 -6
- package/dist/core/across-sandboxes.d.ts +7 -6
- package/dist/core/across-sandboxes.js +123 -152
- package/dist/core/coordinator.d.ts +166 -0
- package/dist/core/coordinator.js +233 -0
- package/dist/core/events.d.ts +2 -2
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +1 -1
- package/dist/core/outcomes.d.ts +148 -0
- package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
- package/dist/core/resources.d.ts +31 -53
- package/dist/core/resources.js +32 -70
- package/dist/core/run-state.d.ts +7 -1
- package/dist/core/run-state.js +2 -0
- package/dist/core/run.d.ts +32 -236
- package/dist/core/run.js +106 -266
- package/dist/core/state-directory.d.ts +1 -1
- package/dist/core/state-directory.js +2 -2
- package/dist/credential/gateways.d.ts +15 -1
- package/dist/credential/index.d.ts +4 -3
- package/dist/credential/index.js +3 -2
- package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
- package/dist/credential/live/vercel-cli-gateway.js +1 -1
- package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
- package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
- package/dist/credential/source.d.ts +73 -6
- package/dist/credential/source.js +55 -2
- package/dist/extension-commands.d.ts +6 -1
- package/dist/extension-commands.js +15 -1
- package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
- package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
- package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
- package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
- package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
- package/dist/extensions/testserver/credential-facts.d.ts +6 -2
- package/dist/extensions/testserver/credential-facts.js +29 -11
- package/dist/extensions/testserver/lifecycle.js +7 -1
- package/dist/extensions/testserver/limit.d.ts +3 -0
- package/dist/extensions/testserver/limit.js +3 -0
- package/dist/extensions/testserver/provision.d.ts +8 -1
- package/dist/extensions/testserver/provision.js +8 -3
- package/dist/extensions/testserver/refusals.d.ts +6 -1
- package/dist/extensions/testserver/refusals.js +16 -1
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/resource.js +1 -1
- package/dist/extensions/testserver/result.d.ts +1 -1
- package/dist/extensions/testserver/result.js +9 -4
- package/dist/planning/driver-file-lists.d.ts +0 -15
- package/dist/planning/driver-file-lists.js +2 -21
- package/dist/planning/plan-only.d.ts +3 -14
- package/dist/planning/plan-only.js +11 -20
- package/dist/planning/run-kind-flags.js +2 -2
- package/dist/planning/run-plan.d.ts +45 -12
- package/dist/planning/run-plan.js +4 -3
- package/dist/planning/suites.d.ts +1 -1
- package/dist/planning/suites.js +2 -2
- package/dist/planning/test-plan.d.ts +9 -0
- package/dist/planning/test-plan.js +9 -0
- package/dist/run-directory/recording.js +2 -2
- package/dist/run-directory/run-record.d.ts +21 -6
- package/dist/run-directory/run-record.js +12 -9
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +55 -29
- package/dist/runner/build-snapshots.js +130 -29
- package/dist/runner/context.d.ts +15 -7
- package/dist/runner/context.js +19 -6
- package/dist/runner/events.d.ts +16 -10
- package/dist/runner/gateways.d.ts +87 -21
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/index.d.ts +11 -7
- package/dist/runner/index.js +9 -4
- package/dist/runner/live/sandbox-errors.d.ts +2 -0
- package/dist/runner/live/sandbox-errors.js +4 -0
- package/dist/runner/live/sandbox-gateway.js +129 -3
- package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
- package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
- package/dist/runner/live/snapshot-records.js +6 -7
- package/dist/runner/local-snapshot-index.d.ts +199 -0
- package/dist/runner/local-snapshot-index.js +211 -0
- package/dist/runner/network-policy.d.ts +6 -6
- package/dist/runner/network-policy.js +7 -7
- package/dist/runner/policy-writes.d.ts +1 -1
- package/dist/runner/policy-writes.js +1 -1
- package/dist/runner/prepare.d.ts +14 -14
- package/dist/runner/prepare.js +20 -11
- package/dist/runner/ready.d.ts +18 -10
- package/dist/runner/ready.js +104 -33
- package/dist/runner/sandboxed-command.d.ts +3 -3
- package/dist/runner/sandboxed-command.js +3 -3
- package/dist/runner/scope.d.ts +10 -6
- package/dist/runner/scope.js +10 -3
- package/dist/runner/secrets.d.ts +13 -13
- package/dist/runner/secrets.js +18 -15
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +3 -3
- package/dist/runner/shared-snapshot-entry.d.ts +92 -0
- package/dist/runner/shared-snapshot-entry.js +168 -0
- package/dist/runner/shared-snapshot-list.d.ts +81 -0
- package/dist/runner/shared-snapshot-list.js +155 -0
- package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
- package/dist/runner/shared-snapshot-lookup.js +118 -0
- package/dist/runner/shared-snapshot-prune.d.ts +58 -0
- package/dist/runner/shared-snapshot-prune.js +133 -0
- package/dist/runner/snapshot-build.d.ts +42 -14
- package/dist/runner/snapshot-build.js +32 -29
- package/dist/runner/snapshot-choice.js +1 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +55 -35
- package/dist/runner/snapshot-key.d.ts +13 -12
- package/dist/runner/snapshot-key.js +13 -12
- package/dist/runner/steps.d.ts +1 -1
- package/dist/runner/steps.js +1 -1
- package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +24 -23
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +70 -69
- package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
- package/dist/sdk/extension/commands.d.ts +8 -3
- package/dist/sdk/extension/commands.js +3 -1
- package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
- package/dist/sdk/extension/credential-diagnosis.js +25 -5
- package/dist/sdk/extension/credential-source.d.ts +20 -3
- package/dist/sdk/extension/credential-source.js +4 -4
- package/dist/sdk/extension/index.d.ts +3 -2
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +1 -1
- package/dist/sdk/extension/secret-source.d.ts +1 -1
- package/dist/sdk/extension/secret-source.js +1 -1
- package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
- package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
- package/dist/shared/cleanup.d.ts +3 -3
- package/dist/shared/cleanup.js +15 -5
- package/dist/shared/snapshot-text.d.ts +4 -4
- package/dist/shared/snapshot-text.js +11 -11
- package/dist/time/duration.js +1 -1
- package/package.json +3 -2
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- package/dist/chunks/chunk-7EENF73W.js +0 -782
- package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
- package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
- package/dist/commands/exec/across-sandboxes-run.js +0 -339
- package/dist/commands/exec/plan-only.d.ts +0 -10
- package/dist/commands/exec/plan-only.js +0 -45
- package/dist/commands/exec/run-command.d.ts +0 -475
- package/dist/commands/exec/run-command.js +0 -603
- package/dist/commands/exec/run-planned.d.ts +0 -20
- package/dist/commands/exec/run-planned.js +0 -22
- package/dist/commands/exec/sandbox-view.d.ts +0 -19
- package/dist/commands/exec/sandbox-view.js +0 -72
- package/dist/commands/test/plan.d.ts +0 -92
- package/dist/commands/test/plan.js +0 -125
- package/dist/core/sandbox-end.d.ts +0 -64
- package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
- package/dist/runner/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import type { SandboxCredential } from "../sdk/extension/index.ts";
|
|
2
|
-
import type
|
|
2
|
+
import { type RunnerContext } from "./context.ts";
|
|
3
3
|
import type { RunnerFailure, RunnerProgress } from "./events.ts";
|
|
4
|
-
import type { CheckoutHead,
|
|
4
|
+
import type { CheckoutHead, RunnerSnapshotEntry, RunnerSnapshotIndexFailure, SandboxAccess } from "./gateways.ts";
|
|
5
5
|
import type { PrepareRunnerOutcome, RunnerPrepareContext } from "./prepare.ts";
|
|
6
|
-
import type {
|
|
6
|
+
import type { CheckedVercelSandboxOptions } from "./vercel-sandbox-options.ts";
|
|
7
7
|
import { type RunnerScopeFacts } from "./scope.ts";
|
|
8
|
-
import { type
|
|
9
|
-
/** What `prepareSnapshotBuild` checks: where, which
|
|
8
|
+
import { type RunnerSnapshotPlan } from "./snapshot-build.ts";
|
|
9
|
+
/** What `prepareSnapshotBuild` checks: where, which runner, and what to build. */
|
|
10
10
|
export interface SnapshotBuildRequest {
|
|
11
11
|
/** The directory the command started in, inside the checkout. */
|
|
12
12
|
readonly cwd: string;
|
|
13
|
-
readonly
|
|
13
|
+
readonly options: CheckedVercelSandboxOptions;
|
|
14
14
|
/** The ref `--base` names; undefined builds at the merge-base. */
|
|
15
15
|
readonly ref: string | undefined;
|
|
16
|
-
/** `--full`: build whatever the
|
|
16
|
+
/** `--full`: build whatever the local snapshot index holds. */
|
|
17
17
|
readonly full: boolean;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* A build, checked on this machine: the
|
|
21
|
-
* has uncommitted changes, which a
|
|
22
|
-
* merge-base and its ref (null for a `--base` build in a checkout where no base ref shares history with HEAD),
|
|
23
|
-
* the commit it builds at is that merge-base (`atMergeBase
|
|
24
|
-
*
|
|
25
|
-
*
|
|
20
|
+
* A build, checked on this machine: the runner snapshot it builds (`plan`), HEAD, whose `dirty` says the working tree
|
|
21
|
+
* has uncommitted changes, which a runner snapshot doesn't hold, the ref `--base` named (null for the merge-base),
|
|
22
|
+
* HEAD's merge-base and its ref (null for a `--base` build in a checkout where no base ref shares history with HEAD),
|
|
23
|
+
* whether the commit it builds at is that merge-base (`atMergeBase`) or an ancestor of it (`ancestorOfMergeBase`, false
|
|
24
|
+
* at the merge-base itself: a run here starts only from a snapshot at its merge-base or at a commit behind it on the
|
|
25
|
+
* base ref, though a run in another checkout, or after a later merge-base, still might), and the runner snapshots of
|
|
26
|
+
* `plan`'s base and key the local snapshot index holds with more than an hour left (`indexed`, at exactly that base,
|
|
27
|
+
* before the team and project filter).
|
|
26
28
|
*/
|
|
27
29
|
export interface PreparedSnapshotBuild {
|
|
28
|
-
readonly plan:
|
|
30
|
+
readonly plan: RunnerSnapshotPlan;
|
|
29
31
|
readonly head: CheckoutHead;
|
|
30
32
|
readonly ref: string | null;
|
|
31
33
|
readonly mergeBase: {
|
|
@@ -33,11 +35,12 @@ export interface PreparedSnapshotBuild {
|
|
|
33
35
|
readonly ref: string;
|
|
34
36
|
} | null;
|
|
35
37
|
readonly atMergeBase: boolean;
|
|
36
|
-
readonly
|
|
38
|
+
readonly ancestorOfMergeBase: boolean;
|
|
39
|
+
readonly indexed: readonly RunnerSnapshotEntry[];
|
|
37
40
|
readonly full: boolean;
|
|
38
41
|
}
|
|
39
42
|
/**
|
|
40
|
-
* How a build's local checks ended: a run's refusals,
|
|
43
|
+
* How a build's local checks ended: a run's refusals, including `submodules`, `invalid-runner`, and `checkout-failed`
|
|
41
44
|
* that the build shares, or `ref-not-found` when `--base` names no local commit.
|
|
42
45
|
*/
|
|
43
46
|
export type PrepareSnapshotBuildOutcome = {
|
|
@@ -53,7 +56,8 @@ export type PrepareSnapshotBuildOutcome = {
|
|
|
53
56
|
* Runs a build's local checks, before anything is minted or started: the repository's root, HEAD, the submodule
|
|
54
57
|
* refusal, HEAD's merge-base (`resolveBase`, which refuses with `no-base-ref` only without `--base`), the commit
|
|
55
58
|
* `--base` resolves to locally, the snapshot steps and key at the commit it builds, the cache's base snapshots of it,
|
|
56
|
-
*
|
|
59
|
+
* whether a commit other than the merge-base is an ancestor of it, and, when it builds at the merge-base, HEAD's count
|
|
60
|
+
* of commits after it. It never mints, acquires or creates, and removes no cache file.
|
|
57
61
|
*/
|
|
58
62
|
export declare function prepareSnapshotBuild(context: RunnerPrepareContext, request: SnapshotBuildRequest): Promise<PrepareSnapshotBuildOutcome>;
|
|
59
63
|
/** What `buildSnapshots` is handed: the checked build, where its sandboxes run, who starts them, and the credentials. */
|
|
@@ -63,32 +67,52 @@ export interface BuildSnapshotsRequest {
|
|
|
63
67
|
readonly access: SandboxAccess;
|
|
64
68
|
/** The local user, for each sandbox's `user` tag. */
|
|
65
69
|
readonly user: string;
|
|
66
|
-
/** The
|
|
70
|
+
/** The runner's credentials, with their values: the firewall adds every one while the runner's snapshot steps run. */
|
|
67
71
|
readonly credentials: readonly Required<SandboxCredential>[];
|
|
72
|
+
/**
|
|
73
|
+
* `--publish`: check the shared snapshot index instead of the local snapshot index, and publish the build there,
|
|
74
|
+
* keeping its build sandbox stopped under the index entry's name. By default it neither reads nor writes the shared
|
|
75
|
+
* snapshot index.
|
|
76
|
+
*/
|
|
77
|
+
readonly publish?: boolean;
|
|
68
78
|
}
|
|
69
79
|
/**
|
|
70
80
|
* How a build ended, before its sandbox scope closed.
|
|
71
81
|
*
|
|
72
|
-
* - `up-to-date`: the
|
|
73
|
-
* nothing started.
|
|
74
|
-
*
|
|
75
|
-
* - `
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
82
|
+
* - `up-to-date`: the local snapshot index holds `snapshot`, a runner snapshot at the commit for the access's team and
|
|
83
|
+
* project, so nothing started. With `publish`, the shared snapshot index holds it instead, in the stopped sandbox
|
|
84
|
+
* `sandboxName`, and the local snapshot index now records it too, unless the write failed.
|
|
85
|
+
* - `built`: it built `snapshot` in `ms` (`sizeBytes`), and the local snapshot index recorded it. With `publish`, the
|
|
86
|
+
* shared snapshot index holds it in the stopped sandbox `sandboxName`, so a local snapshot index entry that couldn't
|
|
87
|
+
* be written (`localIndexFailure`) doesn't fail the build: a run finds the snapshot in the shared snapshot index.
|
|
88
|
+
* - `already-building`: with `publish`, the index entry's sandbox `sandboxName` already exists with a status a build
|
|
89
|
+
* still owns (`status`; null when another build took the name first while this one started), so nothing started.
|
|
90
|
+
* - `not-indexed`: it built `snapshot`, but the local snapshot index couldn't write its entry (`failure`), so no run
|
|
91
|
+
* finds it.
|
|
92
|
+
* - `failed`: a step, a Sandbox call, or the checkout failed.
|
|
93
|
+
* - `aborted`: the signal aborted. A runner snapshot's save runs to its end once started, so a signal during it still
|
|
94
|
+
* leaves a saved snapshot, which `snapshot` names with whether the local snapshot index wrote its entry; null when it
|
|
95
|
+
* saved none.
|
|
79
96
|
*/
|
|
80
97
|
export type SnapshotBuildEnd = {
|
|
81
98
|
readonly kind: "up-to-date";
|
|
82
99
|
readonly snapshot: RunnerSnapshotEntry;
|
|
100
|
+
readonly sandboxName?: string;
|
|
83
101
|
} | {
|
|
84
102
|
readonly kind: "built";
|
|
85
103
|
readonly snapshot: RunnerSnapshotEntry;
|
|
86
104
|
readonly ms: number;
|
|
87
105
|
readonly sizeBytes: number;
|
|
106
|
+
readonly sandboxName?: string;
|
|
107
|
+
readonly localIndexFailure?: RunnerSnapshotIndexFailure;
|
|
88
108
|
} | {
|
|
89
|
-
readonly kind: "
|
|
109
|
+
readonly kind: "already-building";
|
|
110
|
+
readonly sandboxName: string;
|
|
111
|
+
readonly status: string | null;
|
|
112
|
+
} | {
|
|
113
|
+
readonly kind: "not-indexed";
|
|
90
114
|
readonly snapshot: RunnerSnapshotEntry;
|
|
91
|
-
readonly failure:
|
|
115
|
+
readonly failure: RunnerSnapshotIndexFailure;
|
|
92
116
|
} | {
|
|
93
117
|
readonly kind: "failed";
|
|
94
118
|
readonly failure: RunnerFailure;
|
|
@@ -96,7 +120,7 @@ export type SnapshotBuildEnd = {
|
|
|
96
120
|
readonly kind: "aborted";
|
|
97
121
|
readonly snapshot: {
|
|
98
122
|
readonly entry: RunnerSnapshotEntry;
|
|
99
|
-
readonly
|
|
123
|
+
readonly indexed: boolean;
|
|
100
124
|
} | null;
|
|
101
125
|
};
|
|
102
126
|
/** How a build ended (`SnapshotBuildEnd`), with what closing its sandbox scope left (`cleanup`). */
|
|
@@ -108,7 +132,9 @@ export type SnapshotBuildOutcome = SnapshotBuildEnd & {
|
|
|
108
132
|
* ends, keeping none. A cached base snapshot at the commit for the access's team and project is up to date, unless
|
|
109
133
|
* `full`, which builds a new one that replaces its cache entry. `signal` cancels it in any stage: the scope says so,
|
|
110
134
|
* revokes every credential at once, and stops its sandboxes. A base snapshot's save isn't stopped by the signal, so
|
|
111
|
-
* after it the build checks the signal once and ends `aborted` with what it saved.
|
|
135
|
+
* after it the build checks the signal once and ends `aborted` with what it saved. With `publish`, it checks the shared
|
|
136
|
+
* snapshot index instead of the cache (`publishIn`), and the build sandbox it saves stays in the project, stopped, as
|
|
137
|
+
* the index entry.
|
|
112
138
|
*/
|
|
113
139
|
export declare function buildSnapshots(context: RunnerContext, request: BuildSnapshotsRequest, control: {
|
|
114
140
|
readonly signal: AbortSignal;
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
// `storm snapshots build`: building one
|
|
1
|
+
// `storm snapshots build`: building one runner snapshot that the local snapshot index lacks, with no run: at the
|
|
2
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
|
|
4
|
-
// acquires no resource, runs no command, and keeps no sandbox.
|
|
3
|
+
// merge-base or an ancestor of its merge-base. It owns its sandbox scope from its first stage to its end, as a run's
|
|
4
|
+
// runner session does. It acquires no resource, runs no command, and keeps no running sandbox. With `publish`, it also
|
|
5
|
+
// publishes the build to the shared snapshot index: the build sandbox takes the index entry's name and stays in the
|
|
6
|
+
// project, stopped.
|
|
5
7
|
import { resolveBase } from "./base.js";
|
|
8
|
+
import { snapshotIndexTags } from "./context.js";
|
|
9
|
+
import { hasTimeLeft, SNAPSHOT_EXPIRATION_MS } from "./local-snapshot-index.js";
|
|
6
10
|
import { runnerNetworkPolicy } from "./network-policy.js";
|
|
7
11
|
import { runnerSandboxScope } from "./scope.js";
|
|
8
12
|
import { buildSnapshot } from "./snapshot-build.js";
|
|
9
|
-
import {
|
|
13
|
+
import { classifyUnverifiedSharedSandbox, sharedSnapshotBucket, sharedSnapshotSandboxName, usableSharedEntry, } from "./shared-snapshot-entry.js";
|
|
10
14
|
import { snapshotInputsAt } from "./snapshot-key.js";
|
|
15
|
+
import { sandboxApiFailure } from "./steps.js";
|
|
11
16
|
/**
|
|
12
17
|
* Runs a build's local checks, before anything is minted or started: the repository's root, HEAD, the submodule
|
|
13
18
|
* refusal, HEAD's merge-base (`resolveBase`, which refuses with `no-base-ref` only without `--base`), the commit
|
|
14
19
|
* `--base` resolves to locally, the snapshot steps and key at the commit it builds, the cache's base snapshots of it,
|
|
15
|
-
*
|
|
20
|
+
* whether a commit other than the merge-base is an ancestor of it, and, when it builds at the merge-base, HEAD's count
|
|
21
|
+
* of commits after it. It never mints, acquires or creates, and removes no cache file.
|
|
16
22
|
*/
|
|
17
23
|
export async function prepareSnapshotBuild(context, request) {
|
|
18
24
|
const { checkout } = context;
|
|
19
|
-
const {
|
|
25
|
+
const { options, ref } = request;
|
|
20
26
|
const root = await checkout.repositoryRoot({ cwd: request.cwd });
|
|
21
27
|
if (!root.ok)
|
|
22
28
|
return { kind: "checkout-failed", failure: root.failure };
|
|
@@ -24,7 +30,7 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
24
30
|
const head = await checkout.head({ repoRoot });
|
|
25
31
|
if (!head.ok)
|
|
26
32
|
return { kind: "checkout-failed", failure: head.failure };
|
|
27
|
-
const resolved = await resolveBase(checkout, { repoRoot, baseRefs:
|
|
33
|
+
const resolved = await resolveBase(checkout, { repoRoot, baseRefs: options.baseRefs });
|
|
28
34
|
if (resolved.kind === "failed")
|
|
29
35
|
return { kind: "checkout-failed", failure: resolved.failure };
|
|
30
36
|
const mergeBase = resolved.kind === "resolved" ? { commit: resolved.base, ref: resolved.ref } : null;
|
|
@@ -47,20 +53,20 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
47
53
|
return { kind: "ref-not-found", ref };
|
|
48
54
|
base = commit.value;
|
|
49
55
|
}
|
|
50
|
-
const inputs = await snapshotInputsAt(checkout, { repoRoot, base,
|
|
56
|
+
const inputs = await snapshotInputsAt(checkout, { repoRoot, base, options });
|
|
51
57
|
if (!inputs.ok)
|
|
52
|
-
return { kind: "invalid-
|
|
53
|
-
// An unreadable
|
|
58
|
+
return { kind: "invalid-runner", path: inputs.path, problem: inputs.problem };
|
|
59
|
+
// An unreadable local snapshot index holds nothing to reuse: the build goes on, and builds.
|
|
54
60
|
const listed = await context.runnerSnapshots.listEntries();
|
|
55
61
|
const now = context.clock.now();
|
|
56
|
-
const
|
|
57
|
-
entry.
|
|
58
|
-
entry.region ===
|
|
59
|
-
entry.runtime ===
|
|
62
|
+
const indexed = (listed.ok ? listed.value.entries : []).filter((entry) => entry.base === base &&
|
|
63
|
+
entry.runnerName === options.name &&
|
|
64
|
+
entry.region === options.region &&
|
|
65
|
+
entry.runtime === options.runtime &&
|
|
60
66
|
entry.snapshotKey === inputs.key &&
|
|
61
67
|
hasTimeLeft(entry, now));
|
|
62
68
|
const atMergeBase = base === mergeBase?.commit;
|
|
63
|
-
// The built snapshot's count behind HEAD, for a build at the merge-base, the
|
|
69
|
+
// The built snapshot's count behind HEAD, for a build at the merge-base, the snapshot a run here starts from first.
|
|
64
70
|
let commitsAfterBase = null;
|
|
65
71
|
if (atMergeBase) {
|
|
66
72
|
const counted = await checkout.commitCount({ repoRoot, from: base, to: "HEAD" });
|
|
@@ -68,11 +74,19 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
68
74
|
return { kind: "checkout-failed", failure: counted.failure };
|
|
69
75
|
commitsAfterBase = counted.value;
|
|
70
76
|
}
|
|
77
|
+
// Whether a run here may start from a snapshot at another commit: one behind the merge-base on its base ref's line.
|
|
78
|
+
let ancestorOfMergeBase = false;
|
|
79
|
+
if (!atMergeBase && mergeBase !== null) {
|
|
80
|
+
const contained = await checkout.contains({ repoRoot, ancestor: base, descendant: mergeBase.commit });
|
|
81
|
+
if (!contained.ok)
|
|
82
|
+
return { kind: "checkout-failed", failure: contained.failure };
|
|
83
|
+
ancestorOfMergeBase = contained.value;
|
|
84
|
+
}
|
|
71
85
|
return {
|
|
72
86
|
kind: "ok",
|
|
73
87
|
build: {
|
|
74
88
|
plan: {
|
|
75
|
-
|
|
89
|
+
options,
|
|
76
90
|
repoRoot,
|
|
77
91
|
base,
|
|
78
92
|
baseFiles: inputs.baseFiles,
|
|
@@ -83,7 +97,8 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
83
97
|
ref: ref ?? null,
|
|
84
98
|
mergeBase,
|
|
85
99
|
atMergeBase,
|
|
86
|
-
|
|
100
|
+
ancestorOfMergeBase,
|
|
101
|
+
indexed,
|
|
87
102
|
full: request.full,
|
|
88
103
|
},
|
|
89
104
|
};
|
|
@@ -93,14 +108,16 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
93
108
|
* ends, keeping none. A cached base snapshot at the commit for the access's team and project is up to date, unless
|
|
94
109
|
* `full`, which builds a new one that replaces its cache entry. `signal` cancels it in any stage: the scope says so,
|
|
95
110
|
* revokes every credential at once, and stops its sandboxes. A base snapshot's save isn't stopped by the signal, so
|
|
96
|
-
* after it the build checks the signal once and ends `aborted` with what it saved.
|
|
111
|
+
* after it the build checks the signal once and ends `aborted` with what it saved. With `publish`, it checks the shared
|
|
112
|
+
* snapshot index instead of the cache (`publishIn`), and the build sandbox it saves stays in the project, stopped, as
|
|
113
|
+
* the index entry.
|
|
97
114
|
*/
|
|
98
115
|
export async function buildSnapshots(context, request, control, progress) {
|
|
99
116
|
const { signal } = control;
|
|
100
117
|
// When the build is canceled, the scope stops its sandboxes and revokes every credential at once.
|
|
101
118
|
const scope = runnerSandboxScope(context, progress, {
|
|
102
119
|
keepMs: 0,
|
|
103
|
-
basePolicy: runnerNetworkPolicy(request.build.plan.
|
|
120
|
+
basePolicy: runnerNetworkPolicy(request.build.plan.options),
|
|
104
121
|
signal,
|
|
105
122
|
});
|
|
106
123
|
try {
|
|
@@ -117,25 +134,109 @@ async function buildIn(context, request, control, progress) {
|
|
|
117
134
|
const { signal } = control;
|
|
118
135
|
if (signal.aborted)
|
|
119
136
|
return { kind: "aborted", snapshot: null };
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
if (request.publish === true)
|
|
138
|
+
return await publishIn(context, request, control, progress);
|
|
139
|
+
const indexed = build.indexed.find((entry) => entry.teamId === access.teamId && entry.projectId === access.projectId);
|
|
140
|
+
if (!build.full && indexed !== undefined)
|
|
141
|
+
return { kind: "up-to-date", snapshot: indexed };
|
|
142
|
+
const built = await buildSnapshot(context, { prepared: build.plan, access, user, credentials, why: buildReason(build) }, control, progress);
|
|
143
|
+
if (built.kind === "aborted")
|
|
144
|
+
return { kind: "aborted", snapshot: null };
|
|
145
|
+
if (built.kind !== "ok")
|
|
146
|
+
return built;
|
|
147
|
+
const { entry, localIndexFailure, ms, sizeBytes } = built.value;
|
|
148
|
+
if (signal.aborted)
|
|
149
|
+
return { kind: "aborted", snapshot: { entry, indexed: localIndexFailure === null } };
|
|
150
|
+
return localIndexFailure === null
|
|
151
|
+
? { kind: "built", snapshot: entry, ms, sizeBytes }
|
|
152
|
+
: { kind: "not-indexed", snapshot: entry, failure: localIndexFailure };
|
|
153
|
+
}
|
|
154
|
+
/** Why a build builds, for the line that says so. */
|
|
155
|
+
function buildReason(build) {
|
|
123
156
|
const why = build.full ? "full" : build.ref === null ? "no-snapshot" : "base";
|
|
157
|
+
return why === "no-snapshot" ? { kind: why, rejected: [] } : { kind: why };
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* A published build: it reads the shared snapshot index entry for the plan's base (`sharedSnapshotSandboxName`). An
|
|
161
|
+
* entry whose sandbox a build still owns ends `already-building`. A stopped entry whose snapshot is `created` with
|
|
162
|
+
* more than an hour left is up to date, unless `full`, and the cache records it. Any other entry (expired, gone, not
|
|
163
|
+
* `created`, without a snapshot, failed, or aborted, or any entry under `full`) is deleted to free its name, keeping
|
|
164
|
+
* its snapshot. Then it builds under that name and keeps the build sandbox stopped as the new entry.
|
|
165
|
+
*/
|
|
166
|
+
async function publishIn(context, request, control, progress) {
|
|
167
|
+
const { build, access, user, credentials } = request;
|
|
168
|
+
const { plan } = build;
|
|
169
|
+
const { options } = plan;
|
|
170
|
+
const { signal } = control;
|
|
171
|
+
const { runnerSandboxes } = context;
|
|
172
|
+
const bucket = sharedSnapshotBucket({
|
|
173
|
+
teamId: access.teamId,
|
|
174
|
+
projectId: access.projectId,
|
|
175
|
+
region: options.region,
|
|
176
|
+
runtime: options.runtime,
|
|
177
|
+
runnerName: options.name,
|
|
178
|
+
snapshotKey: plan.snapshotKey,
|
|
179
|
+
});
|
|
180
|
+
const name = sharedSnapshotSandboxName(bucket, plan.base);
|
|
181
|
+
const found = await runnerSandboxes.getNamedSandbox(access, { name }, signal);
|
|
182
|
+
if (!found.ok)
|
|
183
|
+
return callStop("get-named-sandbox", found.failure);
|
|
184
|
+
if (found.value.kind === "found") {
|
|
185
|
+
const { sandbox } = found.value;
|
|
186
|
+
const unverified = classifyUnverifiedSharedSandbox(sandbox);
|
|
187
|
+
if (unverified.kind === "settled" && unverified.status === "building")
|
|
188
|
+
return { kind: "already-building", sandboxName: name, status: sandbox.status };
|
|
189
|
+
if (!build.full && unverified.kind === "needs-snapshot") {
|
|
190
|
+
const verified = await runnerSandboxes.getSnapshot(access, { snapshotId: unverified.snapshotId }, signal);
|
|
191
|
+
if (!verified.ok)
|
|
192
|
+
return callStop("get-snapshot", verified.failure);
|
|
193
|
+
const entry = verified.value.kind === "found"
|
|
194
|
+
? usableSharedEntry(access, options, plan.snapshotKey, plan.base, sandbox, verified.value.snapshot, context.clock.now())
|
|
195
|
+
: null;
|
|
196
|
+
if (entry !== null) {
|
|
197
|
+
// Best effort: a run that misses the cache finds the snapshot in the index.
|
|
198
|
+
const written = await context.runnerSnapshots.writeEntry(entry);
|
|
199
|
+
if (!written.ok)
|
|
200
|
+
await progress.emit({ kind: "snapshot-entry-not-written", failure: written.failure });
|
|
201
|
+
return { kind: "up-to-date", snapshot: entry, sandboxName: name };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const removed = await runnerSandboxes.deleteNamedSandbox(access, { name }, signal);
|
|
205
|
+
if (!removed.ok)
|
|
206
|
+
return callStop("delete-named-sandbox", removed.failure);
|
|
207
|
+
}
|
|
208
|
+
if (signal.aborted)
|
|
209
|
+
return { kind: "aborted", snapshot: null };
|
|
210
|
+
const expiresAt = new Date(context.clock.now().getTime() + SNAPSHOT_EXPIRATION_MS).toISOString();
|
|
124
211
|
const built = await buildSnapshot(context, {
|
|
125
|
-
prepared:
|
|
212
|
+
prepared: plan,
|
|
126
213
|
access,
|
|
127
214
|
user,
|
|
128
215
|
credentials,
|
|
129
|
-
why:
|
|
216
|
+
why: buildReason(build),
|
|
217
|
+
publish: { name, tags: snapshotIndexTags(options.name, user, plan.base, expiresAt) },
|
|
130
218
|
}, control, progress);
|
|
219
|
+
if (built.kind === "name-taken")
|
|
220
|
+
return { kind: "already-building", sandboxName: name, status: null };
|
|
131
221
|
if (built.kind === "aborted")
|
|
132
222
|
return { kind: "aborted", snapshot: null };
|
|
133
223
|
if (built.kind !== "ok")
|
|
134
224
|
return built;
|
|
135
|
-
const { entry,
|
|
225
|
+
const { entry, localIndexFailure, ms, sizeBytes } = built.value;
|
|
136
226
|
if (signal.aborted)
|
|
137
|
-
return { kind: "aborted", snapshot: { entry,
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
|
|
227
|
+
return { kind: "aborted", snapshot: { entry, indexed: localIndexFailure === null } };
|
|
228
|
+
return {
|
|
229
|
+
kind: "built",
|
|
230
|
+
snapshot: entry,
|
|
231
|
+
ms,
|
|
232
|
+
sizeBytes,
|
|
233
|
+
sandboxName: name,
|
|
234
|
+
...(localIndexFailure === null ? {} : { localIndexFailure }),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** How a build ends on a failed Sandbox call about the index entry: aborted for the signal, failed otherwise. */
|
|
238
|
+
function callStop(operation, failure) {
|
|
239
|
+
return failure.kind === "aborted"
|
|
240
|
+
? { kind: "aborted", snapshot: null }
|
|
241
|
+
: { kind: "failed", failure: sandboxApiFailure(operation, failure) };
|
|
141
242
|
}
|
package/dist/runner/context.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import type { Timer } from "../time/index.ts";
|
|
2
2
|
import type { RunnerSandboxGateway, RunnerSandboxRole, RunnerTerminal } from "./gateways.ts";
|
|
3
|
-
import type {
|
|
4
|
-
/**
|
|
5
|
-
|
|
3
|
+
import type { LocalSnapshotIndexContext } from "./local-snapshot-index.ts";
|
|
4
|
+
/**
|
|
5
|
+
* The runner's gateways and seams: the checkout, the local snapshot index, Vercel Sandbox, the terminal, the clock,
|
|
6
|
+
* and the timer.
|
|
7
|
+
*/
|
|
8
|
+
export interface RunnerContext extends LocalSnapshotIndexContext {
|
|
6
9
|
readonly runnerSandboxes: RunnerSandboxGateway;
|
|
7
10
|
readonly runnerTerminal: RunnerTerminal;
|
|
8
11
|
readonly timer: Timer;
|
|
9
12
|
}
|
|
10
|
-
/** The `purpose` tag of a
|
|
11
|
-
export declare function runnerPurpose(
|
|
12
|
-
/** The tags of a sandbox: the
|
|
13
|
-
export declare function runnerTags(
|
|
13
|
+
/** The `purpose` tag of a Vercel Sandbox runner's sandboxes. */
|
|
14
|
+
export declare function runnerPurpose(runnerName: string): string;
|
|
15
|
+
/** The tags of a sandbox: the runner's `purpose`, the local `user` who started it, and its `role`. */
|
|
16
|
+
export declare function runnerTags(runnerName: string, role: RunnerSandboxRole, user: string): Readonly<Record<string, string>>;
|
|
17
|
+
/**
|
|
18
|
+
* The 5 tags of a named build sandbox kept stopped as a shared snapshot index entry: the runner's `purpose`, the
|
|
19
|
+
* `user` who built it, `role: "snapshot-index"`, its `base` commit SHA, and `expires-at`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function snapshotIndexTags(runnerName: string, user: string, base: string, expiresAt: string): Readonly<Record<string, string>>;
|
package/dist/runner/context.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
// What the runner reaches the world through as it readies and uses a runner sandbox, and the tags every sandbox it
|
|
2
2
|
// creates carries.
|
|
3
|
-
/** The `purpose` tag of a
|
|
4
|
-
export function runnerPurpose(
|
|
5
|
-
return `storm-runner-${
|
|
3
|
+
/** The `purpose` tag of a Vercel Sandbox runner's sandboxes. */
|
|
4
|
+
export function runnerPurpose(runnerName) {
|
|
5
|
+
return `storm-runner-${runnerName}`;
|
|
6
6
|
}
|
|
7
|
-
/** The tags of a sandbox: the
|
|
8
|
-
export function runnerTags(
|
|
9
|
-
return { purpose: runnerPurpose(
|
|
7
|
+
/** The tags of a sandbox: the runner's `purpose`, the local `user` who started it, and its `role`. */
|
|
8
|
+
export function runnerTags(runnerName, role, user) {
|
|
9
|
+
return { purpose: runnerPurpose(runnerName), user, role };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The 5 tags of a named build sandbox kept stopped as a shared snapshot index entry: the runner's `purpose`, the
|
|
13
|
+
* `user` who built it, `role: "snapshot-index"`, its `base` commit SHA, and `expires-at`.
|
|
14
|
+
*/
|
|
15
|
+
export function snapshotIndexTags(runnerName, user, base, expiresAt) {
|
|
16
|
+
return {
|
|
17
|
+
purpose: runnerPurpose(runnerName),
|
|
18
|
+
user,
|
|
19
|
+
role: "snapshot-index",
|
|
20
|
+
base,
|
|
21
|
+
"expires-at": expiresAt,
|
|
22
|
+
};
|
|
10
23
|
}
|
package/dist/runner/events.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CheckoutFailure, RunnerSandboxRole,
|
|
2
|
-
import type { RejectedSnapshot } from "./snapshot-
|
|
1
|
+
import type { CheckoutFailure, RunnerSandboxRole, RunnerSnapshotIndexFailure } from "./gateways.ts";
|
|
2
|
+
import type { RejectedSnapshot } from "./local-snapshot-index.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Where a step runs, which names its progress lines: `snapshot` (`[runner snapshot]`), `apply` (`[runner]`), `install`
|
|
5
5
|
* (`[runner install]`) and `build` (`[runner build]`).
|
|
@@ -35,7 +35,7 @@ export interface NotKeptSandbox {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Why a base snapshot is being built: no cached snapshot fits the run or the checkout (`no-snapshot`), with why each
|
|
38
|
-
* cached snapshot of the
|
|
38
|
+
* cached snapshot of the runner didn't (`rejected`); `storm snapshots build --full` asked for a new one whatever the
|
|
39
39
|
* cache holds (`full`); or `storm snapshots build --base <ref>` asked for one at a commit the cache has none of
|
|
40
40
|
* (`base`).
|
|
41
41
|
*/
|
|
@@ -50,8 +50,9 @@ export type SnapshotBuildReason = {
|
|
|
50
50
|
/**
|
|
51
51
|
* What the runner reports, in order.
|
|
52
52
|
*
|
|
53
|
-
* - `snapshot-reused`: the run starts from
|
|
54
|
-
*
|
|
53
|
+
* - `snapshot-reused`: the run starts from runner snapshot `snapshotId`, built at `base`; `builtBehind` is how many
|
|
54
|
+
* commits HEAD has that `base` lacks, and `source` says whether it came from the local snapshot index (`local`) or the shared
|
|
55
|
+
* snapshot index (`shared`).
|
|
55
56
|
* - `snapshot-build-started`: a base snapshot of `base` is being built, and `why` (`SnapshotBuildReason`); `summary`
|
|
56
57
|
* says what the build does.
|
|
57
58
|
* - `runner-sandbox-starting`: the runner sandbox is starting from runner snapshot `snapshotId`.
|
|
@@ -61,7 +62,8 @@ export type SnapshotBuildReason = {
|
|
|
61
62
|
* - `snapshot-saving`: the build sandbox is being saved as a runner snapshot.
|
|
62
63
|
* - `snapshot-built`: it was, in `ms` from the build's start; `builtBehind` is how many commits HEAD has that `base`
|
|
63
64
|
* lacks, null for a `storm snapshots build --base` commit that isn't HEAD's merge-base.
|
|
64
|
-
* - `snapshot-entry-not-written`: the cache couldn't record the
|
|
65
|
+
* - `snapshot-entry-not-written`: the cache couldn't record the snapshot; the run goes on.
|
|
66
|
+
* - `shared-snapshot-lookup-failed`: querying the shared snapshot index failed; the run continues without it.
|
|
65
67
|
* - `uploading`: the run's changes are being uploaded to the runner sandbox.
|
|
66
68
|
* - `uploaded`: the run's changes, `bytes` in all, reached the runner sandbox.
|
|
67
69
|
* - `command-output-started`: the command started in runner sandbox `sandbox`, and its output follows on the
|
|
@@ -78,6 +80,7 @@ export type RunnerEvent = {
|
|
|
78
80
|
readonly snapshotId: string;
|
|
79
81
|
readonly base: string;
|
|
80
82
|
readonly builtBehind: number;
|
|
83
|
+
readonly source: "local" | "shared";
|
|
81
84
|
} | {
|
|
82
85
|
readonly kind: "snapshot-build-started";
|
|
83
86
|
readonly base: string;
|
|
@@ -127,7 +130,10 @@ export type RunnerEvent = {
|
|
|
127
130
|
readonly builtBehind: number | null;
|
|
128
131
|
} | {
|
|
129
132
|
readonly kind: "snapshot-entry-not-written";
|
|
130
|
-
readonly failure:
|
|
133
|
+
readonly failure: RunnerSnapshotIndexFailure;
|
|
134
|
+
} | {
|
|
135
|
+
readonly kind: "shared-snapshot-lookup-failed";
|
|
136
|
+
readonly message: string;
|
|
131
137
|
} | {
|
|
132
138
|
readonly kind: "uploading";
|
|
133
139
|
} | {
|
|
@@ -156,9 +162,9 @@ export interface RunnerProgress {
|
|
|
156
162
|
emit(event: RunnerEvent): Promise<void>;
|
|
157
163
|
}
|
|
158
164
|
/** What a Sandbox call was doing when it failed, as `sandbox-api-failed` names it. */
|
|
159
|
-
export type RunnerSandboxCall = "start-build-sandbox" | "start-runner-sandbox" | "upload" | "run-script" | "login-path" | "run-command" | "save-snapshot";
|
|
165
|
+
export type RunnerSandboxCall = "start-build-sandbox" | "start-runner-sandbox" | "upload" | "run-script" | "login-path" | "run-command" | "save-snapshot" | "get-named-sandbox" | "get-snapshot" | "delete-named-sandbox";
|
|
160
166
|
/**
|
|
161
|
-
* Where a network policy write that puts credentials in place or removes them was: around the
|
|
167
|
+
* Where a network policy write that puts credentials in place or removes them was: around the runner's snapshot steps
|
|
162
168
|
* (its toolchain and prebuild steps, in the build sandbox), around its run steps (its install and build steps, in the
|
|
163
169
|
* runner sandbox), before a snapshot save, or around the command.
|
|
164
170
|
*/
|
|
@@ -171,7 +177,7 @@ export type NetworkPolicyPlace = "snapshot-steps" | "run-steps" | "snapshot-save
|
|
|
171
177
|
* - `sandbox-api-failed`: a Sandbox call failed; `status` is the HTTP status when the API answered one.
|
|
172
178
|
* - `checkout-failed`: git or tar failed on this machine, packing the base's files or the run's changes.
|
|
173
179
|
* - `network-policy-failed`: a network policy write that puts credentials in place or removes them failed, `around`
|
|
174
|
-
* one of four places: the
|
|
180
|
+
* one of four places: the runner's snapshot steps (`snapshot-steps`) or its run steps (`run-steps`), whose
|
|
175
181
|
* credentials it puts in place before the first of them (`inject`; none of them ran); a snapshot save
|
|
176
182
|
* (`snapshot-save`), before which the scope removes them (`remove`); or the command (`command`), whose resources'
|
|
177
183
|
* credentials it puts in place before the command starts (`inject`; the command didn't run). `reason` is `api`, with
|