@cnc-tools/storm 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.js +5 -1
- package/dist/bin/storm.js +6 -2
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-FK4RLDEK.js → chunk-27P2QSIM.js} +1 -1
- package/dist/chunks/{chunk-ODQHQJLE.js → chunk-5ED3IDUJ.js} +749 -1121
- package/dist/chunks/{chunk-FSP3SJ35.js → chunk-5TMHYH7G.js} +16 -46
- package/dist/chunks/{chunk-Y3BUNNRG.js → chunk-BFLYGMG3.js} +12 -7
- package/dist/chunks/{chunk-LQKNI3EG.js → chunk-BRUIATTR.js} +6 -6
- package/dist/chunks/{chunk-RYRJNHL7.js → chunk-HOKDKP5A.js} +3 -9
- package/dist/chunks/{chunk-SXW6XN4R.js → chunk-IVRRGGCD.js} +60 -20
- package/dist/chunks/{chunk-TMQQYHUX.js → chunk-QBR5VHJ7.js} +1 -1
- package/dist/chunks/{chunk-YT5OROR7.js → chunk-RA4L2ACU.js} +12 -2
- package/dist/chunks/{chunk-TEEZL3GA.js → chunk-RKONDLPS.js} +17 -71
- package/dist/chunks/{chunk-IYM44FUX.js → chunk-UC6DULWY.js} +2 -2
- package/dist/chunks/{chunk-4XT5RC5T.js → chunk-XPCUINWS.js} +6 -42
- package/dist/chunks/{chunk-U7M3ZB3Z.js → chunk-YBPTMJUM.js} +123 -180
- package/dist/chunks/{chunk-ISGQJIQM.js → chunk-Z5OXOZD3.js} +125 -83
- package/dist/chunks/{chunk-7D6LC5JY.js → chunk-ZH5R7W4A.js} +7 -39
- package/dist/chunks/{live-app-AZ5N5HBD.js → live-app-FBVWUUMT.js} +7 -7
- package/dist/commands/exec/command.d.ts +4 -90
- package/dist/commands/exec/command.js +15 -41
- package/dist/commands/exec/define-run-command.d.ts +19 -100
- package/dist/commands/exec/define-run-command.js +48 -15
- package/dist/commands/exec/driver-plan.d.ts +24 -16
- package/dist/commands/exec/driver-plan.js +34 -15
- package/dist/commands/exec/driver-refusals.js +7 -6
- package/dist/commands/exec/exec-words.d.ts +1 -1
- package/dist/commands/exec/exec-words.js +8 -2
- package/dist/commands/exec/final-results.d.ts +39 -0
- package/dist/commands/exec/final-results.js +29 -0
- package/dist/commands/exec/live-view.js +18 -22
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +15 -109
- package/dist/commands/exec/outcomes.js +25 -39
- package/dist/commands/exec/plan-run.d.ts +11 -3
- package/dist/commands/exec/plan-run.js +3 -2
- package/dist/commands/exec/progress.d.ts +3 -19
- package/dist/commands/exec/progress.js +16 -60
- package/dist/commands/exec/run-command.d.ts +5 -24
- package/dist/commands/exec/run-command.js +32 -84
- package/dist/commands/exec/run-metadata.d.ts +0 -6
- package/dist/commands/exec/run-metadata.js +2 -8
- package/dist/commands/exec/snapshot-text.d.ts +7 -16
- package/dist/commands/exec/snapshot-text.js +9 -49
- package/dist/commands/exec/test-plan.d.ts +2 -1
- package/dist/commands/exec/test-plan.js +13 -4
- package/dist/commands/exec/tests-summary.d.ts +2 -2
- package/dist/commands/exec/view.js +2 -12
- package/dist/commands/exec/worker-chart.d.ts +1 -1
- package/dist/commands/playwright/command.d.ts +12 -97
- package/dist/commands/playwright/command.js +14 -14
- package/dist/commands/playwright/metadata.js +2 -2
- package/dist/commands/runs/facts.d.ts +1 -37
- package/dist/commands/runs/facts.js +4 -36
- package/dist/commands/runs/list/command.d.ts +0 -72
- package/dist/commands/runs/list/command.js +6 -6
- package/dist/commands/runs/list/outcomes.d.ts +0 -36
- package/dist/commands/runs/logs/command.js +6 -6
- package/dist/commands/runs/show/command.d.ts +2 -74
- package/dist/commands/runs/show/command.js +16 -43
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +1 -37
- package/dist/commands/runs/show/outcomes.js +8 -42
- package/dist/commands/snapshots/build/command.d.ts +14 -411
- package/dist/commands/snapshots/build/command.js +59 -234
- package/dist/commands/snapshots/build/metadata.js +10 -7
- package/dist/commands/snapshots/build/outcomes.d.ts +11 -241
- package/dist/commands/snapshots/build/outcomes.js +29 -196
- package/dist/commands/snapshots/list/command.d.ts +2 -36
- package/dist/commands/snapshots/list/command.js +20 -56
- package/dist/commands/snapshots/list/metadata.js +1 -1
- package/dist/commands/snapshots/list/outcomes.d.ts +2 -37
- package/dist/commands/snapshots/list/outcomes.js +13 -53
- package/dist/commands/vitest/command.d.ts +14 -98
- package/dist/commands/vitest/command.js +14 -14
- package/dist/commands/vitest/metadata.js +2 -2
- package/dist/config/resolve.d.ts +1 -1
- package/dist/config/resolve.js +2 -1
- package/dist/config/schema.d.ts +8 -0
- package/dist/config/schema.js +5 -4
- package/dist/core/events.d.ts +5 -6
- package/dist/core/run-state.d.ts +7 -29
- package/dist/core/run-state.js +3 -26
- package/dist/core/run.d.ts +6 -14
- package/dist/core/run.js +17 -28
- package/dist/extensions/playwright/driver.js +17 -10
- package/dist/extensions/testserver/commands/pool/create/command.js +4 -4
- package/dist/extensions/testserver/commands/pool/list/command.js +2 -2
- package/dist/extensions/testserver/definition.d.ts +1 -1
- package/dist/extensions/testserver/extension.d.ts +1 -1
- package/dist/extensions/testserver/options/rules.d.ts +3 -3
- package/dist/extensions/testserver/options/rules.js +5 -5
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/vercel-cli/index.d.ts +1 -0
- package/dist/extensions/testserver/vercel-cli/index.js +1 -0
- package/dist/extensions/testserver/vercel-cli/report.js +5 -2
- package/dist/extensions/testserver/vercel-cli/session-id.d.ts +8 -0
- package/dist/extensions/testserver/vercel-cli/session-id.js +16 -0
- package/dist/extensions/testserver/vitest/config.d.ts +2 -2
- package/dist/extensions/testserver/vitest/config.js +2 -2
- package/dist/extensions/testserver/vitest/container-scope.d.ts +25 -16
- package/dist/extensions/testserver/vitest/container-scope.js +32 -13
- package/dist/extensions/testserver/vitest/diagnostics.d.ts +5 -4
- package/dist/extensions/testserver/vitest/diagnostics.js +15 -8
- package/dist/extensions/testserver/vitest/fixtures.d.ts +10 -1
- package/dist/extensions/testserver/vitest/fixtures.js +36 -10
- package/dist/extensions/testserver/vitest/types.d.ts +9 -0
- package/dist/extensions/vitest/driver.js +28 -14
- package/dist/extensions/vitest/plan/gateways.d.ts +28 -5
- package/dist/extensions/vitest/plan/gateways.js +2 -2
- package/dist/extensions/vitest/plan/list-output.d.ts +5 -0
- package/dist/extensions/vitest/plan/list-output.js +23 -9
- package/dist/extensions/vitest/plan/live/list-gateway.d.ts +3 -2
- package/dist/extensions/vitest/plan/live/list-gateway.js +77 -64
- package/dist/extensions/vitest/plan/plan-over.d.ts +19 -7
- package/dist/extensions/vitest/plan/plan-over.js +18 -7
- package/dist/extensions/vitest/plan/plan.d.ts +14 -5
- package/dist/extensions/vitest/plan/plan.js +23 -9
- package/dist/extensions.d.ts +2 -2
- package/dist/run-directory/index.d.ts +1 -1
- package/dist/run-directory/index.js +0 -1
- package/dist/run-directory/plan.d.ts +3 -2
- package/dist/run-directory/plan.js +6 -3
- package/dist/run-directory/recording.js +2 -2
- package/dist/run-directory/run-record.d.ts +18 -135
- package/dist/run-directory/run-record.js +8 -68
- package/dist/runner/build-snapshots.d.ts +50 -114
- package/dist/runner/build-snapshots.js +70 -159
- package/dist/runner/events.d.ts +4 -88
- package/dist/runner/gateways.d.ts +5 -23
- package/dist/runner/index.d.ts +5 -6
- package/dist/runner/index.js +1 -1
- package/dist/runner/live/snapshot-records.js +7 -18
- package/dist/runner/prepare.d.ts +11 -22
- package/dist/runner/prepare.js +6 -17
- package/dist/runner/ready.d.ts +16 -45
- package/dist/runner/ready.js +34 -59
- package/dist/runner/recipe.d.ts +5 -45
- package/dist/runner/recipe.js +0 -41
- package/dist/runner/sandboxed-command.d.ts +5 -3
- package/dist/runner/sandboxed-command.js +10 -4
- package/dist/runner/scope.d.ts +8 -25
- package/dist/runner/scope.js +4 -8
- package/dist/runner/session.d.ts +18 -65
- package/dist/runner/session.js +15 -83
- package/dist/runner/snapshot-build.d.ts +2 -2
- package/dist/runner/snapshot-cache.d.ts +22 -74
- package/dist/runner/snapshot-cache.js +15 -107
- package/dist/runner/snapshot-inspect.d.ts +9 -13
- package/dist/runner/snapshot-inspect.js +48 -57
- package/dist/runner/snapshot-key.d.ts +9 -14
- package/dist/runner/snapshot-key.js +15 -22
- package/dist/sdk/extension/driver.d.ts +32 -6
- package/dist/sdk/extension/driver.js +12 -2
- package/dist/sdk/extension/index.d.ts +1 -1
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +6 -5
- package/dist/vendor/testserver-sdk/container/api-request.d.ts +2 -3
- package/dist/vendor/testserver-sdk/container/api-request.js +2 -3
- package/dist/vendor/testserver-sdk/container/container.d.ts +12 -2
- package/dist/vendor/testserver-sdk/container/container.js +10 -7
- package/dist/vendor/testserver-sdk/container/recorder.d.ts +29 -7
- package/dist/vendor/testserver-sdk/container/recorder.js +26 -14
- package/dist/vendor/testserver-sdk/index.d.ts +1 -1
- package/dist/vendor/testserver-sdk/index.js +1 -1
- package/dist/vendor/testserver-sdk/proxy/exchange.d.ts +24 -5
- package/dist/vendor/testserver-sdk/proxy/exchange.js +43 -25
- package/dist/vendor/testserver-sdk/proxy/faulted-exchange.js +15 -10
- package/dist/vendor/testserver-sdk/proxy/faults.d.ts +6 -5
- package/dist/vendor/testserver-sdk/proxy/proxy.d.ts +10 -1
- package/dist/vendor/testserver-sdk/proxy/proxy.js +5 -3
- package/dist/vendor/testserver-sdk/proxy/records.d.ts +17 -17
- package/dist/vendor/testserver-sdk/proxy/records.js +18 -17
- package/dist/vendor/testserver-sdk/records/body.d.ts +7 -9
- package/dist/vendor/testserver-sdk/records/body.js +10 -15
- package/dist/vendor/testserver-sdk/records/headers.d.ts +79 -0
- package/dist/vendor/testserver-sdk/records/headers.js +162 -0
- package/dist/vendor/testserver-sdk/records/index.d.ts +2 -1
- package/dist/vendor/testserver-sdk/records/index.js +4 -2
- package/dist/vendor/testserver-sdk/records/records.d.ts +19 -10
- package/package.json +5 -4
- package/skills/overview.md +5 -5
- package/skills/read-run-output.md +8 -9
- package/dist/runner/snapshot-save.d.ts +0 -70
- package/dist/runner/snapshot-save.js +0 -160
- package/dist/runner/snapshot-start.d.ts +0 -25
- package/dist/runner/snapshot-start.js +0 -16
- package/skills/testserver-builds.md +0 -82
package/dist/runner/session.js
CHANGED
|
@@ -1,57 +1,25 @@
|
|
|
1
1
|
// A runner session: everything one run does in its runner sandbox, in order. It owns the run's sandbox scope from
|
|
2
|
-
// before the run mints to the run's end, readies the runner sandbox, runs the command in the sandbox it readied,
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
import { obtainSnapshot, readyRunner } from "./ready.js";
|
|
2
|
+
// before the run mints to the run's end, readies the runner sandbox, runs the command in the sandbox it readied, and
|
|
3
|
+
// closes the scope before it releases the run's resources. The run hands it what releasing its resources and reporting
|
|
4
|
+
// cleanup's start take. The scope and the stopping line take the keep time from the session's request.
|
|
5
|
+
import { readyRunner } from "./ready.js";
|
|
7
6
|
import { runCommandInSandbox } from "./sandboxed-command.js";
|
|
8
7
|
import { runnerSandboxScope } from "./scope.js";
|
|
9
|
-
import { isDevEntry } from "./snapshot-cache.js";
|
|
10
|
-
import { saveDevSnapshot } from "./snapshot-save.js";
|
|
11
|
-
import { chooseSnapshotStart } from "./snapshot-start.js";
|
|
12
|
-
/** Whether `runner` started from a dev snapshot a run at HEAD commit `head` saved. */
|
|
13
|
-
function savedAt(runner, head) {
|
|
14
|
-
const { startedFrom } = runner;
|
|
15
|
-
return isDevEntry(startedFrom) && startedFrom.head === head;
|
|
16
|
-
}
|
|
17
|
-
/** Decides, from how the command ended, the signal, the save mode, and HEAD's commit, whether `finish` saves. */
|
|
18
|
-
function saveDecision(ended, signal, mode, head) {
|
|
19
|
-
if (ended === undefined || signal.aborted)
|
|
20
|
-
return { kind: "none" };
|
|
21
|
-
if (mode.kind === "never")
|
|
22
|
-
return { kind: "skip", reason: mode.reason };
|
|
23
|
-
if (mode.kind === "always")
|
|
24
|
-
return { kind: "save", runner: ended.runner };
|
|
25
|
-
if (ended.exitCode !== 0)
|
|
26
|
-
return { kind: "skip", reason: "command-failed" };
|
|
27
|
-
if (savedAt(ended.runner, head))
|
|
28
|
-
return { kind: "skip", reason: "already-saved" };
|
|
29
|
-
return { kind: "save", runner: ended.runner };
|
|
30
|
-
}
|
|
31
8
|
/**
|
|
32
|
-
* Opens a run's runner session over `context`, reporting to `progress`: it opens the sandbox scope, which
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* the session reports `stopping`, with whether the command runs and that keep time, before the scope starts to close.
|
|
9
|
+
* Opens a run's runner session over `context`, reporting to `progress`: it opens the sandbox scope, which keeps the
|
|
10
|
+
* runner sandbox for the request's keep time as it closes, and listens for `signal`. On its first abort, the session
|
|
11
|
+
* reports `stopping`, with whether the command runs and the keep time, before the scope starts to close.
|
|
36
12
|
*/
|
|
37
13
|
export function openRunnerSession(context, request, control, progress) {
|
|
38
14
|
const { signal, cleanup } = control;
|
|
39
|
-
|
|
40
|
-
const unsaved = { kind: "keep", ms: request.keepMs };
|
|
41
|
-
// Set in the same turn as the decision that starts a save, so the stopping line and the scope, which both read
|
|
42
|
-
// `keepMs`, never disagree about the runner sandbox.
|
|
43
|
-
let saveStarted = false;
|
|
44
|
-
const keepMs = () => (saveStarted ? 0 : request.keepMs);
|
|
45
|
-
const scope = runnerSandboxScope(context, progress, { keepMs });
|
|
15
|
+
const scope = runnerSandboxScope(context, progress, { keepMs: request.keepMs });
|
|
46
16
|
const closeScope = async () => ({ ...(await scope.close()), target: request.target });
|
|
47
17
|
let readying = false;
|
|
48
18
|
let readied;
|
|
49
19
|
let commandRunning = false;
|
|
50
|
-
// The runner sandbox the command ended in on its own, the one a save saves, and the exit code it ended with.
|
|
51
|
-
let ended;
|
|
52
20
|
// Said before the close starts, so the stopping line comes before any line the close's waits print.
|
|
53
21
|
const stop = () => {
|
|
54
|
-
void progress.emit({ kind: "stopping", commandRunning, keepMs: keepMs
|
|
22
|
+
void progress.emit({ kind: "stopping", commandRunning, keepMs: request.keepMs }).catch(() => undefined);
|
|
55
23
|
void scope.close().catch(() => undefined);
|
|
56
24
|
};
|
|
57
25
|
if (signal.aborted)
|
|
@@ -64,12 +32,7 @@ export function openRunnerSession(context, request, control, progress) {
|
|
|
64
32
|
throw new Error("the runner session readies its runner sandbox once");
|
|
65
33
|
readying = true;
|
|
66
34
|
const { prepared, user, secrets } = request;
|
|
67
|
-
const
|
|
68
|
-
const start = chooseSnapshotStart(prepared, access);
|
|
69
|
-
const obtained = await obtainSnapshot(context, { prepared, access, user, secrets, start }, lane, progress);
|
|
70
|
-
if (obtained.kind !== "ok")
|
|
71
|
-
return obtained;
|
|
72
|
-
const outcome = await readyRunner(context, { prepared, access, user, secrets, start: obtained.value }, lane, progress);
|
|
35
|
+
const outcome = await readyRunner(context, { prepared, access, user, secrets }, { scope, signal: laneSignal }, progress);
|
|
73
36
|
if (outcome.kind === "ready")
|
|
74
37
|
readied = outcome.runner;
|
|
75
38
|
return outcome;
|
|
@@ -78,51 +41,20 @@ export function openRunnerSession(context, request, control, progress) {
|
|
|
78
41
|
if (readied === undefined)
|
|
79
42
|
throw new Error("the runner session's runner sandbox isn't ready");
|
|
80
43
|
commandRunning = true;
|
|
81
|
-
|
|
44
|
+
return await runCommandInSandbox(context, {
|
|
82
45
|
runner: readied,
|
|
83
46
|
argv: command.argv,
|
|
84
47
|
runPayload: command.runPayload,
|
|
85
48
|
...(command.testEvents === undefined ? {} : { testEvents: command.testEvents }),
|
|
86
49
|
}, { kill: signal }, progress);
|
|
87
|
-
if (ran.kind === "exited")
|
|
88
|
-
ended = { runner: readied, exitCode: ran.exitCode };
|
|
89
|
-
return ran;
|
|
90
50
|
},
|
|
91
51
|
async finish() {
|
|
92
52
|
commandRunning = false;
|
|
93
|
-
|
|
94
|
-
let save = null;
|
|
95
|
-
let noSave = null;
|
|
96
|
-
let action = unsaved;
|
|
97
|
-
const decision = saveDecision(ended, signal, request.save, prepared.head.commit);
|
|
98
|
-
switch (decision.kind) {
|
|
99
|
-
case "none":
|
|
100
|
-
break;
|
|
101
|
-
case "skip":
|
|
102
|
-
noSave = decision.reason;
|
|
103
|
-
await progress.emit({ kind: "dev-snapshot-skipped", reason: noSave });
|
|
104
|
-
break;
|
|
105
|
-
case "save": {
|
|
106
|
-
saveStarted = true;
|
|
107
|
-
const plan = { kind: "save", branch: prepared.head.branch };
|
|
108
|
-
action = plan;
|
|
109
|
-
const saving = saveDevSnapshot(context, { ready: decision.runner, branch: plan.branch, head: prepared.head.commit }, { scope, signal }, progress);
|
|
110
|
-
// The save settles before the scope closes, even when releasing the resources threw.
|
|
111
|
-
try {
|
|
112
|
-
await cleanup.release(plan);
|
|
113
|
-
}
|
|
114
|
-
finally {
|
|
115
|
-
save = (await saving).save;
|
|
116
|
-
}
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
await cleanup.startCleanup(action);
|
|
53
|
+
await cleanup.startCleanup();
|
|
121
54
|
const facts = await closeScope();
|
|
122
55
|
signal.removeEventListener("abort", stop);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return { save, noSave, cleanup: facts };
|
|
56
|
+
await cleanup.release();
|
|
57
|
+
return facts;
|
|
126
58
|
},
|
|
127
59
|
async close() {
|
|
128
60
|
signal.removeEventListener("abort", stop);
|
|
@@ -131,7 +63,7 @@ export function openRunnerSession(context, request, control, progress) {
|
|
|
131
63
|
return await closeScope();
|
|
132
64
|
}
|
|
133
65
|
finally {
|
|
134
|
-
await cleanup.release(
|
|
66
|
+
await cleanup.release();
|
|
135
67
|
}
|
|
136
68
|
},
|
|
137
69
|
};
|
|
@@ -18,11 +18,11 @@ export interface BuiltSnapshot {
|
|
|
18
18
|
readonly cacheFailure: RunnerSnapshotCacheFailure | null;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* What a base snapshot build reads of a prepared run, or of a `storm snapshots build
|
|
21
|
+
* What a base snapshot build reads of a prepared run, or of a `storm snapshots build` plan: the recipe, the
|
|
22
22
|
* checkout, the base, its snapshot steps and key, and how many commits HEAD has after the base.
|
|
23
23
|
*/
|
|
24
24
|
export interface BaseSnapshotPlan extends Pick<PreparedRunner, "recipe" | "repoRoot" | "base" | "toolchains" | "prebuild" | "snapshotKey"> {
|
|
25
|
-
/** How many commits HEAD has after the base; null for a `--base` commit that isn't
|
|
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 runner secrets, and why it builds. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Clock } from "../time/index.ts";
|
|
2
|
-
import type { CheckoutGateway,
|
|
3
|
-
import type { CheckedRecipe
|
|
2
|
+
import type { CheckoutGateway, RunnerSnapshotCacheFailure, RunnerSnapshotCacheGateway, RunnerSnapshotEntry } from "./gateways.ts";
|
|
3
|
+
import type { CheckedRecipe } from "./recipe.ts";
|
|
4
4
|
/** The subpath of storm's state directory that holds the runner snapshot cache. */
|
|
5
5
|
export declare const RUNNER_SNAPSHOTS_SUBPATH: readonly string[];
|
|
6
6
|
/** How long a runner snapshot lives after it is built: 7 days. The Sandbox API needs 0 or at least a day. */
|
|
@@ -9,22 +9,10 @@ export declare const SNAPSHOT_EXPIRATION_MS: number;
|
|
|
9
9
|
export declare const SNAPSHOT_MIN_REMAINING_MS: number;
|
|
10
10
|
/**
|
|
11
11
|
* An entry's identity: the first 32 hex characters of sha256 over its team id, project id, region, runtime, recipe
|
|
12
|
-
* name
|
|
13
|
-
*
|
|
14
|
-
* snapshot's at its base, and a dev snapshot's replaces only the one its checkout saved at the same commit. The
|
|
15
|
-
* branch and, for a dev snapshot, the base are no part of it. A base snapshot's identity is the one it had before dev
|
|
16
|
-
* snapshots existed.
|
|
12
|
+
* name, snapshot key and base, joined with NUL. Entries with one identity replace each other, so a team and project
|
|
13
|
+
* have one entry per recipe, key and base.
|
|
17
14
|
*/
|
|
18
15
|
export declare function snapshotEntryIdentity(entry: RunnerSnapshotEntry): string;
|
|
19
|
-
/** A cache entry that records a dev snapshot: it has the commit that saved it and the checkout's root. */
|
|
20
|
-
export type DevSnapshotEntry = RunnerSnapshotEntry & {
|
|
21
|
-
readonly head: string;
|
|
22
|
-
readonly repoRoot: string;
|
|
23
|
-
};
|
|
24
|
-
/** Whether `entry` records a dev snapshot, saved from a runner sandbox, rather than a base snapshot. */
|
|
25
|
-
export declare function isDevEntry(entry: RunnerSnapshotEntry): entry is DevSnapshotEntry;
|
|
26
|
-
/** The commit `entry`'s snapshot was built at: a dev snapshot's is the commit that saved it, a base snapshot's its base. */
|
|
27
|
-
export declare function builtAtCommit(entry: RunnerSnapshotEntry): string;
|
|
28
16
|
/** The name of the file that records `entry`: its identity and `.json`. */
|
|
29
17
|
export declare function snapshotEntryFileName(entry: RunnerSnapshotEntry): string;
|
|
30
18
|
/** Whether `entry`'s snapshot has expired at `now`. */
|
|
@@ -32,17 +20,14 @@ export declare function isExpiredEntry(entry: RunnerSnapshotEntry, now: Date): b
|
|
|
32
20
|
/** Whether `entry`'s snapshot has more than `SNAPSHOT_MIN_REMAINING_MS` left at `now`. */
|
|
33
21
|
export declare function hasTimeLeft(entry: RunnerSnapshotEntry, now: Date): boolean;
|
|
34
22
|
/**
|
|
35
|
-
* A cache entry a run may start from, before the team and project are known: its base is the run's merge-base
|
|
36
|
-
* snapshot key is the run's,
|
|
37
|
-
* behind HEAD.
|
|
23
|
+
* A cache entry a run may start from, before the team and project are known: its base is the run's merge-base and its
|
|
24
|
+
* snapshot key is the run's, with how far that base is behind HEAD.
|
|
38
25
|
*/
|
|
39
26
|
export interface RunnerSnapshotCandidate {
|
|
40
27
|
readonly entry: RunnerSnapshotEntry;
|
|
41
|
-
/** The commit the snapshot was built at (`builtAtCommit`), a full SHA. */
|
|
42
|
-
readonly builtAt: string;
|
|
43
28
|
/**
|
|
44
|
-
* How many commits HEAD has that the
|
|
45
|
-
*
|
|
29
|
+
* How many commits HEAD has that the merge-base lacks: what the install and the build have left to do. 0 when HEAD
|
|
30
|
+
* is the merge-base.
|
|
46
31
|
*/
|
|
47
32
|
readonly builtBehind: number;
|
|
48
33
|
}
|
|
@@ -52,21 +37,15 @@ export interface RunnerSnapshotCandidate {
|
|
|
52
37
|
* - `expired`: it has expired. A run's path removes the file first (`removeExpiredEntries`), so only a list of
|
|
53
38
|
* entries that still holds it, as `storm snapshots list`'s does, gets this reason.
|
|
54
39
|
* - `expires-soon`: it has `SNAPSHOT_MIN_REMAINING_MS` or less left.
|
|
55
|
-
* - `other-
|
|
56
|
-
*
|
|
57
|
-
* - `not-trusted`: it is a dev snapshot, and the recipe doesn't trust dev snapshots (`DevSnapshotReuse`).
|
|
58
|
-
* - `other-base`: its base isn't the run's merge-base.
|
|
40
|
+
* - `other-base`: its base isn't the run's merge-base. A run starts only from a snapshot built at its merge-base,
|
|
41
|
+
* which a base ref holds, so no snapshot built from a branch's own commits carries over into a run.
|
|
59
42
|
* - `steps-changed`: its snapshot key isn't the run's, the one the recipe's snapshot steps give at the merge-base.
|
|
60
|
-
* - `not-in-history`: it is a dev snapshot, and the commit that saved it is neither HEAD nor in HEAD's history.
|
|
61
43
|
* - `other-owner`: it was built for another team or project than the run's credential names.
|
|
62
|
-
* - `not-picked`: it is a candidate that a run here doesn't start from, since the pick preferred another one: one
|
|
63
|
-
* built at a commit fewer commits behind HEAD, or at the same commit a dev snapshot. Only the inspection gives it
|
|
64
|
-
* (`inspectSnapshotCache`): a run that builds picked none, so it passed over none of its own.
|
|
65
44
|
*
|
|
66
|
-
* The classification gives all but the last
|
|
45
|
+
* The classification gives all but the last, in that order of checks (`classifySnapshotEntries`); `other-owner`
|
|
67
46
|
* needs the team and project (`snapshotRejections`).
|
|
68
47
|
*/
|
|
69
|
-
export type SnapshotRejectionReason = "expired" | "expires-soon" | "other-
|
|
48
|
+
export type SnapshotRejectionReason = "expired" | "expires-soon" | "other-base" | "steps-changed" | "other-owner";
|
|
70
49
|
/** A cached snapshot of the run's recipe that the run doesn't start from, and why. */
|
|
71
50
|
export interface RejectedSnapshot {
|
|
72
51
|
readonly entry: RunnerSnapshotEntry;
|
|
@@ -134,29 +113,21 @@ export interface SnapshotCacheContext {
|
|
|
134
113
|
export declare function removeExpiredEntries(context: Pick<SnapshotCacheContext, "runnerSnapshots" | "clock">): Promise<SnapshotCacheListing>;
|
|
135
114
|
/**
|
|
136
115
|
* Classifies `entries`, cache entries a caller listed, for a run of `recipe`: which ones it may start from, and why
|
|
137
|
-
* not from each other one of the recipe's. It changes no file. Of the entries for the recipe's
|
|
138
|
-
* name it keeps the ones with more than an hour left whose base is the run's merge-base
|
|
139
|
-
* key is the run's
|
|
140
|
-
*
|
|
141
|
-
* longer counts, and none unless `devSnapshots` is `reuse`. HEAD's branch is no part of it: another checkout may hold
|
|
142
|
-
* other code, so its dev snapshot never carries over, whatever its branch. Every other entry of the recipe is
|
|
143
|
-
* `rejected`, with the first reason that rules it out, an expired one as `expired`. Each entry gets exactly one
|
|
144
|
-
* verdict. Git is asked once per dev snapshot commit whether HEAD holds it and, for a candidate, how far behind HEAD it
|
|
145
|
-
* is; a git failure ends the classification with that failure.
|
|
116
|
+
* not from each other one of the recipe's. It changes no file and asks Git nothing. Of the entries for the recipe's
|
|
117
|
+
* region, runtime and name it keeps the ones with more than an hour left whose base is the run's merge-base and whose
|
|
118
|
+
* snapshot key is the run's. Every other entry of the recipe is `rejected`, with the first reason that rules it out,
|
|
119
|
+
* an expired one as `expired`. Each entry gets exactly one verdict, in the order given.
|
|
146
120
|
*/
|
|
147
|
-
export declare function classifySnapshotEntries(context: Pick<SnapshotCacheContext, "
|
|
121
|
+
export declare function classifySnapshotEntries(context: Pick<SnapshotCacheContext, "clock">, request: {
|
|
148
122
|
readonly entries: readonly RunnerSnapshotEntry[];
|
|
149
|
-
readonly repoRoot: string;
|
|
150
123
|
readonly recipe: Pick<CheckedRecipe, "name" | "region" | "runtime">;
|
|
151
124
|
/** The run's base, HEAD's merge-base with a base ref: a candidate's base is this one. */
|
|
152
125
|
readonly base: string;
|
|
153
126
|
/** The run's snapshot key, the recipe's snapshot steps at `base`: a candidate's key is this one. */
|
|
154
127
|
readonly snapshotKey: string;
|
|
155
|
-
/** How many commits HEAD has that `base` lacks:
|
|
128
|
+
/** How many commits HEAD has that `base` lacks: each candidate's `builtBehind`. */
|
|
156
129
|
readonly commitsAfterBase: number;
|
|
157
|
-
|
|
158
|
-
readonly devSnapshots: DevSnapshotReuse;
|
|
159
|
-
}): Promise<CheckoutResult<SnapshotClassification>>;
|
|
130
|
+
}): SnapshotClassification;
|
|
160
131
|
/**
|
|
161
132
|
* Why a run for `owner`'s team and project starts from none of the recipe's cached snapshots, when the pick found no
|
|
162
133
|
* candidate of theirs: every candidate is then another team's or project's, `other-owner`; an entry for another team
|
|
@@ -167,34 +138,11 @@ export declare function snapshotRejections(read: SnapshotCacheRead, owner: {
|
|
|
167
138
|
readonly projectId: string;
|
|
168
139
|
}): RejectedSnapshot[];
|
|
169
140
|
/**
|
|
170
|
-
* Picks the runner snapshot a run starts from, once the credential names its team and project
|
|
171
|
-
* them
|
|
172
|
-
*
|
|
173
|
-
* an ancestor of is the fewest commits behind; on separate lines of a merged history, the one with the least left to
|
|
174
|
-
* install and build wins. Identities make the answer unique: a team and project have one base snapshot at the
|
|
175
|
-
* merge-base, and one dev snapshot of this checkout per commit. `undefined` when none is for them.
|
|
141
|
+
* Picks the runner snapshot a run starts from, once the credential names its team and project: the candidate for
|
|
142
|
+
* them. Every candidate has the run's merge-base and snapshot key, and identities make the answer unique: a team and
|
|
143
|
+
* project have one entry per recipe, key and base. `undefined` when none is for them.
|
|
176
144
|
*/
|
|
177
145
|
export declare function pickSnapshot(candidates: readonly RunnerSnapshotCandidate[], owner: {
|
|
178
146
|
readonly teamId: string;
|
|
179
147
|
readonly projectId: string;
|
|
180
148
|
}): RunnerSnapshotCandidate | undefined;
|
|
181
|
-
/**
|
|
182
|
-
* What dropping dev snapshots from the cache did: the snapshot ids of the entries it removed, and why it couldn't list
|
|
183
|
-
* the cache or remove an entry, if it couldn't.
|
|
184
|
-
*/
|
|
185
|
-
export interface DevSnapshotDrop {
|
|
186
|
-
readonly snapshotIds: readonly string[];
|
|
187
|
-
readonly failures: readonly DevSnapshotDropFailure[];
|
|
188
|
-
}
|
|
189
|
-
/** Why a drop couldn't list the cache or remove an entry: what failed, in words. */
|
|
190
|
-
export interface DevSnapshotDropFailure {
|
|
191
|
-
readonly message: string;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Removes every cached dev snapshot entry built on the base snapshot `replaced` names: of its team and project, its
|
|
195
|
-
* recipe's region, runtime and name, its snapshot key and its base, from any checkout, since each started from that
|
|
196
|
-
* base snapshot or from a dev snapshot built on it, and holds its toolchains. `storm snapshots build --full` calls it
|
|
197
|
-
* once its new base snapshot replaced that one, so no run starts from the old toolchains. The snapshots themselves are
|
|
198
|
-
* left to expire. A failure is reported, never a refusal.
|
|
199
|
-
*/
|
|
200
|
-
export declare function dropDevSnapshotsOn(context: Pick<SnapshotCacheContext, "runnerSnapshots">, replaced: Pick<RunnerSnapshotEntry, "teamId" | "projectId" | "region" | "runtime" | "recipeName" | "snapshotKey" | "base">): Promise<DevSnapshotDrop>;
|
|
@@ -11,11 +11,8 @@ export const SNAPSHOT_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
|
11
11
|
export const SNAPSHOT_MIN_REMAINING_MS = 60 * 60 * 1000;
|
|
12
12
|
/**
|
|
13
13
|
* An entry's identity: the first 32 hex characters of sha256 over its team id, project id, region, runtime, recipe
|
|
14
|
-
* name
|
|
15
|
-
*
|
|
16
|
-
* snapshot's at its base, and a dev snapshot's replaces only the one its checkout saved at the same commit. The
|
|
17
|
-
* branch and, for a dev snapshot, the base are no part of it. A base snapshot's identity is the one it had before dev
|
|
18
|
-
* snapshots existed.
|
|
14
|
+
* name, snapshot key and base, joined with NUL. Entries with one identity replace each other, so a team and project
|
|
15
|
+
* have one entry per recipe, key and base.
|
|
19
16
|
*/
|
|
20
17
|
export function snapshotEntryIdentity(entry) {
|
|
21
18
|
return createHash("sha256")
|
|
@@ -26,19 +23,11 @@ export function snapshotEntryIdentity(entry) {
|
|
|
26
23
|
entry.runtime,
|
|
27
24
|
entry.recipeName,
|
|
28
25
|
entry.snapshotKey,
|
|
29
|
-
|
|
26
|
+
entry.base,
|
|
30
27
|
].join("\0"))
|
|
31
28
|
.digest("hex")
|
|
32
29
|
.slice(0, 32);
|
|
33
30
|
}
|
|
34
|
-
/** Whether `entry` records a dev snapshot, saved from a runner sandbox, rather than a base snapshot. */
|
|
35
|
-
export function isDevEntry(entry) {
|
|
36
|
-
return entry.head !== undefined && entry.repoRoot !== undefined;
|
|
37
|
-
}
|
|
38
|
-
/** The commit `entry`'s snapshot was built at: a dev snapshot's is the commit that saved it, a base snapshot's its base. */
|
|
39
|
-
export function builtAtCommit(entry) {
|
|
40
|
-
return isDevEntry(entry) ? entry.head : entry.base;
|
|
41
|
-
}
|
|
42
31
|
/** The name of the file that records `entry`: its identity and `.json`. */
|
|
43
32
|
export function snapshotEntryFileName(entry) {
|
|
44
33
|
return `${snapshotEntryIdentity(entry)}.json`;
|
|
@@ -78,19 +67,13 @@ export async function removeExpiredEntries(context) {
|
|
|
78
67
|
}
|
|
79
68
|
/**
|
|
80
69
|
* Classifies `entries`, cache entries a caller listed, for a run of `recipe`: which ones it may start from, and why
|
|
81
|
-
* not from each other one of the recipe's. It changes no file. Of the entries for the recipe's
|
|
82
|
-
* name it keeps the ones with more than an hour left whose base is the run's merge-base
|
|
83
|
-
* key is the run's
|
|
84
|
-
*
|
|
85
|
-
* longer counts, and none unless `devSnapshots` is `reuse`. HEAD's branch is no part of it: another checkout may hold
|
|
86
|
-
* other code, so its dev snapshot never carries over, whatever its branch. Every other entry of the recipe is
|
|
87
|
-
* `rejected`, with the first reason that rules it out, an expired one as `expired`. Each entry gets exactly one
|
|
88
|
-
* verdict. Git is asked once per dev snapshot commit whether HEAD holds it and, for a candidate, how far behind HEAD it
|
|
89
|
-
* is; a git failure ends the classification with that failure.
|
|
70
|
+
* not from each other one of the recipe's. It changes no file and asks Git nothing. Of the entries for the recipe's
|
|
71
|
+
* region, runtime and name it keeps the ones with more than an hour left whose base is the run's merge-base and whose
|
|
72
|
+
* snapshot key is the run's. Every other entry of the recipe is `rejected`, with the first reason that rules it out,
|
|
73
|
+
* an expired one as `expired`. Each entry gets exactly one verdict, in the order given.
|
|
90
74
|
*/
|
|
91
|
-
export
|
|
92
|
-
const {
|
|
93
|
-
const { entries, repoRoot, recipe, base, snapshotKey, commitsAfterBase, devSnapshots } = request;
|
|
75
|
+
export function classifySnapshotEntries(context, request) {
|
|
76
|
+
const { entries, recipe, base, snapshotKey, commitsAfterBase } = request;
|
|
94
77
|
const now = context.clock.now();
|
|
95
78
|
const candidates = [];
|
|
96
79
|
const rejected = [];
|
|
@@ -100,60 +83,26 @@ export async function classifySnapshotEntries(context, request) {
|
|
|
100
83
|
rejected.push(rejection);
|
|
101
84
|
verdicts.push({ kind: "rejected", entry, rejection });
|
|
102
85
|
};
|
|
103
|
-
// Whether HEAD holds each dev snapshot's commit, and how far behind HEAD it is, asked once per commit.
|
|
104
|
-
const inHistory = new Map();
|
|
105
|
-
const behind = new Map();
|
|
106
86
|
for (const entry of entries) {
|
|
107
87
|
if (entry.region !== recipe.region || entry.runtime !== recipe.runtime || entry.recipeName !== recipe.name) {
|
|
108
88
|
verdicts.push({ kind: "other-recipe", entry });
|
|
109
89
|
continue;
|
|
110
90
|
}
|
|
111
|
-
const dev = isDevEntry(entry);
|
|
112
91
|
if (isExpiredEntry(entry, now))
|
|
113
92
|
reject(entry, "expired");
|
|
114
93
|
else if (!hasTimeLeft(entry, now))
|
|
115
94
|
reject(entry, "expires-soon");
|
|
116
|
-
else if (dev && entry.repoRoot !== repoRoot)
|
|
117
|
-
reject(entry, "other-checkout");
|
|
118
|
-
else if (dev && devSnapshots !== "reuse")
|
|
119
|
-
reject(entry, devSnapshots);
|
|
120
95
|
else if (entry.base !== base)
|
|
121
96
|
reject(entry, "other-base");
|
|
122
97
|
else if (entry.snapshotKey !== snapshotKey)
|
|
123
98
|
reject(entry, "steps-changed");
|
|
124
|
-
else if (!dev) {
|
|
125
|
-
const candidate = { entry, builtAt: entry.base, builtBehind: commitsAfterBase };
|
|
126
|
-
candidates.push(candidate);
|
|
127
|
-
verdicts.push({ kind: "candidate", entry, candidate });
|
|
128
|
-
}
|
|
129
99
|
else {
|
|
130
|
-
const
|
|
131
|
-
let contained = inHistory.get(builtAt);
|
|
132
|
-
if (contained === undefined) {
|
|
133
|
-
const asked = await checkout.contains({ repoRoot, ancestor: builtAt, descendant: "HEAD" });
|
|
134
|
-
if (!asked.ok)
|
|
135
|
-
return asked;
|
|
136
|
-
contained = asked.value;
|
|
137
|
-
inHistory.set(builtAt, contained);
|
|
138
|
-
}
|
|
139
|
-
if (!contained) {
|
|
140
|
-
reject(entry, "not-in-history");
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
let builtBehind = behind.get(builtAt);
|
|
144
|
-
if (builtBehind === undefined) {
|
|
145
|
-
const counted = await checkout.commitCount({ repoRoot, from: builtAt, to: "HEAD" });
|
|
146
|
-
if (!counted.ok)
|
|
147
|
-
return counted;
|
|
148
|
-
builtBehind = counted.value;
|
|
149
|
-
behind.set(builtAt, builtBehind);
|
|
150
|
-
}
|
|
151
|
-
const candidate = { entry, builtAt, builtBehind };
|
|
100
|
+
const candidate = { entry, builtBehind: commitsAfterBase };
|
|
152
101
|
candidates.push(candidate);
|
|
153
102
|
verdicts.push({ kind: "candidate", entry, candidate });
|
|
154
103
|
}
|
|
155
104
|
}
|
|
156
|
-
return {
|
|
105
|
+
return { candidates, rejected, verdicts };
|
|
157
106
|
}
|
|
158
107
|
/**
|
|
159
108
|
* Why a run for `owner`'s team and project starts from none of the recipe's cached snapshots, when the pick found no
|
|
@@ -168,51 +117,10 @@ export function snapshotRejections(read, owner) {
|
|
|
168
117
|
];
|
|
169
118
|
}
|
|
170
119
|
/**
|
|
171
|
-
* Picks the runner snapshot a run starts from, once the credential names its team and project
|
|
172
|
-
* them
|
|
173
|
-
*
|
|
174
|
-
* an ancestor of is the fewest commits behind; on separate lines of a merged history, the one with the least left to
|
|
175
|
-
* install and build wins. Identities make the answer unique: a team and project have one base snapshot at the
|
|
176
|
-
* merge-base, and one dev snapshot of this checkout per commit. `undefined` when none is for them.
|
|
120
|
+
* Picks the runner snapshot a run starts from, once the credential names its team and project: the candidate for
|
|
121
|
+
* them. Every candidate has the run's merge-base and snapshot key, and identities make the answer unique: a team and
|
|
122
|
+
* project have one entry per recipe, key and base. `undefined` when none is for them.
|
|
177
123
|
*/
|
|
178
124
|
export function pickSnapshot(candidates, owner) {
|
|
179
|
-
return candidates
|
|
180
|
-
.filter(({ entry }) => entry.teamId === owner.teamId && entry.projectId === owner.projectId)
|
|
181
|
-
.toSorted((a, b) => a.builtBehind - b.builtBehind || Number(isDevEntry(b.entry)) - Number(isDevEntry(a.entry)))[0];
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Removes every cached dev snapshot entry built on the base snapshot `replaced` names: of its team and project, its
|
|
185
|
-
* recipe's region, runtime and name, its snapshot key and its base, from any checkout, since each started from that
|
|
186
|
-
* base snapshot or from a dev snapshot built on it, and holds its toolchains. `storm snapshots build --full` calls it
|
|
187
|
-
* once its new base snapshot replaced that one, so no run starts from the old toolchains. The snapshots themselves are
|
|
188
|
-
* left to expire. A failure is reported, never a refusal.
|
|
189
|
-
*/
|
|
190
|
-
export async function dropDevSnapshotsOn(context, replaced) {
|
|
191
|
-
const { runnerSnapshots } = context;
|
|
192
|
-
const listed = await runnerSnapshots.listEntries();
|
|
193
|
-
if (!listed.ok)
|
|
194
|
-
return { snapshotIds: [], failures: [{ message: cacheFailureText(listed.failure) }] };
|
|
195
|
-
const snapshotIds = [];
|
|
196
|
-
const failures = [];
|
|
197
|
-
for (const entry of listed.value.entries) {
|
|
198
|
-
if (!isDevEntry(entry) ||
|
|
199
|
-
entry.teamId !== replaced.teamId ||
|
|
200
|
-
entry.projectId !== replaced.projectId ||
|
|
201
|
-
entry.region !== replaced.region ||
|
|
202
|
-
entry.runtime !== replaced.runtime ||
|
|
203
|
-
entry.recipeName !== replaced.recipeName ||
|
|
204
|
-
entry.snapshotKey !== replaced.snapshotKey ||
|
|
205
|
-
entry.base !== replaced.base)
|
|
206
|
-
continue;
|
|
207
|
-
const removed = await runnerSnapshots.removeEntry(entry);
|
|
208
|
-
if (removed.ok)
|
|
209
|
-
snapshotIds.push(entry.snapshotId);
|
|
210
|
-
else
|
|
211
|
-
failures.push({ message: cacheFailureText(removed.failure) });
|
|
212
|
-
}
|
|
213
|
-
return { snapshotIds, failures };
|
|
214
|
-
}
|
|
215
|
-
/** A cache failure in words: the path it failed on and what the OS said. */
|
|
216
|
-
function cacheFailureText(failure) {
|
|
217
|
-
return `${failure.path}: ${failure.message}`;
|
|
125
|
+
return candidates.find(({ entry }) => entry.teamId === owner.teamId && entry.projectId === owner.projectId);
|
|
218
126
|
}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import type { CheckoutFailure, CheckoutHead, RunnerSnapshotEntry, UnreadableSnapshotEntry } from "./gateways.ts";
|
|
2
|
-
import {
|
|
2
|
+
import type { CheckedRecipe } from "./recipe.ts";
|
|
3
3
|
import { type SnapshotCacheContext, type SnapshotRejectionReason } from "./snapshot-cache.ts";
|
|
4
4
|
/**
|
|
5
|
-
* One cached runner snapshot, as a checkout sees it:
|
|
6
|
-
*
|
|
7
|
-
* (`
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* One cached runner snapshot, as a checkout sees it: from the checkout's Git history, whether HEAD is its base or
|
|
6
|
+
* holds it (`inHistory`), which an amend or a rebase can change, and how many commits HEAD has that its base lacks
|
|
7
|
+
* (`builtBehind`). `inHistory` is null when storm didn't check it: outside a Git checkout, or without a recipe or a
|
|
8
|
+
* base; `builtBehind` is null then too, and when the base isn't in HEAD's history. `picked` says a run here starts
|
|
9
|
+
* from it, for its team and project.
|
|
10
10
|
* `reason` says why a run here doesn't (`SnapshotRejectionReason`), `other-recipe` for another recipe'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
|
-
readonly kind: "base" | "dev";
|
|
16
|
-
readonly builtAt: string;
|
|
17
15
|
readonly inHistory: boolean | null;
|
|
18
16
|
readonly builtBehind: number | null;
|
|
19
|
-
/** For a dev snapshot, whether this checkout saved it; null for a base snapshot, and outside a Git checkout. */
|
|
20
|
-
readonly savedHere: boolean | null;
|
|
21
17
|
readonly expired: boolean;
|
|
22
18
|
readonly picked: boolean;
|
|
23
19
|
readonly reason: SnapshotRejectionReason | "other-recipe" | null;
|
|
@@ -75,9 +71,9 @@ export type SnapshotCacheInspectionOutcome = {
|
|
|
75
71
|
/**
|
|
76
72
|
* Inspects the cache from `cwd` for `recipe`, the runner recipe that applies there, if any. With a recipe, in a Git
|
|
77
73
|
* checkout whose HEAD shares history with one of its base refs, it marks for each team and project the snapshot a run
|
|
78
|
-
* here starts from, by a run's own rule (`classifySnapshotEntries`, `
|
|
79
|
-
*
|
|
80
|
-
*
|
|
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 runs the recipe's snapshot steps at the merge-base for the
|
|
76
|
+
* run's snapshot key, as a run does. Otherwise it picks none and
|
|
81
77
|
* says why. `all` adds the snapshots of other recipes, and of the recipe's other regions and runtimes, as
|
|
82
78
|
* `other-recipe`. It lists the cache once and classifies that listing, which removes no file, so an expired entry of
|
|
83
79
|
* the recipe stays and is `expired`. A git failure ends it with `checkout-failed`, as it ends a run.
|