@cnc-tools/storm 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.js +1 -1
- package/dist/combine-errors.js +2 -2
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/{run → exec}/cleanup.d.ts +1 -1
- package/dist/commands/{run → exec}/cleanup.js +1 -1
- package/dist/commands/{run/outcomes.d.ts → exec/command.d.ts} +103 -112
- package/dist/commands/exec/command.js +23 -0
- package/dist/commands/{run → exec}/job-summary.d.ts +5 -1
- package/dist/commands/{run → exec}/job-summary.js +5 -2
- package/dist/commands/{run → exec}/live-view.js +29 -13
- package/dist/commands/exec/metadata.d.ts +69 -0
- package/dist/commands/exec/metadata.js +55 -0
- package/dist/commands/{run → exec}/mint-failed.js +4 -4
- package/dist/commands/exec/outcomes.d.ts +664 -0
- package/dist/commands/exec/outcomes.js +347 -0
- package/dist/commands/{run → exec}/progress.d.ts +14 -2
- package/dist/commands/{run → exec}/progress.js +54 -9
- package/dist/commands/exec/run-command.d.ts +227 -0
- package/dist/commands/exec/run-command.js +696 -0
- package/dist/commands/exec/run-metadata.d.ts +59 -0
- package/dist/commands/exec/run-metadata.js +61 -0
- package/dist/commands/{run → exec}/run-record.d.ts +110 -5
- package/dist/commands/{run → exec}/run-record.js +57 -1
- package/dist/commands/exec/testserver-flags.d.ts +48 -0
- package/dist/commands/exec/testserver-flags.js +80 -0
- package/dist/commands/{run → exec}/view.js +36 -4
- package/dist/commands/runs/facts.d.ts +25 -0
- package/dist/commands/runs/facts.js +38 -5
- package/dist/commands/runs/list/command.d.ts +25 -0
- package/dist/commands/runs/list/outcomes.d.ts +25 -0
- package/dist/commands/runs/logs/metadata.js +1 -1
- package/dist/commands/runs/logs/outcomes.js +4 -1
- package/dist/commands/runs/past-run.d.ts +2 -2
- package/dist/commands/runs/past-run.js +2 -2
- package/dist/commands/runs/show/command.d.ts +25 -0
- package/dist/commands/runs/show/metadata.js +2 -2
- package/dist/commands/runs/show/outcomes.d.ts +25 -0
- package/dist/commands/runs/show/outcomes.js +37 -5
- package/dist/commands/vitest/command.d.ts +325 -0
- package/dist/commands/vitest/command.js +138 -0
- package/dist/commands/vitest/metadata.d.ts +69 -0
- package/dist/commands/vitest/metadata.js +35 -0
- package/dist/commands/vitest/outcomes.d.ts +298 -0
- package/dist/commands/vitest/outcomes.js +77 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -0
- package/dist/config/resolve.d.ts +3 -3
- package/dist/config/resolve.js +3 -3
- package/dist/config/resource-config.d.ts +2 -2
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/set.d.ts +15 -4
- package/dist/config/set.js +28 -12
- package/dist/config-file/define.d.ts +8 -6
- package/dist/context.d.ts +6 -3
- package/dist/context.js +4 -2
- package/dist/core/command-provider.d.ts +1 -1
- package/dist/core/events.d.ts +9 -7
- package/dist/core/presentation.js +1 -1
- package/dist/core/presentations.js +1 -1
- package/dist/core/run-state.d.ts +30 -6
- package/dist/core/run-state.js +19 -4
- package/dist/core/run.d.ts +17 -4
- package/dist/core/run.js +61 -25
- package/dist/resources/testserver/command.d.ts +1 -1
- package/dist/resources/testserver/command.js +1 -1
- package/dist/resources/testserver/config.d.ts +1 -1
- package/dist/resources/testserver/config.js +3 -2
- package/dist/resources/testserver/credential-facts.js +1 -1
- package/dist/resources/testserver/resource.d.ts +2 -2
- package/dist/resources/testserver/sandbox/create.d.ts +2 -2
- package/dist/resources/testserver/sandbox/create.js +2 -2
- package/dist/resources.d.ts +9 -6
- package/dist/resources.js +3 -3
- package/dist/runner/events.d.ts +64 -1
- package/dist/runner/gateways.d.ts +17 -6
- package/dist/runner/index.d.ts +5 -4
- package/dist/runner/index.js +4 -3
- package/dist/runner/live/snapshot-records.js +18 -4
- package/dist/runner/prepare.d.ts +23 -4
- package/dist/runner/prepare.js +13 -3
- package/dist/runner/ready.d.ts +7 -3
- package/dist/runner/ready.js +11 -5
- package/dist/runner/scope.d.ts +17 -1
- package/dist/runner/scope.js +4 -0
- package/dist/runner/snapshot-build.d.ts +3 -1
- package/dist/runner/snapshot-build.js +12 -2
- package/dist/runner/snapshot-cache.d.ts +46 -8
- package/dist/runner/snapshot-cache.js +60 -11
- package/dist/runner/snapshot-key.d.ts +12 -1
- package/dist/runner/snapshot-key.js +17 -1
- package/dist/runner/snapshot-save.d.ts +53 -0
- package/dist/runner/snapshot-save.js +148 -0
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/payload/payload.d.ts +2 -2
- package/dist/sdk/payload/payload.js +2 -2
- package/dist/story/align.d.ts +1 -1
- package/dist/story/align.js +1 -1
- package/dist/story/definition.d.ts +22 -15
- package/dist/story/definition.js +2 -2
- package/dist/story/errors.js +1 -1
- package/dist/story/gateways.d.ts +45 -25
- package/dist/story/gateways.js +2 -2
- package/dist/story/host.d.ts +11 -8
- package/dist/story/host.js +37 -37
- package/dist/story/index.d.ts +1 -1
- package/dist/story/index.js +4 -4
- package/dist/story/json.d.ts +1 -1
- package/dist/story/json.js +2 -2
- package/dist/story/live/recording-gateway.d.ts +2 -0
- package/dist/story/live/{artifact-gateway.js → recording-gateway.js} +33 -12
- package/dist/story/mode.d.ts +2 -2
- package/dist/story/mode.js +1 -1
- package/dist/story/orphans.d.ts +23 -5
- package/dist/story/orphans.js +44 -8
- package/dist/story/recording.d.ts +62 -0
- package/dist/story/{artifact.js → recording.js} +31 -27
- package/dist/story/report.d.ts +21 -9
- package/dist/story/report.js +37 -25
- package/dist/story/settle.d.ts +23 -21
- package/dist/story/settle.js +17 -16
- package/dist/story/{run.d.ts → start.d.ts} +18 -17
- package/dist/story/{run.js → start.js} +66 -43
- package/dist/vercel-cli/driver.d.ts +1 -1
- package/dist/vercel-cli/entry.d.ts +1 -1
- package/dist/vercel-cli/entry.js +1 -1
- package/dist/vercel-cli/verbose.d.ts +2 -2
- package/dist/vercel-cli/verbose.js +2 -2
- package/dist/vitest/config.d.ts +5 -5
- package/dist/vitest/config.js +5 -5
- package/dist/vitest/find-vitest.d.ts +7 -0
- package/dist/vitest/find-vitest.js +28 -0
- package/dist/vitest/fixtures.d.ts +2 -2
- package/dist/vitest/fixtures.js +3 -3
- package/dist/vitest/gateways.d.ts +37 -6
- package/dist/vitest/gateways.js +3 -2
- package/dist/vitest/live/list-gateway.d.ts +7 -3
- package/dist/vitest/live/list-gateway.js +55 -8
- package/dist/vitest/plan.d.ts +41 -8
- package/dist/vitest/plan.js +47 -16
- package/dist/vitest/sandbox.d.ts +1 -1
- package/dist/vitest/sandbox.js +1 -1
- package/dist/vitest/test-events.d.ts +2 -2
- package/dist/vitest/test-events.js +3 -3
- package/dist/vitest/test-results.d.ts +1 -1
- package/dist/vitest/test-results.js +1 -1
- package/dist/vitest/types.d.ts +1 -1
- package/package.json +2 -2
- package/skills/overview.md +5 -4
- package/skills/read-run-output.md +1 -1
- package/dist/commands/run/command.d.ts +0 -327
- package/dist/commands/run/command.js +0 -620
- package/dist/commands/run/metadata.d.ts +0 -47
- package/dist/commands/run/metadata.js +0 -83
- package/dist/commands/run/outcomes.js +0 -332
- package/dist/story/artifact.d.ts +0 -60
- package/dist/story/live/artifact-gateway.d.ts +0 -2
- /package/dist/commands/{run → exec}/live-view.d.ts +0 -0
- /package/dist/commands/{run → exec}/mint-failed.d.ts +0 -0
- /package/dist/commands/{run → exec}/redaction.d.ts +0 -0
- /package/dist/commands/{run → exec}/redaction.js +0 -0
- /package/dist/commands/{run → exec}/run-collector.d.ts +0 -0
- /package/dist/commands/{run → exec}/run-collector.js +0 -0
- /package/dist/commands/{run → exec}/tests-summary.d.ts +0 -0
- /package/dist/commands/{run → exec}/tests-summary.js +0 -0
- /package/dist/commands/{run → exec}/text.d.ts +0 -0
- /package/dist/commands/{run → exec}/text.js +0 -0
- /package/dist/commands/{run → exec}/view.d.ts +0 -0
- /package/dist/commands/{run → exec}/waterfall.d.ts +0 -0
- /package/dist/commands/{run → exec}/waterfall.js +0 -0
- /package/dist/commands/{run → exec}/worker-chart.d.ts +0 -0
- /package/dist/commands/{run → exec}/worker-chart.js +0 -0
package/dist/runner/events.d.ts
CHANGED
|
@@ -32,7 +32,8 @@ export interface NotKeptSandbox {
|
|
|
32
32
|
/**
|
|
33
33
|
* What the runner reports, in order.
|
|
34
34
|
*
|
|
35
|
-
* - `snapshot-reused`: the run starts from cached runner snapshot `snapshotId`, of `base
|
|
35
|
+
* - `snapshot-reused`: the run starts from cached runner snapshot `snapshotId`, of `base`; for a branch snapshot,
|
|
36
|
+
* saved by a run on `branch` at HEAD commit `head`, each null for a base snapshot.
|
|
36
37
|
* - `snapshot-build-started`: the run builds a runner snapshot of `base`, because no cached one qualified or
|
|
37
38
|
* `--rebuild-snapshot` asked; `summary` says what the build does.
|
|
38
39
|
* - `runner-sandbox-starting`: the runner sandbox is starting from runner snapshot `snapshotId`.
|
|
@@ -52,11 +53,19 @@ export interface NotKeptSandbox {
|
|
|
52
53
|
* and releasing the run's resources.
|
|
53
54
|
* - `waiting-for-snapshot`: closing waits up to `settleMs` for a runner snapshot still saving.
|
|
54
55
|
* - `sandbox-kept`: closing kept runner sandbox `name` running until `stopsAt`, an ISO time.
|
|
56
|
+
* - `branch-snapshot-saving`: the run saves the runner sandbox as a branch snapshot of `branch`, once the command
|
|
57
|
+
* ended (`--save-snapshot`).
|
|
58
|
+
* - `branch-snapshot-saved`: it did, as runner snapshot `snapshotId` of `branch` at HEAD commit `head`, in `ms`.
|
|
59
|
+
* - `branch-snapshot-not-saved`: it didn't, and `save` says why.
|
|
60
|
+
* - `branch-snapshots-dropped`: `--rebuild-snapshot` removed `branch`'s branch snapshot entries from the cache.
|
|
61
|
+
* - `branch-snapshots-not-dropped`: it couldn't list the cache or remove one of them.
|
|
55
62
|
*/
|
|
56
63
|
export type RunnerEvent = {
|
|
57
64
|
readonly kind: "snapshot-reused";
|
|
58
65
|
readonly snapshotId: string;
|
|
59
66
|
readonly base: string;
|
|
67
|
+
readonly branch: string | null;
|
|
68
|
+
readonly head: string | null;
|
|
60
69
|
} | {
|
|
61
70
|
readonly kind: "snapshot-build-started";
|
|
62
71
|
readonly base: string;
|
|
@@ -130,6 +139,29 @@ export type RunnerEvent = {
|
|
|
130
139
|
readonly kind: "sandbox-kept";
|
|
131
140
|
readonly name: string;
|
|
132
141
|
readonly stopsAt: string;
|
|
142
|
+
} | {
|
|
143
|
+
readonly kind: "branch-snapshot-saving";
|
|
144
|
+
readonly branch: string;
|
|
145
|
+
} | {
|
|
146
|
+
readonly kind: "branch-snapshot-saved";
|
|
147
|
+
readonly snapshotId: string;
|
|
148
|
+
readonly branch: string;
|
|
149
|
+
readonly head: string;
|
|
150
|
+
readonly ms: number;
|
|
151
|
+
readonly sizeBytes: number;
|
|
152
|
+
} | {
|
|
153
|
+
readonly kind: "branch-snapshot-not-saved";
|
|
154
|
+
readonly save: Exclude<RunnerSave, {
|
|
155
|
+
readonly kind: "saved" | "skipped";
|
|
156
|
+
}>;
|
|
157
|
+
} | {
|
|
158
|
+
readonly kind: "branch-snapshots-dropped";
|
|
159
|
+
readonly branch: string;
|
|
160
|
+
readonly snapshotIds: readonly string[];
|
|
161
|
+
} | {
|
|
162
|
+
readonly kind: "branch-snapshots-not-dropped";
|
|
163
|
+
readonly branch: string;
|
|
164
|
+
readonly failure: RunnerSnapshotCacheFailure;
|
|
133
165
|
};
|
|
134
166
|
/** Hears the runner's events as they happen. */
|
|
135
167
|
export interface RunnerProgress {
|
|
@@ -159,6 +191,37 @@ export type RunnerFailure = {
|
|
|
159
191
|
readonly kind: "checkout-failed";
|
|
160
192
|
readonly failure: CheckoutFailure;
|
|
161
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* How saving the runner sandbox as a branch snapshot ended (`--save-snapshot`).
|
|
196
|
+
*
|
|
197
|
+
* - `saved`: it is runner snapshot `snapshotId` of `base`, for `branch` at HEAD commit `head`, saved in `ms` from the
|
|
198
|
+
* save's start; `entryWritten` says whether the cache recorded it.
|
|
199
|
+
* - `skipped`: HEAD was detached as the run started, so there is no branch to save it for (`prepareRunner`); the run
|
|
200
|
+
* keeps its runner sandbox as without the flag.
|
|
201
|
+
* - `failed`: the scrub or the save failed with `message`.
|
|
202
|
+
* - `stopped`: a signal stopped it before it saved, or before the cache recorded the snapshot.
|
|
203
|
+
*
|
|
204
|
+
* A run on a branch never keeps its runner sandbox, whether the save ran or how it ended (`RunnerSandboxPlan`).
|
|
205
|
+
*/
|
|
206
|
+
export type RunnerSave = {
|
|
207
|
+
readonly kind: "saved";
|
|
208
|
+
readonly snapshotId: string;
|
|
209
|
+
readonly base: string;
|
|
210
|
+
readonly branch: string;
|
|
211
|
+
readonly head: string;
|
|
212
|
+
readonly ms: number;
|
|
213
|
+
readonly sizeBytes: number;
|
|
214
|
+
readonly entryWritten: boolean;
|
|
215
|
+
} | {
|
|
216
|
+
readonly kind: "skipped";
|
|
217
|
+
readonly reason: "detached-head";
|
|
218
|
+
} | {
|
|
219
|
+
readonly kind: "failed";
|
|
220
|
+
readonly step: "scrub" | "save-snapshot";
|
|
221
|
+
readonly message: string;
|
|
222
|
+
} | {
|
|
223
|
+
readonly kind: "stopped";
|
|
224
|
+
};
|
|
162
225
|
/** How one stage of readying the runner ended: its value, a failure, or a stop because the run was aborted. */
|
|
163
226
|
export type RunnerStage<T> = {
|
|
164
227
|
readonly kind: "ok";
|
|
@@ -122,7 +122,8 @@ export interface CheckoutGateway {
|
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* One runner snapshot the cache records: who it belongs to, what it was built from, and when it expires. Times
|
|
125
|
-
* are ISO strings.
|
|
125
|
+
* are ISO strings. An entry with `branch` and `head` records a branch snapshot, saved from a run on that branch; one
|
|
126
|
+
* without them records a base snapshot, built from its base. An entry has both or neither.
|
|
126
127
|
*/
|
|
127
128
|
export interface RunnerSnapshotEntry {
|
|
128
129
|
readonly teamId: string;
|
|
@@ -132,8 +133,17 @@ export interface RunnerSnapshotEntry {
|
|
|
132
133
|
readonly recipeName: string;
|
|
133
134
|
/** The snapshot key at `base` (`snapshotKey`). */
|
|
134
135
|
readonly snapshotKey: string;
|
|
135
|
-
/** The base commit's full SHA. */
|
|
136
|
+
/** The base commit's full SHA, whose tracked files the snapshot's repository commits first, in either kind. */
|
|
136
137
|
readonly base: string;
|
|
138
|
+
/** For a branch snapshot, the local branch of the run that saved it. */
|
|
139
|
+
readonly branch?: string;
|
|
140
|
+
/** For a branch snapshot, the full SHA of the HEAD commit of the run that saved it. */
|
|
141
|
+
readonly head?: string;
|
|
142
|
+
/**
|
|
143
|
+
* For a branch snapshot, the root of the checkout the run that saved it ran from. Only a run from that checkout
|
|
144
|
+
* starts from it, so a branch of the same name in another checkout never inherits what this run left.
|
|
145
|
+
*/
|
|
146
|
+
readonly repoRoot?: string;
|
|
137
147
|
readonly snapshotId: string;
|
|
138
148
|
readonly createdAt: string;
|
|
139
149
|
readonly expiresAt: string;
|
|
@@ -170,8 +180,9 @@ export type RunnerSnapshotCacheOperation = {
|
|
|
170
180
|
};
|
|
171
181
|
/**
|
|
172
182
|
* The per-machine runner snapshot cache: one record per runner snapshot, keyed by the entry's identity (team,
|
|
173
|
-
* project, region, runtime, recipe name, snapshot key and
|
|
174
|
-
* never rejects. Which entries a run may use, and when one has
|
|
183
|
+
* project, region, runtime, recipe name, snapshot key, base and, for a branch snapshot, branch and checkout root).
|
|
184
|
+
* Every method returns its expected failures and never rejects. Which entries a run may use, and when one has
|
|
185
|
+
* expired, is the caller's.
|
|
175
186
|
*/
|
|
176
187
|
export interface RunnerSnapshotCacheGateway {
|
|
177
188
|
/** Every readable entry, and the files it couldn't read. A cache never written is empty. */
|
|
@@ -260,7 +271,7 @@ export interface StagedFile {
|
|
|
260
271
|
readonly name: string;
|
|
261
272
|
readonly content: Uint8Array;
|
|
262
273
|
}
|
|
263
|
-
/** A runner snapshot a build sandbox was saved as. */
|
|
274
|
+
/** A runner snapshot a build sandbox or a runner sandbox was saved as. */
|
|
264
275
|
export interface SavedSnapshot {
|
|
265
276
|
readonly snapshotId: string;
|
|
266
277
|
/** When the Sandbox API says it expires, as an ISO string, when it says. */
|
|
@@ -319,7 +330,7 @@ export interface RunnerSandboxGateway {
|
|
|
319
330
|
readonly path: string;
|
|
320
331
|
readonly fromLine: number;
|
|
321
332
|
}, onOutput: (chunk: RemoteOutputChunk) => void, signal?: AbortSignal): Promise<RunnerSandboxOperation>;
|
|
322
|
-
/** Saves a build sandbox as a runner snapshot that expires after `expirationMs`; that stops the sandbox. */
|
|
333
|
+
/** Saves a build or runner sandbox as a runner snapshot that expires after `expirationMs`; that stops the sandbox. */
|
|
323
334
|
saveSnapshot(sandbox: RunnerSandbox, request: {
|
|
324
335
|
readonly expirationMs: number;
|
|
325
336
|
}): Promise<RunnerSandboxResult<SavedSnapshot>>;
|
package/dist/runner/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { type BaseResolution, type RefusedBaseRef, resolveBase } from "./base.ts";
|
|
2
2
|
export type { RunnerContext } from "./context.ts";
|
|
3
|
-
export { type KeptSandbox, type NotDeletedSandbox, type NotKeptSandbox, type NotStoppedSandbox, type RunnerEvent, type RunnerFailure, type RunnerOutputSection, type RunnerProgress, type RunnerSandboxCall, type RunnerStage, type RunnerStepPhase, } from "./events.ts";
|
|
3
|
+
export { type KeptSandbox, type NotDeletedSandbox, type NotKeptSandbox, type NotStoppedSandbox, type RunnerEvent, type RunnerFailure, type RunnerOutputSection, type RunnerProgress, type RunnerSandboxCall, type RunnerSave, type RunnerStage, type RunnerStepPhase, } from "./events.ts";
|
|
4
4
|
export type { BaseArchive, BaseCandidate, CheckoutFailure, CheckoutHead, CheckoutGateway, CheckoutResult, CheckoutUpload, FileAtCommit, RemoteExit, RemoteOutputChunk, RunnerKeepFailure, RunnerSandbox, RunnerSandboxFailure, RunnerSandboxGateway, RunnerSandboxOperation, RunnerSandboxPlacement, RunnerSandboxResult, RunnerSandboxRole, RunnerSnapshotCacheFailure, RunnerSnapshotCacheGateway, RunnerSnapshotCacheOperation, RunnerSnapshotCacheResult, RunnerSnapshotEntry, RunnerSnapshotListing, RunnerStartFailure, RunnerTerminal, SandboxAccess, SavedSnapshot, StagedFile, UnreadableSnapshotEntry, } from "./gateways.ts";
|
|
5
5
|
export { liveCheckoutGateway } from "./live/checkout-gateway.ts";
|
|
6
6
|
export { liveRunnerSandboxGateway } from "./live/sandbox-gateway.ts";
|
|
@@ -12,8 +12,9 @@ export { type PreparedRunner, prepareRunner, type PrepareRunnerOutcome, type Pre
|
|
|
12
12
|
export { APPLY_LABEL, type ReadyRunner, readyRunner, type ReadyRunnerOutcome, type ReadyRunnerRequest, } from "./ready.ts";
|
|
13
13
|
export { type CheckedRecipe, checkRecipe, type RecipeCheck, type RecipeProblem, resolveSteps, resolveVcpus, type RunnerRecipe, type RunnerResources, type RunnerStep, type RunnerStepContext, type RunnerSteps, } from "./recipe.ts";
|
|
14
14
|
export { REMOTE_TEST_EVENTS_PATH, type RemoteCommandOutcome, remoteCommand, remoteEnvironment, type RemoteTestEvents, runRemote, } from "./remote-command.ts";
|
|
15
|
-
export { CREATE_SETTLE_MS, type RunnerSandboxScope, runnerSandboxScope, type RunnerScopeReport, SNAPSHOT_SETTLE_MS, } from "./scope.ts";
|
|
15
|
+
export { CREATE_SETTLE_MS, keptMs, type RunnerSandboxPlan, type RunnerSandboxScope, runnerSandboxScope, type RunnerScopeReport, SNAPSHOT_SETTLE_MS, } from "./scope.ts";
|
|
16
16
|
export { BASE_INDEX_LABEL, buildSnapshot, type BuildSnapshotRequest, type BuiltSnapshot } from "./snapshot-build.ts";
|
|
17
|
-
export { findSnapshotCandidates, pickSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type RunnerSnapshotCandidate, SNAPSHOT_EXPIRATION_MS, type SnapshotCacheContext, type SnapshotCacheNote, snapshotEntryFileName, snapshotEntryIdentity, } from "./snapshot-cache.ts";
|
|
18
|
-
export { applyScript, baseIndexScript, snapshotKey, type SnapshotStepsAt, snapshotStepsAt } from "./snapshot-key.ts";
|
|
17
|
+
export { dropBranchSnapshots, type DroppedBranchSnapshots, findSnapshotCandidates, isBranchEntry, pickSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type RunnerSnapshotCandidate, SNAPSHOT_EXPIRATION_MS, type SnapshotCacheContext, type SnapshotCacheNote, snapshotEntryFileName, snapshotEntryIdentity, } from "./snapshot-cache.ts";
|
|
18
|
+
export { applyScript, baseIndexScript, RESET_TO_BASE, snapshotKey, type SnapshotStepsAt, snapshotStepsAt, } from "./snapshot-key.ts";
|
|
19
|
+
export { saveBranchSnapshot, type SaveBranchSnapshotRequest, scrubGitScript, scrubTempScript, TEMP_DIRECTORIES, } from "./snapshot-save.ts";
|
|
19
20
|
export { STEP_ENV, type StepOutcome } from "./steps.ts";
|
package/dist/runner/index.js
CHANGED
|
@@ -11,8 +11,9 @@ export { prepareRunner, } from "./prepare.js";
|
|
|
11
11
|
export { APPLY_LABEL, readyRunner, } from "./ready.js";
|
|
12
12
|
export { checkRecipe, resolveSteps, resolveVcpus, } from "./recipe.js";
|
|
13
13
|
export { REMOTE_TEST_EVENTS_PATH, remoteCommand, remoteEnvironment, runRemote, } from "./remote-command.js";
|
|
14
|
-
export { CREATE_SETTLE_MS, runnerSandboxScope, SNAPSHOT_SETTLE_MS, } from "./scope.js";
|
|
14
|
+
export { CREATE_SETTLE_MS, keptMs, runnerSandboxScope, SNAPSHOT_SETTLE_MS, } from "./scope.js";
|
|
15
15
|
export { BASE_INDEX_LABEL, buildSnapshot } from "./snapshot-build.js";
|
|
16
|
-
export { findSnapshotCandidates, pickSnapshot, RUNNER_SNAPSHOTS_SUBPATH, SNAPSHOT_EXPIRATION_MS, snapshotEntryFileName, snapshotEntryIdentity, } from "./snapshot-cache.js";
|
|
17
|
-
export { applyScript, baseIndexScript, snapshotKey, snapshotStepsAt } from "./snapshot-key.js";
|
|
16
|
+
export { dropBranchSnapshots, findSnapshotCandidates, isBranchEntry, pickSnapshot, RUNNER_SNAPSHOTS_SUBPATH, SNAPSHOT_EXPIRATION_MS, snapshotEntryFileName, snapshotEntryIdentity, } from "./snapshot-cache.js";
|
|
17
|
+
export { applyScript, baseIndexScript, RESET_TO_BASE, snapshotKey, snapshotStepsAt, } from "./snapshot-key.js";
|
|
18
|
+
export { saveBranchSnapshot, scrubGitScript, scrubTempScript, TEMP_DIRECTORIES, } from "./snapshot-save.js";
|
|
18
19
|
export { STEP_ENV } from "./steps.js";
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// The runner snapshot cache's file format: one JSON object per runner snapshot, carrying `version: 1`. A reader
|
|
2
|
-
// rejects a version it doesn't know.
|
|
2
|
+
// rejects a version it doesn't know. A branch snapshot's record adds `branch`, `head` and `repoRoot`, all three or
|
|
3
|
+
// none; a storm that predates them drops them as it reads, so the file's name no longer matches the entry's identity,
|
|
4
|
+
// and that storm lists the file as unreadable and never starts from it.
|
|
3
5
|
import { z } from "zod";
|
|
4
6
|
const isoTime = z.string().refine((value) => !Number.isNaN(Date.parse(value)), { message: "not a time" });
|
|
5
7
|
const nonEmpty = z.string().min(1);
|
|
6
|
-
const entrySchema = z
|
|
8
|
+
const entrySchema = z
|
|
9
|
+
.object({
|
|
7
10
|
version: z.literal(1),
|
|
8
11
|
teamId: nonEmpty,
|
|
9
12
|
projectId: nonEmpty,
|
|
@@ -12,10 +15,17 @@ const entrySchema = z.object({
|
|
|
12
15
|
recipeName: nonEmpty,
|
|
13
16
|
snapshotKey: nonEmpty,
|
|
14
17
|
base: nonEmpty,
|
|
18
|
+
branch: nonEmpty.exactOptional(),
|
|
19
|
+
head: nonEmpty.exactOptional(),
|
|
20
|
+
repoRoot: nonEmpty.exactOptional(),
|
|
15
21
|
snapshotId: nonEmpty,
|
|
16
22
|
createdAt: isoTime,
|
|
17
23
|
expiresAt: isoTime,
|
|
18
|
-
})
|
|
24
|
+
})
|
|
25
|
+
.refine((entry) => {
|
|
26
|
+
const present = [entry.branch, entry.head, entry.repoRoot].filter((value) => value !== undefined).length;
|
|
27
|
+
return present === 0 || present === 3;
|
|
28
|
+
}, { message: "has some of branch, head and repoRoot without the others" });
|
|
19
29
|
/** The entry a cache file holds, or why it holds none. */
|
|
20
30
|
export function parseSnapshotEntry(text) {
|
|
21
31
|
let json;
|
|
@@ -39,7 +49,8 @@ export function parseSnapshotEntry(text) {
|
|
|
39
49
|
}
|
|
40
50
|
/** The text of the file that records `entry`. */
|
|
41
51
|
export function snapshotEntryText(entry) {
|
|
42
|
-
const { teamId, projectId, region, runtime, recipeName, snapshotKey, base,
|
|
52
|
+
const { teamId, projectId, region, runtime, recipeName, snapshotKey, base, branch, head, repoRoot } = entry;
|
|
53
|
+
const { snapshotId, createdAt, expiresAt } = entry;
|
|
43
54
|
const record = {
|
|
44
55
|
version: 1,
|
|
45
56
|
teamId,
|
|
@@ -49,6 +60,9 @@ export function snapshotEntryText(entry) {
|
|
|
49
60
|
recipeName,
|
|
50
61
|
snapshotKey,
|
|
51
62
|
base,
|
|
63
|
+
...(branch === undefined ? {} : { branch }),
|
|
64
|
+
...(head === undefined ? {} : { head }),
|
|
65
|
+
...(repoRoot === undefined ? {} : { repoRoot }),
|
|
52
66
|
snapshotId,
|
|
53
67
|
createdAt,
|
|
54
68
|
expiresAt,
|
package/dist/runner/prepare.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RefusedBaseRef } from "./base.ts";
|
|
2
|
-
import type { CheckoutFailure, CheckoutUpload } from "./gateways.ts";
|
|
2
|
+
import type { CheckoutFailure, CheckoutHead, CheckoutUpload } from "./gateways.ts";
|
|
3
3
|
import { type CheckedRecipe, type RunnerResources, type RunnerStep } from "./recipe.ts";
|
|
4
4
|
import { type RunnerSnapshotCandidate, type SnapshotCacheContext, type SnapshotCacheNote } from "./snapshot-cache.ts";
|
|
5
5
|
/** What `prepareRunner` needs: the checkout, the runner snapshot cache and the clock. */
|
|
@@ -12,11 +12,15 @@ export interface PrepareRunnerRequest {
|
|
|
12
12
|
readonly resources: RunnerResources;
|
|
13
13
|
/** `--rebuild-snapshot`: the run builds a runner snapshot whatever the cache holds, so the cache isn't read. */
|
|
14
14
|
readonly rebuild: boolean;
|
|
15
|
+
/** `--save-snapshot`: the run saves the runner sandbox as a branch snapshot of HEAD's branch once the command ends. */
|
|
16
|
+
readonly saveSnapshot: boolean;
|
|
15
17
|
}
|
|
16
18
|
/** A runner run checked on this machine, ready for the remote side. */
|
|
17
19
|
export interface PreparedRunner {
|
|
18
20
|
readonly recipe: CheckedRecipe;
|
|
19
21
|
readonly repoRoot: string;
|
|
22
|
+
/** Where HEAD is: the branch a run's branch snapshot is for, null when detached, and its commit. */
|
|
23
|
+
readonly head: CheckoutHead;
|
|
20
24
|
/** The run's base, a full SHA, and the ref it is HEAD's merge-base with. */
|
|
21
25
|
readonly base: string;
|
|
22
26
|
readonly baseRef: string;
|
|
@@ -27,11 +31,25 @@ export interface PreparedRunner {
|
|
|
27
31
|
/** The runner sandbox's vCPUs for the run's resources. */
|
|
28
32
|
readonly vcpus: number;
|
|
29
33
|
readonly upload: CheckoutUpload;
|
|
30
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* The cached runner snapshots the run may start from, base snapshots and HEAD's branch's branch snapshots, before
|
|
36
|
+
* the team and project filter (`pickSnapshot`).
|
|
37
|
+
*/
|
|
31
38
|
readonly candidates: readonly RunnerSnapshotCandidate[];
|
|
32
39
|
readonly rebuild: boolean;
|
|
33
40
|
/** What the cache read noticed, for the run to report. */
|
|
34
41
|
readonly notes: readonly SnapshotCacheNote[];
|
|
42
|
+
/**
|
|
43
|
+
* `--save-snapshot`: the branch the run saves a branch snapshot of, or why it saves none (`skipped`, with a
|
|
44
|
+
* detached HEAD); null without the flag.
|
|
45
|
+
*/
|
|
46
|
+
readonly save: {
|
|
47
|
+
readonly kind: "branch";
|
|
48
|
+
readonly branch: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: "skipped";
|
|
51
|
+
readonly reason: "detached-head";
|
|
52
|
+
} | null;
|
|
35
53
|
}
|
|
36
54
|
/**
|
|
37
55
|
* How the local checks ended.
|
|
@@ -61,7 +79,8 @@ export type PrepareRunnerOutcome = {
|
|
|
61
79
|
readonly failure: CheckoutFailure;
|
|
62
80
|
};
|
|
63
81
|
/**
|
|
64
|
-
* Runs the local checks in order: the repository's root, the base, the submodule refusal, the snapshot steps at
|
|
65
|
-
* base and their key, the runner's vCPUs, the upload, and the cache read. It never mints, leases or creates.
|
|
82
|
+
* Runs the local checks in order: the repository's root, HEAD, the base, the submodule refusal, the snapshot steps at
|
|
83
|
+
* the base and their key, the runner's vCPUs, the upload, and the cache read. It never mints, leases or creates. Under
|
|
84
|
+
* `--save-snapshot` it decides what the run saves: HEAD's branch, or nothing with a detached HEAD.
|
|
66
85
|
*/
|
|
67
86
|
export declare function prepareRunner(context: RunnerPrepareContext, request: PrepareRunnerRequest): Promise<PrepareRunnerOutcome>;
|
package/dist/runner/prepare.js
CHANGED
|
@@ -6,8 +6,9 @@ import { resolveVcpus } from "./recipe.js";
|
|
|
6
6
|
import { findSnapshotCandidates, } from "./snapshot-cache.js";
|
|
7
7
|
import { snapshotStepsAt } from "./snapshot-key.js";
|
|
8
8
|
/**
|
|
9
|
-
* Runs the local checks in order: the repository's root, the base, the submodule refusal, the snapshot steps at
|
|
10
|
-
* base and their key, the runner's vCPUs, the upload, and the cache read. It never mints, leases or creates.
|
|
9
|
+
* Runs the local checks in order: the repository's root, HEAD, the base, the submodule refusal, the snapshot steps at
|
|
10
|
+
* the base and their key, the runner's vCPUs, the upload, and the cache read. It never mints, leases or creates. Under
|
|
11
|
+
* `--save-snapshot` it decides what the run saves: HEAD's branch, or nothing with a detached HEAD.
|
|
11
12
|
*/
|
|
12
13
|
export async function prepareRunner(context, request) {
|
|
13
14
|
const { checkout } = context;
|
|
@@ -16,6 +17,9 @@ export async function prepareRunner(context, request) {
|
|
|
16
17
|
if (!root.ok)
|
|
17
18
|
return { kind: "checkout-failed", failure: root.failure };
|
|
18
19
|
const repoRoot = root.value;
|
|
20
|
+
const head = await checkout.head({ repoRoot });
|
|
21
|
+
if (!head.ok)
|
|
22
|
+
return { kind: "checkout-failed", failure: head.failure };
|
|
19
23
|
const resolved = await resolveBase(checkout, { repoRoot, baseRefs: recipe.baseRefs });
|
|
20
24
|
if (resolved.kind === "failed")
|
|
21
25
|
return { kind: "checkout-failed", failure: resolved.failure };
|
|
@@ -38,12 +42,13 @@ export async function prepareRunner(context, request) {
|
|
|
38
42
|
return { kind: "checkout-failed", failure: upload.failure };
|
|
39
43
|
const cache = request.rebuild
|
|
40
44
|
? { candidates: [], notes: [] }
|
|
41
|
-
: await findSnapshotCandidates(context, { repoRoot, recipe });
|
|
45
|
+
: await findSnapshotCandidates(context, { repoRoot, recipe, branch: head.value.branch });
|
|
42
46
|
return {
|
|
43
47
|
kind: "ok",
|
|
44
48
|
prepared: {
|
|
45
49
|
recipe,
|
|
46
50
|
repoRoot,
|
|
51
|
+
head: head.value,
|
|
47
52
|
base,
|
|
48
53
|
baseRef: resolved.ref,
|
|
49
54
|
toolchains: steps.toolchains,
|
|
@@ -54,6 +59,11 @@ export async function prepareRunner(context, request) {
|
|
|
54
59
|
candidates: cache.candidates,
|
|
55
60
|
rebuild: request.rebuild,
|
|
56
61
|
notes: cache.notes,
|
|
62
|
+
save: !request.saveSnapshot
|
|
63
|
+
? null
|
|
64
|
+
: head.value.branch === null
|
|
65
|
+
? { kind: "skipped", reason: "detached-head" }
|
|
66
|
+
: { kind: "branch", branch: head.value.branch },
|
|
57
67
|
},
|
|
58
68
|
};
|
|
59
69
|
}
|
package/dist/runner/ready.d.ts
CHANGED
|
@@ -8,11 +8,15 @@ export declare const APPLY_LABEL = "Applying your changes";
|
|
|
8
8
|
/** A runner sandbox ready for the command. */
|
|
9
9
|
export interface ReadyRunner {
|
|
10
10
|
readonly sandbox: RunnerSandbox;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The cache entry of the runner snapshot it started from: a base snapshot or a branch snapshot, whose base its
|
|
13
|
+
* repository holds as its first commit.
|
|
14
|
+
*/
|
|
15
|
+
readonly startedFrom: RunnerSnapshotEntry;
|
|
14
16
|
/** Whether this run built the runner snapshot. */
|
|
15
17
|
readonly built: boolean;
|
|
18
|
+
/** How long the build step took, in milliseconds. */
|
|
19
|
+
readonly buildMs: number;
|
|
16
20
|
readonly vcpus: number;
|
|
17
21
|
readonly region: string;
|
|
18
22
|
readonly runtime: string;
|
package/dist/runner/ready.js
CHANGED
|
@@ -24,7 +24,13 @@ export async function readyRunner(context, request, control, progress) {
|
|
|
24
24
|
let entry;
|
|
25
25
|
if (picked !== undefined) {
|
|
26
26
|
entry = picked.entry;
|
|
27
|
-
await progress.emit({
|
|
27
|
+
await progress.emit({
|
|
28
|
+
kind: "snapshot-reused",
|
|
29
|
+
snapshotId: entry.snapshotId,
|
|
30
|
+
base: entry.base,
|
|
31
|
+
branch: entry.branch ?? null,
|
|
32
|
+
head: entry.head ?? null,
|
|
33
|
+
});
|
|
28
34
|
}
|
|
29
35
|
else {
|
|
30
36
|
const built = await buildSnapshot(context, { prepared, access, user: request.user, reason: prepared.rebuild ? "rebuild" : "no-snapshot" }, control, progress);
|
|
@@ -83,9 +89,9 @@ export async function readyRunner(context, request, control, progress) {
|
|
|
83
89
|
kind: "ready",
|
|
84
90
|
runner: {
|
|
85
91
|
sandbox,
|
|
86
|
-
|
|
87
|
-
base: entry.base,
|
|
92
|
+
startedFrom: entry,
|
|
88
93
|
built: picked === undefined,
|
|
94
|
+
buildMs: built.value,
|
|
89
95
|
vcpus: prepared.vcpus,
|
|
90
96
|
region: recipe.region,
|
|
91
97
|
runtime: recipe.runtime,
|
|
@@ -133,7 +139,7 @@ export function stagedChanges(upload) {
|
|
|
133
139
|
: [{ name: STAGED_FILES.untrackedTarball, content: upload.untrackedTarball }]),
|
|
134
140
|
];
|
|
135
141
|
}
|
|
136
|
-
/** Runs the apply, install or build step; the install and build get rule lines. */
|
|
142
|
+
/** Runs the apply, install or build step, answering how long it took; the install and build get rule lines. */
|
|
137
143
|
async function stage(context, request, signal, progress) {
|
|
138
144
|
if (signal.aborted)
|
|
139
145
|
return { kind: "aborted" };
|
|
@@ -145,7 +151,7 @@ async function stage(context, request, signal, progress) {
|
|
|
145
151
|
if (ran.kind === "succeeded") {
|
|
146
152
|
if (section !== undefined)
|
|
147
153
|
await progress.emit({ kind: "output-ended", section, outcome: "finished" });
|
|
148
|
-
return { kind: "ok", value:
|
|
154
|
+
return { kind: "ok", value: ran.ms };
|
|
149
155
|
}
|
|
150
156
|
const stop = ran.kind === "exited"
|
|
151
157
|
? {
|
package/dist/runner/scope.d.ts
CHANGED
|
@@ -5,6 +5,20 @@ import type { RunnerSandbox, RunnerSandboxGateway, RunnerSandboxPlacement, Runne
|
|
|
5
5
|
export declare const CREATE_SETTLE_MS = 20000;
|
|
6
6
|
/** How long closing waits for a runner snapshot still saving: 2 minutes. */
|
|
7
7
|
export declare const SNAPSHOT_SETTLE_MS: number;
|
|
8
|
+
/**
|
|
9
|
+
* What a runner run does with its runner sandbox once it ends, decided before the run starts: keep it running `ms`
|
|
10
|
+
* (`keep`; 0 stops and deletes it), or save it as a branch snapshot of `branch` (`save`, `--save-snapshot` on a
|
|
11
|
+
* branch), which never keeps it, whether the save runs or not.
|
|
12
|
+
*/
|
|
13
|
+
export type RunnerSandboxPlan = {
|
|
14
|
+
readonly kind: "keep";
|
|
15
|
+
readonly ms: number;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: "save";
|
|
18
|
+
readonly branch: string;
|
|
19
|
+
};
|
|
20
|
+
/** How long `plan` keeps the runner sandbox running once the run ends, in milliseconds: 0 for a save. */
|
|
21
|
+
export declare function keptMs(plan: RunnerSandboxPlan): number;
|
|
8
22
|
/**
|
|
9
23
|
* What closing a scope left: the runner sandbox it kept running (`kept`), or couldn't keep running and so stopped and
|
|
10
24
|
* deleted (`notKept`), each null otherwise, and the sandboxes it couldn't stop or delete.
|
|
@@ -30,7 +44,9 @@ export interface RunnerSandboxScope {
|
|
|
30
44
|
startRunnerSandbox(access: SandboxAccess, request: RunnerSandboxPlacement & {
|
|
31
45
|
readonly snapshotId: string;
|
|
32
46
|
}): Promise<RunnerSandboxResult<RunnerSandbox, RunnerStartFailure>>;
|
|
33
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Saves a build or runner sandbox as a runner snapshot, then deletes it at once; a failed save leaves it to `close`.
|
|
49
|
+
*/
|
|
34
50
|
saveSnapshot(sandbox: RunnerSandbox, request: {
|
|
35
51
|
readonly expirationMs: number;
|
|
36
52
|
}): Promise<RunnerSandboxResult<SavedSnapshot>>;
|
package/dist/runner/scope.js
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
export const CREATE_SETTLE_MS = 20_000;
|
|
7
7
|
/** How long closing waits for a runner snapshot still saving: 2 minutes. */
|
|
8
8
|
export const SNAPSHOT_SETTLE_MS = 2 * 60_000;
|
|
9
|
+
/** How long `plan` keeps the runner sandbox running once the run ends, in milliseconds: 0 for a save. */
|
|
10
|
+
export function keptMs(plan) {
|
|
11
|
+
return plan.kind === "keep" ? plan.ms : 0;
|
|
12
|
+
}
|
|
9
13
|
/**
|
|
10
14
|
* A scope over `context.runnerSandboxes`, waiting with `context.timer` and reporting to `progress`, which keeps the
|
|
11
15
|
* runner sandbox running `keepMs` past closing (`context.clock` says when that is), or stops and deletes it with the
|
|
@@ -25,7 +25,9 @@ export interface BuildSnapshotRequest {
|
|
|
25
25
|
/**
|
|
26
26
|
* Builds a runner snapshot of `prepared.base`. The build sandbox starts while the base's files are packed, and is
|
|
27
27
|
* deleted once saved; a build that fails leaves it to the scope to stop and delete. A cache entry that can't be
|
|
28
|
-
* written is reported, and the build still succeeds.
|
|
28
|
+
* written is reported, and the build still succeeds. Under `--rebuild-snapshot` it then removes HEAD's branch's branch
|
|
29
|
+
* snapshot entries for the same owner and recipe, so the next run doesn't start from one the rebuild meant to replace;
|
|
30
|
+
* one it can't remove is reported.
|
|
29
31
|
*/
|
|
30
32
|
export declare function buildSnapshot(context: Pick<RunnerContext, "checkout" | "runnerSnapshots" | "runnerSandboxes" | "clock">, request: BuildSnapshotRequest, control: {
|
|
31
33
|
readonly scope: RunnerSandboxScope;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Building a runner snapshot of a run's base: a build sandbox runs the toolchain steps, commits exactly the base's
|
|
2
2
|
// tracked files, runs the warm steps, and is saved as a snapshot, which the cache then records.
|
|
3
3
|
import { runnerTags } from "./context.js";
|
|
4
|
-
import { SNAPSHOT_EXPIRATION_MS } from "./snapshot-cache.js";
|
|
4
|
+
import { dropBranchSnapshots, SNAPSHOT_EXPIRATION_MS } from "./snapshot-cache.js";
|
|
5
5
|
import { baseIndexScript, STAGED_FILES } from "./snapshot-key.js";
|
|
6
6
|
import { runStep, sandboxStop } from "./steps.js";
|
|
7
7
|
/** How long a build sandbox may live: 30 minutes. */
|
|
@@ -11,7 +11,9 @@ export const BASE_INDEX_LABEL = "Committing the base's files";
|
|
|
11
11
|
/**
|
|
12
12
|
* Builds a runner snapshot of `prepared.base`. The build sandbox starts while the base's files are packed, and is
|
|
13
13
|
* deleted once saved; a build that fails leaves it to the scope to stop and delete. A cache entry that can't be
|
|
14
|
-
* written is reported, and the build still succeeds.
|
|
14
|
+
* written is reported, and the build still succeeds. Under `--rebuild-snapshot` it then removes HEAD's branch's branch
|
|
15
|
+
* snapshot entries for the same owner and recipe, so the next run doesn't start from one the rebuild meant to replace;
|
|
16
|
+
* one it can't remove is reported.
|
|
15
17
|
*/
|
|
16
18
|
export async function buildSnapshot(context, request, control, progress) {
|
|
17
19
|
const { prepared, access } = request;
|
|
@@ -100,6 +102,14 @@ export async function buildSnapshot(context, request, control, progress) {
|
|
|
100
102
|
const written = await context.runnerSnapshots.writeEntry(entry);
|
|
101
103
|
if (!written.ok)
|
|
102
104
|
await progress.emit({ kind: "snapshot-entry-not-written", failure: written.failure });
|
|
105
|
+
const { branch } = prepared.head;
|
|
106
|
+
if (request.reason === "rebuild" && branch !== null) {
|
|
107
|
+
const dropped = await dropBranchSnapshots(context.runnerSnapshots, { branch, repoRoot, owner: access, recipe });
|
|
108
|
+
if (dropped.snapshotIds.length > 0)
|
|
109
|
+
await progress.emit({ kind: "branch-snapshots-dropped", branch, snapshotIds: dropped.snapshotIds });
|
|
110
|
+
for (const failure of dropped.failures)
|
|
111
|
+
await progress.emit({ kind: "branch-snapshots-not-dropped", branch, failure });
|
|
112
|
+
}
|
|
103
113
|
const ms = now() - startedAt;
|
|
104
114
|
await progress.emit({
|
|
105
115
|
kind: "snapshot-built",
|
|
@@ -9,9 +9,18 @@ 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, snapshot key and
|
|
12
|
+
* name, snapshot key, base and, for a branch snapshot only, branch and checkout root, joined with NUL. Entries with
|
|
13
|
+
* one identity replace each other: a base snapshot's entry replaces the base snapshot's at its base, and a branch
|
|
14
|
+
* snapshot's replaces that branch's in that checkout at its base. A base snapshot's identity is the one it had before
|
|
15
|
+
* branch snapshots existed.
|
|
13
16
|
*/
|
|
14
17
|
export declare function snapshotEntryIdentity(entry: RunnerSnapshotEntry): string;
|
|
18
|
+
/** Whether `entry` records a branch snapshot, saved from a run on its branch, rather than a base snapshot. */
|
|
19
|
+
export declare function isBranchEntry(entry: RunnerSnapshotEntry): entry is RunnerSnapshotEntry & {
|
|
20
|
+
readonly branch: string;
|
|
21
|
+
readonly head: string;
|
|
22
|
+
readonly repoRoot: string;
|
|
23
|
+
};
|
|
15
24
|
/** The name of the file that records `entry`: its identity and `.json`. */
|
|
16
25
|
export declare function snapshotEntryFileName(entry: RunnerSnapshotEntry): string;
|
|
17
26
|
/** Whether `entry`'s snapshot has expired at `now`. */
|
|
@@ -61,24 +70,53 @@ export interface SnapshotCacheContext {
|
|
|
61
70
|
readonly clock: Clock;
|
|
62
71
|
}
|
|
63
72
|
/**
|
|
64
|
-
* Reads the cache for the runner snapshots a run of `recipe` may start from. It removes expired entries'
|
|
65
|
-
* keeps the entries for the recipe's region, runtime and name with more than an hour left, whose base HEAD
|
|
66
|
-
* (a base missing from the clone doesn't), and whose snapshot key, recomputed at that entry's base, is the
|
|
67
|
-
* recorded.
|
|
73
|
+
* Reads the cache for the runner snapshots a run of `recipe` on `branch` may start from. It removes expired entries'
|
|
74
|
+
* files, and keeps the entries for the recipe's region, runtime and name with more than an hour left, whose base HEAD
|
|
75
|
+
* contains (a base missing from the clone doesn't), and whose snapshot key, recomputed at that entry's base, is the
|
|
76
|
+
* one recorded. Of branch snapshots it keeps only `branch`'s saved from this checkout, `repoRoot`, whatever HEAD
|
|
77
|
+
* commit saved them; with `branch` null, a detached HEAD, it keeps none. A branch of the same name in another checkout
|
|
78
|
+
* may hold other code, so its snapshot never carries over. A failure along the way is a note, never a refusal.
|
|
68
79
|
*/
|
|
69
80
|
export declare function findSnapshotCandidates(context: SnapshotCacheContext, request: {
|
|
70
81
|
readonly repoRoot: string;
|
|
71
82
|
readonly recipe: Pick<CheckedRecipe, "name" | "region" | "runtime" | "snapshot">;
|
|
83
|
+
/** HEAD's branch; null when detached. */
|
|
84
|
+
readonly branch: string | null;
|
|
72
85
|
}): Promise<{
|
|
73
86
|
readonly candidates: readonly RunnerSnapshotCandidate[];
|
|
74
87
|
readonly notes: readonly SnapshotCacheNote[];
|
|
75
88
|
}>;
|
|
76
89
|
/**
|
|
77
|
-
* Picks the runner snapshot a run starts from, once the credential names its team and project
|
|
78
|
-
*
|
|
79
|
-
*
|
|
90
|
+
* Picks the runner snapshot a run starts from, once the credential names its team and project. Of the candidates for
|
|
91
|
+
* them it finds the base nearest HEAD, the one every other candidate's base is an ancestor of; when bases are on
|
|
92
|
+
* separate lines of history, the newest commit. Of the candidates at that base it picks a branch snapshot over the
|
|
93
|
+
* base snapshot, then the one that expires later, so a branch snapshot of an older base never beats a nearer base.
|
|
94
|
+
* `undefined` when none is for them.
|
|
80
95
|
*/
|
|
81
96
|
export declare function pickSnapshot(candidates: readonly RunnerSnapshotCandidate[], owner: {
|
|
82
97
|
readonly teamId: string;
|
|
83
98
|
readonly projectId: string;
|
|
84
99
|
}): RunnerSnapshotCandidate | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* What dropping a branch's runner snapshots from the cache did: the snapshot ids of the entries it removed, and why
|
|
102
|
+
* it couldn't list the cache or remove an entry, if it couldn't.
|
|
103
|
+
*/
|
|
104
|
+
export interface DroppedBranchSnapshots {
|
|
105
|
+
readonly snapshotIds: readonly string[];
|
|
106
|
+
readonly failures: readonly RunnerSnapshotCacheFailure[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Removes every cached branch snapshot entry of `branch` in the checkout at `repoRoot` for `owner`'s team and project
|
|
110
|
+
* and the recipe's region, runtime and name, whatever its base, so a run after `--rebuild-snapshot` doesn't start
|
|
111
|
+
* from a branch snapshot the rebuild meant to replace. The snapshots themselves are left to expire. A failure is
|
|
112
|
+
* reported, never a refusal.
|
|
113
|
+
*/
|
|
114
|
+
export declare function dropBranchSnapshots(runnerSnapshots: RunnerSnapshotCacheGateway, request: {
|
|
115
|
+
readonly branch: string;
|
|
116
|
+
readonly repoRoot: string;
|
|
117
|
+
readonly owner: {
|
|
118
|
+
readonly teamId: string;
|
|
119
|
+
readonly projectId: string;
|
|
120
|
+
};
|
|
121
|
+
readonly recipe: Pick<CheckedRecipe, "name" | "region" | "runtime">;
|
|
122
|
+
}): Promise<DroppedBranchSnapshots>;
|