@cnc-tools/storm 0.16.0 → 0.18.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/bin/storm.js +54 -40
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/chunk-AS37D43E.js +2173 -0
- package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
- package/dist/chunks/chunk-DZLU7BYK.js +340 -0
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
- package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
- package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
- package/dist/chunks/chunk-SZMYIIG2.js +88 -0
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
- package/dist/cli.d.ts +28 -0
- package/dist/cli.js +64 -0
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
- package/dist/commands/exec/across-sandboxes-outcomes.js +3 -3
- 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 +67 -14
- 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 +104 -22
- package/dist/commands/exec/outcomes.js +73 -26
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +239 -90
- 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 +8 -4
- package/dist/commands/runs/facts.js +19 -10
- package/dist/commands/runs/list/command.d.ts +16 -8
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +8 -4
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +16 -8
- package/dist/commands/runs/show/command.js +31 -29
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +8 -4
- package/dist/commands/runs/show/outcomes.js +8 -6
- 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 +376 -101
- package/dist/commands/snapshots/build/command.js +447 -149
- 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 +242 -47
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +368 -27
- package/dist/commands/snapshots/list/command.js +298 -68
- 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 +247 -15
- package/dist/commands/snapshots/list/outcomes.js +223 -52
- 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 +67 -14
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +33 -7
- 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 +14 -4
- package/dist/config-file/toolchain.js +43 -7
- package/dist/context.d.ts +10 -6
- package/dist/context.js +8 -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 +107 -267
- 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 +1 -1
- package/dist/extension-commands.js +2 -2
- 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 +3 -3
- package/dist/run-directory/run-record.d.ts +26 -11
- package/dist/run-directory/run-record.js +16 -13
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +60 -29
- package/dist/runner/build-snapshots.js +136 -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 +122 -23
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/gh.d.ts +42 -0
- package/dist/runner/gh.js +58 -0
- package/dist/runner/index.d.ts +13 -8
- package/dist/runner/index.js +12 -6
- package/dist/runner/live/checkout-gateway.js +7 -0
- package/dist/runner/live/gh-output.d.ts +17 -0
- package/dist/runner/live/gh-output.js +37 -0
- package/dist/runner/live/gh-token-gateway.d.ts +13 -0
- package/dist/runner/live/gh-token-gateway.js +51 -0
- 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 +140 -4
- 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 +12 -12
- package/dist/runner/local-snapshot-index.d.ts +205 -0
- package/dist/runner/local-snapshot-index.js +210 -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 +19 -11
- 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 +15 -8
- package/dist/runner/scope.js +16 -5
- package/dist/runner/secrets.d.ts +41 -18
- package/dist/runner/secrets.js +226 -30
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +6 -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 +79 -47
- package/dist/runner/snapshot-choice.js +2 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +52 -35
- package/dist/runner/snapshot-key.d.ts +32 -17
- package/dist/runner/snapshot-key.js +43 -18
- package/dist/runner/snapshot-source.d.ts +31 -0
- package/dist/runner/snapshot-source.js +122 -0
- 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} +4 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
- package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
- 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 +5 -3
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- package/dist/application.d.ts +0 -21
- package/dist/application.js +0 -30
- 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/recipe-secrets.d.ts +0 -67
- package/dist/runner/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
|
@@ -1,51 +1,79 @@
|
|
|
1
1
|
import type { SandboxCredential } from "../sdk/extension/index.ts";
|
|
2
2
|
import { type RunnerContext } from "./context.ts";
|
|
3
3
|
import type { RunnerProgress, RunnerStage, SnapshotBuildReason } from "./events.ts";
|
|
4
|
-
import type {
|
|
4
|
+
import type { RunnerSnapshotEntry, RunnerSnapshotIndexFailure, SandboxAccess } from "./gateways.ts";
|
|
5
5
|
import type { PreparedRunner } from "./prepare.ts";
|
|
6
6
|
import type { RunnerSandboxScope } from "./scope.ts";
|
|
7
7
|
/** How long a build sandbox may live: 30 minutes. */
|
|
8
8
|
export declare const BUILD_SANDBOX_TIMEOUT_MS: number;
|
|
9
9
|
/** The label of the step between the toolchain and prebuild steps that commits the base's files. */
|
|
10
10
|
export declare const BASE_INDEX_LABEL = "Committing the base's files";
|
|
11
|
-
/** A runner snapshot a run built and the
|
|
11
|
+
/** A runner snapshot a run built and the local snapshot index entry recorded for it, or why it couldn't record it. */
|
|
12
12
|
export interface BuiltSnapshot {
|
|
13
13
|
readonly entry: RunnerSnapshotEntry;
|
|
14
|
-
/** How long the build took, from its start to the
|
|
14
|
+
/** How long the build took, from its start to the local snapshot index entry. */
|
|
15
15
|
readonly ms: number;
|
|
16
16
|
readonly sizeBytes: number;
|
|
17
|
-
/** Why the
|
|
18
|
-
readonly
|
|
17
|
+
/** Why the local snapshot index couldn't write `entry`; null when it wrote it. */
|
|
18
|
+
readonly localIndexFailure: RunnerSnapshotIndexFailure | null;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* What a
|
|
21
|
+
* What a runner snapshot build reads of a prepared run, or of a `storm snapshots build` plan: the runner options, the
|
|
22
22
|
* checkout, the base, its snapshot steps and key, and how many commits HEAD has after the base.
|
|
23
23
|
*/
|
|
24
|
-
export interface
|
|
24
|
+
export interface RunnerSnapshotPlan extends Pick<PreparedRunner, "options" | "repoRoot" | "base" | "baseFiles" | "snapshotKey"> {
|
|
25
25
|
/** How many commits HEAD has after the base; null for a `--base` commit that isn't HEAD's merge-base. */
|
|
26
26
|
readonly commitsAfterBase: number | null;
|
|
27
27
|
}
|
|
28
28
|
/** What a snapshot build needs to know: what it builds, who it runs as, the credentials, and why it builds. */
|
|
29
29
|
export interface BuildSnapshotRequest {
|
|
30
|
-
readonly prepared:
|
|
30
|
+
readonly prepared: RunnerSnapshotPlan;
|
|
31
31
|
readonly access: SandboxAccess;
|
|
32
32
|
/** The local user, for the sandbox's `user` tag. */
|
|
33
33
|
readonly user: string;
|
|
34
34
|
/**
|
|
35
|
-
* The
|
|
35
|
+
* The runner's credentials, with their values; the firewall adds each one from before the first toolchain step until
|
|
36
36
|
* the scope revokes them before the snapshot save, or in its fence if the build ends early.
|
|
37
37
|
*/
|
|
38
38
|
readonly credentials: readonly Required<SandboxCredential>[];
|
|
39
39
|
/** Why it builds, for the line that says so. */
|
|
40
40
|
readonly why: SnapshotBuildReason;
|
|
41
|
+
/**
|
|
42
|
+
* Publish the build to the shared snapshot index: the build sandbox takes `name` and `tags`
|
|
43
|
+
* (`snapshotIndexTags`), and stays in the project, stopped, once saved. Undefined builds an unnamed build sandbox
|
|
44
|
+
* with the runner's tags, which is deleted once saved.
|
|
45
|
+
*/
|
|
46
|
+
readonly publish?: SnapshotPublish;
|
|
47
|
+
}
|
|
48
|
+
/** The name and tags of a build sandbox kept stopped as a shared snapshot index entry. */
|
|
49
|
+
export interface SnapshotPublish {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly tags: Readonly<Record<string, string>>;
|
|
41
52
|
}
|
|
42
53
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* same identity, a base snapshot of the same owner, recipe, snapshot key and base. A cache entry that can't be written
|
|
46
|
-
* is reported, and the build still succeeds, saying why (`BuiltSnapshot.cacheFailure`).
|
|
54
|
+
* How a published snapshot build ended: a build's stage, or `name-taken` when a sandbox named `name` already exists in
|
|
55
|
+
* the project, such as one another build started first, so this build started nothing.
|
|
47
56
|
*/
|
|
48
|
-
export
|
|
57
|
+
export type PublishedSnapshotStage = RunnerStage<BuiltSnapshot> | {
|
|
58
|
+
readonly kind: "name-taken";
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly message: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Builds a runner snapshot of `prepared.base`. The build sandbox starts while the base's files are packed, and is
|
|
64
|
+
* deleted once saved; a build that fails leaves it to the scope to stop and delete. Its local snapshot index entry
|
|
65
|
+
* replaces one of the same identity, a runner snapshot of the same owner, runner, snapshot key, and base. A local
|
|
66
|
+
* snapshot index entry that can't be written is reported, and the build still succeeds, saying why
|
|
67
|
+
* (`BuiltSnapshot.localIndexFailure`). With `publish`, the build sandbox takes its name and tags and stays in the
|
|
68
|
+
* project, stopped, once saved, and a name already taken ends the build `name-taken` before anything else starts.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildSnapshot(context: Pick<RunnerContext, "checkout" | "runnerSnapshots" | "runnerSandboxes" | "clock">, request: BuildSnapshotRequest & {
|
|
71
|
+
readonly publish?: undefined;
|
|
72
|
+
}, control: {
|
|
49
73
|
readonly scope: RunnerSandboxScope;
|
|
50
74
|
readonly signal: AbortSignal;
|
|
51
75
|
}, progress: RunnerProgress): Promise<RunnerStage<BuiltSnapshot>>;
|
|
76
|
+
export declare function buildSnapshot(context: Pick<RunnerContext, "checkout" | "runnerSnapshots" | "runnerSandboxes" | "clock">, request: BuildSnapshotRequest, control: {
|
|
77
|
+
readonly scope: RunnerSandboxScope;
|
|
78
|
+
readonly signal: AbortSignal;
|
|
79
|
+
}, progress: RunnerProgress): Promise<PublishedSnapshotStage>;
|
|
@@ -1,79 +1,99 @@
|
|
|
1
1
|
// Building a runner snapshot of a run's base: a build sandbox runs the toolchain steps, commits exactly the base's
|
|
2
|
-
// tracked files, runs the prebuild steps, and is saved as a snapshot, which the
|
|
3
|
-
// grants the
|
|
4
|
-
// scope's fence if the build fails or is canceled).
|
|
2
|
+
// tracked files, runs the prebuild steps, and is saved as a snapshot, which the local snapshot index then records. The
|
|
3
|
+
// sandbox scope grants the runner's credentials before the first toolchain step, and revokes them before the snapshot
|
|
4
|
+
// save (or in the scope's fence if the build fails or is canceled). A published build names its build sandbox and keeps
|
|
5
|
+
// it stopped once saved, as an entry of the shared snapshot index.
|
|
5
6
|
import { runnerTags } from "./context.js";
|
|
6
|
-
import { SNAPSHOT_EXPIRATION_MS } from "./snapshot-
|
|
7
|
-
import { baseIndexScript, STAGED_FILES } from "./snapshot-key.js";
|
|
7
|
+
import { SNAPSHOT_EXPIRATION_MS } from "./local-snapshot-index.js";
|
|
8
|
+
import { baseIndexScript, gitFetchBaseIndexScript, STAGED_FILES } from "./snapshot-key.js";
|
|
9
|
+
import { normalizeGitFetchUrl } from "./snapshot-source.js";
|
|
8
10
|
import { networkPolicyStop, runStep, sandboxStop } from "./steps.js";
|
|
9
11
|
/** How long a build sandbox may live: 30 minutes. */
|
|
10
12
|
export const BUILD_SANDBOX_TIMEOUT_MS = 30 * 60_000;
|
|
11
13
|
/** The label of the step between the toolchain and prebuild steps that commits the base's files. */
|
|
12
14
|
export const BASE_INDEX_LABEL = "Committing the base's files";
|
|
13
|
-
/**
|
|
14
|
-
* Builds a base snapshot of `prepared.base`. The build sandbox starts while the base's files are packed, and is
|
|
15
|
-
* deleted once saved; a build that fails leaves it to the scope to stop and delete. Its cache entry replaces one of the
|
|
16
|
-
* same identity, a base snapshot of the same owner, recipe, snapshot key and base. A cache entry that can't be written
|
|
17
|
-
* is reported, and the build still succeeds, saying why (`BuiltSnapshot.cacheFailure`).
|
|
18
|
-
*/
|
|
19
15
|
export async function buildSnapshot(context, request, control, progress) {
|
|
20
16
|
const { prepared, access } = request;
|
|
21
|
-
const {
|
|
17
|
+
const { options, repoRoot, base } = prepared;
|
|
22
18
|
const { scope, signal } = control;
|
|
19
|
+
const { publish } = request;
|
|
23
20
|
const now = () => context.clock.now().getTime();
|
|
24
21
|
const startedAt = now();
|
|
25
22
|
await progress.emit({
|
|
26
23
|
kind: "snapshot-build-started",
|
|
27
24
|
base,
|
|
28
25
|
why: request.why,
|
|
29
|
-
summary:
|
|
30
|
-
[...
|
|
26
|
+
summary: options.snapshot.summary ??
|
|
27
|
+
[...options.snapshot.toolchains, ...options.snapshot.prebuild].map(({ label }) => label).join(", "),
|
|
31
28
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
let fetchUrl;
|
|
30
|
+
if (options.snapshot.source !== undefined) {
|
|
31
|
+
const resolved = await resolveGitFetchUrl(context.checkout, {
|
|
32
|
+
repoRoot,
|
|
33
|
+
remote: options.snapshot.source.remote,
|
|
34
|
+
});
|
|
35
|
+
if (!resolved.ok)
|
|
36
|
+
return { kind: "failed", failure: { kind: "checkout-failed", failure: resolved.failure } };
|
|
37
|
+
fetchUrl = resolved.value;
|
|
38
|
+
}
|
|
39
|
+
const startBuild = () => scope.startBuildSandbox(access, {
|
|
40
|
+
region: options.region,
|
|
41
|
+
image: options.image,
|
|
42
|
+
vcpus: options.snapshot.vcpus,
|
|
43
|
+
timeoutMs: BUILD_SANDBOX_TIMEOUT_MS,
|
|
44
|
+
...(publish === undefined
|
|
45
|
+
? { tags: runnerTags(options.name, "snapshot-build", request.user) }
|
|
46
|
+
: { name: publish.name, tags: publish.tags }),
|
|
47
|
+
});
|
|
48
|
+
const [started, baseStep] = fetchUrl === undefined
|
|
49
|
+
? await Promise.all([startBuild(), context.checkout.baseArchive({ repoRoot, base })])
|
|
50
|
+
: [await startBuild(), fetchUrl];
|
|
42
51
|
if (!started.ok)
|
|
43
|
-
return
|
|
52
|
+
return started.failure.kind === "name-taken"
|
|
53
|
+
? { kind: "name-taken", name: started.failure.name, message: started.failure.message }
|
|
54
|
+
: sandboxStop("start-build-sandbox", started.failure);
|
|
44
55
|
const sandbox = started.value;
|
|
45
56
|
await progress.emit({
|
|
46
57
|
kind: "sandbox-started",
|
|
47
58
|
role: "snapshot-build",
|
|
48
59
|
name: sandbox.name,
|
|
49
|
-
region:
|
|
50
|
-
vcpus:
|
|
60
|
+
region: options.region,
|
|
61
|
+
vcpus: options.snapshot.vcpus,
|
|
51
62
|
ms: now() - startedAt,
|
|
52
63
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
let baseStepScript;
|
|
65
|
+
if (typeof baseStep === "string") {
|
|
66
|
+
baseStepScript = gitFetchBaseIndexScript(baseStep, base);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (!baseStep.ok)
|
|
70
|
+
return { kind: "failed", failure: { kind: "checkout-failed", failure: baseStep.failure } };
|
|
71
|
+
const staged = await context.runnerSandboxes.upload(sandbox, [
|
|
72
|
+
{ name: STAGED_FILES.baseTarball, content: baseStep.value.tarball },
|
|
73
|
+
{ name: STAGED_FILES.baseFileList, content: baseStep.value.fileList },
|
|
74
|
+
], signal);
|
|
75
|
+
if (!staged.ok)
|
|
76
|
+
return sandboxStop("upload", staged.failure);
|
|
77
|
+
baseStepScript = baseIndexScript(base, staged.value.directory);
|
|
78
|
+
}
|
|
61
79
|
if (prepared.baseFiles.length > 0) {
|
|
62
80
|
const encoder = new TextEncoder();
|
|
63
81
|
const placed = await context.runnerSandboxes.placeBaseFiles(sandbox, prepared.baseFiles.map(({ path, text }) => ({ name: path, content: encoder.encode(text) })), signal);
|
|
64
82
|
if (!placed.ok)
|
|
65
83
|
return sandboxStop("upload", placed.failure);
|
|
66
84
|
}
|
|
67
|
-
// Every credential the
|
|
85
|
+
// Every credential the runner declares goes on the steps' requests, from before the first toolchain step until
|
|
68
86
|
// `saveSnapshot` revokes them before saving (or the scope's fence revokes them if a step fails or the build is
|
|
69
|
-
// canceled). storm's own base-index step falls inside
|
|
70
|
-
//
|
|
87
|
+
// canceled). storm's own base-index step falls inside. With `snapshot.source: { kind: "git-fetch" }` its fetch needs
|
|
88
|
+
// them, since a credential for the Git host reaches the fetch's requests only this way. Otherwise it runs only tar and
|
|
89
|
+
// git on the uploaded files, so it makes no request, and revoking and granting again around it would add two writes
|
|
90
|
+
// and their failures for nothing.
|
|
71
91
|
const steps = [
|
|
72
|
-
...
|
|
73
|
-
{ label: BASE_INDEX_LABEL, script:
|
|
74
|
-
...
|
|
92
|
+
...options.snapshot.toolchains,
|
|
93
|
+
{ label: BASE_INDEX_LABEL, script: baseStepScript },
|
|
94
|
+
...options.snapshot.prebuild,
|
|
75
95
|
];
|
|
76
|
-
await progress.emit({ kind: "output-started", section: "snapshot", sandbox: sandbox.name, region:
|
|
96
|
+
await progress.emit({ kind: "output-started", section: "snapshot", sandbox: sandbox.name, region: options.region });
|
|
77
97
|
let stop;
|
|
78
98
|
if (request.credentials.length > 0) {
|
|
79
99
|
const granted = await scope.grantCredentials(sandbox, request.credentials, signal);
|
|
@@ -114,7 +134,10 @@ export async function buildSnapshot(context, request, control, progress) {
|
|
|
114
134
|
if (signal.aborted)
|
|
115
135
|
return { kind: "aborted" };
|
|
116
136
|
await progress.emit({ kind: "snapshot-saving" });
|
|
117
|
-
const saved = await scope.saveSnapshot(sandbox, {
|
|
137
|
+
const saved = await scope.saveSnapshot(sandbox, {
|
|
138
|
+
expirationMs: SNAPSHOT_EXPIRATION_MS,
|
|
139
|
+
...(publish === undefined ? {} : { keepStopped: true }),
|
|
140
|
+
});
|
|
118
141
|
if (!saved.ok)
|
|
119
142
|
return saved.failure.kind === "credential-not-revoked"
|
|
120
143
|
? networkPolicyStop("remove", "snapshot-save", saved.failure.failure)
|
|
@@ -123,9 +146,9 @@ export async function buildSnapshot(context, request, control, progress) {
|
|
|
123
146
|
const entry = {
|
|
124
147
|
teamId: access.teamId,
|
|
125
148
|
projectId: access.projectId,
|
|
126
|
-
region:
|
|
127
|
-
|
|
128
|
-
|
|
149
|
+
region: options.region,
|
|
150
|
+
image: options.image,
|
|
151
|
+
runnerName: options.name,
|
|
129
152
|
snapshotKey: prepared.snapshotKey,
|
|
130
153
|
base,
|
|
131
154
|
snapshotId: saved.value.snapshotId,
|
|
@@ -146,6 +169,15 @@ export async function buildSnapshot(context, request, control, progress) {
|
|
|
146
169
|
});
|
|
147
170
|
return {
|
|
148
171
|
kind: "ok",
|
|
149
|
-
value: { entry, ms, sizeBytes: saved.value.sizeBytes,
|
|
172
|
+
value: { entry, ms, sizeBytes: saved.value.sizeBytes, localIndexFailure: written.ok ? null : written.failure },
|
|
150
173
|
};
|
|
151
174
|
}
|
|
175
|
+
async function resolveGitFetchUrl(checkout, request) {
|
|
176
|
+
const remote = await checkout.remoteUrl(request);
|
|
177
|
+
if (!remote.ok)
|
|
178
|
+
return remote;
|
|
179
|
+
const fetchUrl = normalizeGitFetchUrl(remote.value);
|
|
180
|
+
if (fetchUrl.ok)
|
|
181
|
+
return { ok: true, value: fetchUrl.url };
|
|
182
|
+
return { ok: false, failure: { message: `the URL of Git remote "${request.remote}" ${fetchUrl.problem}` } };
|
|
183
|
+
}
|
|
@@ -19,7 +19,8 @@ export async function chooseSnapshotForRun(context, request, control, progress)
|
|
|
19
19
|
// reporting cancellation or stopping sandboxes outside the running step.
|
|
20
20
|
const scope = runnerSandboxScope(context, progress, {
|
|
21
21
|
keepMs: 0,
|
|
22
|
-
basePolicy: runnerNetworkPolicy(request.prepared.
|
|
22
|
+
basePolicy: runnerNetworkPolicy(request.prepared.options),
|
|
23
|
+
managedCredentials: request.prepared.options.managedCredentials,
|
|
23
24
|
signal,
|
|
24
25
|
});
|
|
25
26
|
try {
|
|
@@ -1,85 +1,84 @@
|
|
|
1
1
|
import type { CheckoutFailure, CheckoutHead, RunnerSnapshotEntry, UnreadableSnapshotEntry } from "./gateways.ts";
|
|
2
|
-
import type {
|
|
3
|
-
import { type
|
|
2
|
+
import type { CheckedVercelSandboxOptions } from "./vercel-sandbox-options.ts";
|
|
3
|
+
import { type LocalSnapshotIndexContext, type SnapshotRejectionReason } from "./local-snapshot-index.ts";
|
|
4
4
|
/**
|
|
5
|
-
* One
|
|
6
|
-
* holds it (`inHistory`), which an amend or a rebase can change, and how many commits HEAD has that its
|
|
7
|
-
* (`builtBehind`). `inHistory` is null when storm didn't check it: outside a Git checkout, or without a
|
|
8
|
-
* base; `builtBehind` is null then too, and when the base isn't in HEAD's history. `picked` says a run
|
|
9
|
-
* from it, for its team and project.
|
|
10
|
-
* `reason` says why a run here doesn't (`SnapshotRejectionReason`), `other-
|
|
5
|
+
* One runner snapshot in the local snapshot index, as a checkout sees it: from the checkout's Git history, whether HEAD
|
|
6
|
+
* is its base or holds it (`inHistory`), which an amend or a rebase can change, and how many commits HEAD has that its
|
|
7
|
+
* base lacks (`builtBehind`). `inHistory` is null when storm didn't check it: outside a Git checkout, or without a
|
|
8
|
+
* runner or a base; `builtBehind` is null then too, and when the base isn't in HEAD's history. `picked` says a run
|
|
9
|
+
* here starts from it, for its team and project.
|
|
10
|
+
* `reason` says why a run here doesn't (`SnapshotRejectionReason`), `other-runner` for another runner's, or null for
|
|
11
11
|
* a picked one and when storm checked nothing.
|
|
12
12
|
*/
|
|
13
13
|
export interface InspectedSnapshot {
|
|
14
14
|
readonly entry: RunnerSnapshotEntry;
|
|
15
15
|
readonly inHistory: boolean | null;
|
|
16
16
|
readonly builtBehind: number | null;
|
|
17
|
+
readonly commitsBehindMergeBase: number | null;
|
|
17
18
|
readonly expired: boolean;
|
|
18
19
|
readonly picked: boolean;
|
|
19
|
-
readonly reason: SnapshotRejectionReason | "other-
|
|
20
|
+
readonly reason: SnapshotRejectionReason | "other-runner" | null;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
|
-
* Why the inspection picked for no
|
|
23
|
-
* applies there (`no-
|
|
23
|
+
* Why the inspection picked for no runner: the directory is in no Git checkout (`no-checkout`), no Vercel Sandbox
|
|
24
|
+
* runner applies there (`no-runner`), or no base ref of the runner exists locally and shares history with HEAD
|
|
25
|
+
* (`no-base`).
|
|
24
26
|
*/
|
|
25
|
-
export type UnpickedReason = "no-checkout" | "no-
|
|
26
|
-
/** What `
|
|
27
|
-
export interface
|
|
28
|
-
/** Where the
|
|
27
|
+
export type UnpickedReason = "no-checkout" | "no-runner" | "no-base";
|
|
28
|
+
/** What `inspectLocalSnapshotIndex` found. */
|
|
29
|
+
export interface LocalSnapshotIndexInspection {
|
|
30
|
+
/** Where the local snapshot index lives. */
|
|
29
31
|
readonly directory: string;
|
|
30
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The checkout the directory is in: its root, HEAD, and HEAD's merge-base with a base ref, with how many commits HEAD
|
|
34
|
+
* has that the merge-base lacks; null without one.
|
|
35
|
+
*/
|
|
31
36
|
readonly checkout: {
|
|
32
37
|
readonly repoRoot: string;
|
|
33
38
|
readonly head: CheckoutHead;
|
|
34
39
|
readonly mergeBase: {
|
|
35
40
|
readonly commit: string;
|
|
36
41
|
readonly ref: string;
|
|
42
|
+
readonly commitsAfterBase: number;
|
|
37
43
|
} | null;
|
|
38
44
|
} | null;
|
|
39
|
-
/** The
|
|
45
|
+
/** The runner a run here uses, by name, when storm picked for it; else why it picked for none. */
|
|
40
46
|
readonly picking: {
|
|
41
|
-
readonly kind: "
|
|
42
|
-
readonly
|
|
47
|
+
readonly kind: "runner";
|
|
48
|
+
readonly runner: string;
|
|
43
49
|
} | {
|
|
44
50
|
readonly kind: "none";
|
|
45
51
|
readonly why: UnpickedReason;
|
|
46
52
|
};
|
|
47
|
-
/** The
|
|
53
|
+
/** The run's snapshot key at the merge-base, when storm picked for a runner; else null. */
|
|
54
|
+
readonly snapshotKey: string | null;
|
|
55
|
+
/** The runner's snapshots, and with `all` every other runner's too. */
|
|
48
56
|
readonly snapshots: readonly InspectedSnapshot[];
|
|
49
57
|
readonly unreadable: readonly UnreadableSnapshotEntry[];
|
|
50
58
|
}
|
|
51
59
|
/**
|
|
52
|
-
* How an inspection ended: what it found; the
|
|
53
|
-
* snapshot (`checkout-failed`); or a declared base file of the
|
|
54
|
-
* (`invalid-
|
|
60
|
+
* How an inspection ended: what it found; the local snapshot index it couldn't list (`local-index-unreadable`); git
|
|
61
|
+
* failing while it checked the checkout or a snapshot (`checkout-failed`); or a declared base file of the runner that
|
|
62
|
+
* couldn't be read at the merge-base (`invalid-runner`), as a run's local checks refuse it, with `path` the key inside
|
|
63
|
+
* the runner options.
|
|
55
64
|
*/
|
|
56
|
-
export type
|
|
65
|
+
export type LocalSnapshotIndexInspectionOutcome = {
|
|
57
66
|
readonly kind: "ok";
|
|
58
|
-
readonly inspection:
|
|
67
|
+
readonly inspection: LocalSnapshotIndexInspection;
|
|
59
68
|
} | {
|
|
60
|
-
readonly kind: "
|
|
69
|
+
readonly kind: "local-index-unreadable";
|
|
61
70
|
readonly path: string;
|
|
62
71
|
readonly message: string;
|
|
63
72
|
} | {
|
|
64
73
|
readonly kind: "checkout-failed";
|
|
65
74
|
readonly failure: CheckoutFailure;
|
|
66
75
|
} | {
|
|
67
|
-
readonly kind: "invalid-
|
|
76
|
+
readonly kind: "invalid-runner";
|
|
68
77
|
readonly path: readonly string[];
|
|
69
78
|
readonly problem: string;
|
|
70
79
|
};
|
|
71
|
-
|
|
72
|
-
* Inspects the cache from `cwd` for `recipe`, the runner recipe that applies there, if any. With a recipe, in a Git
|
|
73
|
-
* checkout whose HEAD shares history with one of its base refs, it marks for each team and project the snapshot a run
|
|
74
|
-
* here starts from, by a run's own rule (`classifySnapshotEntries`, `pickSnapshot`), and gives each other
|
|
75
|
-
* snapshot of the recipe the reason it isn't picked. It reads the recipe's declared base files at the merge-base for
|
|
76
|
-
* the run's snapshot key, as a run does. Otherwise it picks none and
|
|
77
|
-
* says why. `all` adds the snapshots of other recipes, and of the recipe's other regions and runtimes, as
|
|
78
|
-
* `other-recipe`. It lists the cache once and classifies that listing, which removes no file, so an expired entry of
|
|
79
|
-
* the recipe stays and is `expired`. A git failure ends it with `checkout-failed`, as it ends a run.
|
|
80
|
-
*/
|
|
81
|
-
export declare function inspectSnapshotCache(context: SnapshotCacheContext, request: {
|
|
80
|
+
export declare function inspectLocalSnapshotIndex(context: LocalSnapshotIndexContext, request: {
|
|
82
81
|
readonly cwd: string;
|
|
83
|
-
readonly
|
|
82
|
+
readonly options: CheckedVercelSandboxOptions | undefined;
|
|
84
83
|
readonly all: boolean;
|
|
85
|
-
}): Promise<
|
|
84
|
+
}): Promise<LocalSnapshotIndexInspectionOutcome>;
|
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
// What the
|
|
2
|
-
// commits, and for the checkout's
|
|
3
|
-
// the
|
|
1
|
+
// What the local snapshot index holds, as a checkout sees it: every indexed snapshot with where it was built, in
|
|
2
|
+
// commits, and for the checkout's runner which one a run here starts from and why not from each other one. It reads
|
|
3
|
+
// the local snapshot index and Git, and changes nothing: no file is removed, nothing is minted, and no sandbox starts.
|
|
4
4
|
import { resolveBase } from "./base.js";
|
|
5
|
-
import { classifySnapshotEntries, isExpiredEntry, pickSnapshot, } from "./snapshot-
|
|
5
|
+
import { classifySnapshotEntries, isExpiredEntry, matchesRunnerTarget, pickSnapshot, resolveAncestorDistances, } from "./local-snapshot-index.js";
|
|
6
6
|
import { snapshotInputsAt } from "./snapshot-key.js";
|
|
7
|
-
|
|
8
|
-
* Inspects the cache from `cwd` for `recipe`, the runner recipe that applies there, if any. With a recipe, in a Git
|
|
9
|
-
* checkout whose HEAD shares history with one of its base refs, it marks for each team and project the snapshot a run
|
|
10
|
-
* here starts from, by a run's own rule (`classifySnapshotEntries`, `pickSnapshot`), and gives each other
|
|
11
|
-
* snapshot of the recipe the reason it isn't picked. It reads the recipe's declared base files at the merge-base for
|
|
12
|
-
* the run's snapshot key, as a run does. Otherwise it picks none and
|
|
13
|
-
* says why. `all` adds the snapshots of other recipes, and of the recipe's other regions and runtimes, as
|
|
14
|
-
* `other-recipe`. It lists the cache once and classifies that listing, which removes no file, so an expired entry of
|
|
15
|
-
* the recipe stays and is `expired`. A git failure ends it with `checkout-failed`, as it ends a run.
|
|
16
|
-
*/
|
|
17
|
-
export async function inspectSnapshotCache(context, request) {
|
|
7
|
+
export async function inspectLocalSnapshotIndex(context, request) {
|
|
18
8
|
const { checkout, runnerSnapshots } = context;
|
|
19
|
-
const {
|
|
9
|
+
const { options } = request;
|
|
20
10
|
const listed = await runnerSnapshots.listEntries();
|
|
21
11
|
if (!listed.ok)
|
|
22
|
-
return { kind: "
|
|
12
|
+
return { kind: "local-index-unreadable", ...listed.failure };
|
|
23
13
|
const { directory, entries, unreadable } = listed.value;
|
|
24
14
|
const now = context.clock.now();
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
entry.region === recipe.region &&
|
|
28
|
-
entry.runtime === recipe.runtime;
|
|
29
|
-
const shows = (entry) => request.all || recipe === undefined || ofRecipe(entry);
|
|
15
|
+
const ofRunner = (entry) => options !== undefined && matchesRunnerTarget(entry, options);
|
|
16
|
+
const shows = (entry) => request.all || options === undefined || ofRunner(entry);
|
|
30
17
|
const shown = entries.filter(shows);
|
|
31
18
|
const root = await checkout.repositoryRoot({ cwd: request.cwd });
|
|
32
19
|
const head = root.ok ? await checkout.head({ repoRoot: root.value }) : undefined;
|
|
@@ -37,41 +24,53 @@ export async function inspectSnapshotCache(context, request) {
|
|
|
37
24
|
directory,
|
|
38
25
|
checkout: null,
|
|
39
26
|
picking: { kind: "none", why: "no-checkout" },
|
|
27
|
+
snapshotKey: null,
|
|
40
28
|
snapshots: shown.map((entry) => unchecked(entry, now)),
|
|
41
29
|
unreadable,
|
|
42
30
|
},
|
|
43
31
|
};
|
|
44
32
|
}
|
|
45
33
|
const repoRoot = root.value;
|
|
46
|
-
const resolved =
|
|
34
|
+
const resolved = options === undefined ? undefined : await resolveBase(checkout, { repoRoot, baseRefs: options.baseRefs });
|
|
47
35
|
if (resolved?.kind === "failed")
|
|
48
36
|
return { kind: "checkout-failed", failure: resolved.failure };
|
|
49
|
-
if (
|
|
37
|
+
if (options === undefined || resolved === undefined || resolved.kind !== "resolved") {
|
|
50
38
|
return {
|
|
51
39
|
kind: "ok",
|
|
52
40
|
inspection: {
|
|
53
41
|
directory,
|
|
54
42
|
checkout: { repoRoot, head: head.value, mergeBase: null },
|
|
55
|
-
picking: { kind: "none", why:
|
|
43
|
+
picking: { kind: "none", why: options === undefined ? "no-runner" : "no-base" },
|
|
44
|
+
snapshotKey: null,
|
|
56
45
|
snapshots: shown.map((entry) => unchecked(entry, now)),
|
|
57
46
|
unreadable,
|
|
58
47
|
},
|
|
59
48
|
};
|
|
60
49
|
}
|
|
61
50
|
const mergeBase = resolved.base;
|
|
62
|
-
const inputs = await snapshotInputsAt(checkout, { repoRoot, base: mergeBase,
|
|
51
|
+
const inputs = await snapshotInputsAt(checkout, { repoRoot, base: mergeBase, options });
|
|
63
52
|
if (!inputs.ok)
|
|
64
|
-
return { kind: "invalid-
|
|
53
|
+
return { kind: "invalid-runner", path: inputs.path, problem: inputs.problem };
|
|
65
54
|
const afterBase = await checkout.commitCount({ repoRoot, from: mergeBase, to: "HEAD" });
|
|
66
55
|
if (!afterBase.ok)
|
|
67
56
|
return { kind: "checkout-failed", failure: afterBase.failure };
|
|
68
|
-
// The one listing above is classified as a run would,
|
|
57
|
+
// The one listing above is classified as a run would, with ancestors of the merge-base allowed, and nothing is
|
|
58
|
+
// removed: an expired entry is `expired`.
|
|
59
|
+
const ancestorDistances = await resolveAncestorDistances(context, {
|
|
60
|
+
repoRoot,
|
|
61
|
+
entries,
|
|
62
|
+
options,
|
|
63
|
+
mergeBase,
|
|
64
|
+
});
|
|
65
|
+
if (!ancestorDistances.ok)
|
|
66
|
+
return { kind: "checkout-failed", failure: ancestorDistances.failure };
|
|
69
67
|
const read = classifySnapshotEntries(context, {
|
|
70
68
|
entries,
|
|
71
|
-
|
|
69
|
+
options,
|
|
72
70
|
base: mergeBase,
|
|
73
71
|
snapshotKey: inputs.key,
|
|
74
72
|
commitsAfterBase: afterBase.value,
|
|
73
|
+
ancestorDistances: ancestorDistances.value,
|
|
75
74
|
});
|
|
76
75
|
// The choice is per team and project, since the credential that names them isn't minted here. Every entry that isn't
|
|
77
76
|
// a candidate keeps the classification's reason, since it is ruled out whoever the run's credential names.
|
|
@@ -82,7 +81,12 @@ export async function inspectSnapshotCache(context, request) {
|
|
|
82
81
|
if (pick !== undefined)
|
|
83
82
|
picked.add(pick);
|
|
84
83
|
}
|
|
85
|
-
const place = historyPlacer(context, {
|
|
84
|
+
const place = historyPlacer(context, {
|
|
85
|
+
repoRoot,
|
|
86
|
+
mergeBase,
|
|
87
|
+
commitsAfterBase: afterBase.value,
|
|
88
|
+
ancestorDistances: ancestorDistances.value,
|
|
89
|
+
});
|
|
86
90
|
const snapshots = [];
|
|
87
91
|
for (const verdict of read.verdicts) {
|
|
88
92
|
const { entry } = verdict;
|
|
@@ -95,6 +99,7 @@ export async function inspectSnapshotCache(context, request) {
|
|
|
95
99
|
entry,
|
|
96
100
|
inHistory: true,
|
|
97
101
|
builtBehind: candidate.builtBehind,
|
|
102
|
+
commitsBehindMergeBase: candidate.commitsBehindMergeBase,
|
|
98
103
|
expired,
|
|
99
104
|
picked: picked.has(candidate),
|
|
100
105
|
reason: null,
|
|
@@ -108,28 +113,35 @@ export async function inspectSnapshotCache(context, request) {
|
|
|
108
113
|
snapshots.push({
|
|
109
114
|
entry,
|
|
110
115
|
...placed.value,
|
|
116
|
+
commitsBehindMergeBase: null,
|
|
111
117
|
expired,
|
|
112
118
|
picked: false,
|
|
113
|
-
reason: verdict.kind === "rejected" ? verdict.rejection.reason : "other-
|
|
119
|
+
reason: verdict.kind === "rejected" ? verdict.rejection.reason : "other-runner",
|
|
114
120
|
});
|
|
115
121
|
}
|
|
116
122
|
return {
|
|
117
123
|
kind: "ok",
|
|
118
124
|
inspection: {
|
|
119
125
|
directory,
|
|
120
|
-
checkout: {
|
|
121
|
-
|
|
126
|
+
checkout: {
|
|
127
|
+
repoRoot,
|
|
128
|
+
head: head.value,
|
|
129
|
+
mergeBase: { commit: mergeBase, ref: resolved.ref, commitsAfterBase: afterBase.value },
|
|
130
|
+
},
|
|
131
|
+
picking: { kind: "runner", runner: options.name },
|
|
132
|
+
snapshotKey: inputs.key,
|
|
122
133
|
snapshots,
|
|
123
134
|
unreadable,
|
|
124
135
|
},
|
|
125
136
|
};
|
|
126
137
|
}
|
|
127
|
-
/** An entry storm checked nothing of: outside a Git checkout, or with no
|
|
138
|
+
/** An entry storm checked nothing of: outside a Git checkout, or with no runner or no base to pick for. */
|
|
128
139
|
function unchecked(entry, now) {
|
|
129
140
|
return {
|
|
130
141
|
entry,
|
|
131
142
|
inHistory: null,
|
|
132
143
|
builtBehind: null,
|
|
144
|
+
commitsBehindMergeBase: null,
|
|
133
145
|
expired: isExpiredEntry(entry, now),
|
|
134
146
|
picked: false,
|
|
135
147
|
reason: null,
|
|
@@ -137,12 +149,17 @@ function unchecked(entry, now) {
|
|
|
137
149
|
}
|
|
138
150
|
/**
|
|
139
151
|
* Where a base sits in HEAD's history, for the list: whether HEAD is it or holds it, and if so how many commits HEAD
|
|
140
|
-
* has that it lacks. Git is asked at most once per base, and nothing for the merge-base
|
|
152
|
+
* has that it lacks. Git is asked at most once per base, and nothing for the merge-base or an ancestor of it, whose
|
|
153
|
+
* counts the caller has.
|
|
141
154
|
*/
|
|
142
155
|
function historyPlacer(context, request) {
|
|
143
156
|
const { repoRoot } = request;
|
|
144
157
|
const known = new Map([
|
|
145
158
|
[request.mergeBase, { inHistory: true, builtBehind: request.commitsAfterBase }],
|
|
159
|
+
...Object.entries(request.ancestorDistances).map(([base, commitsBehindMergeBase]) => [
|
|
160
|
+
base,
|
|
161
|
+
{ inHistory: true, builtBehind: request.commitsAfterBase + commitsBehindMergeBase },
|
|
162
|
+
]),
|
|
146
163
|
]);
|
|
147
164
|
return async (base) => {
|
|
148
165
|
const answer = known.get(base);
|