@cnc-tools/storm 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.d.ts +22 -13
- package/dist/application.js +21 -10
- package/dist/bin/run.d.ts +18 -0
- package/dist/bin/run.js +31 -0
- package/dist/bin/storm.js +42 -26
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
- package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
- package/dist/chunks/{chunk-SZEURWRS.js → chunk-4O5C2XGJ.js} +18 -15
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
- package/dist/chunks/{chunk-QVS7HRU7.js → chunk-6UHIJXZG.js} +3 -3
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/{chunk-4U4DZ7VG.js → chunk-7DZE67QM.js} +2 -2
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
- package/dist/chunks/{chunk-QUHY6FGN.js → chunk-CKGZA25H.js} +1 -18
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
- package/dist/chunks/{chunk-KC4KDJ5K.js → chunk-DADEYJDW.js} +174 -153
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/chunk-F4MOYHRY.js +198 -0
- package/dist/chunks/{chunk-CXAT7ZKP.js → chunk-FNBB6V4R.js} +1 -1
- package/dist/chunks/{chunk-OX7X4B2L.js → chunk-GRT3UIBV.js} +18 -1
- package/dist/chunks/chunk-HP3CURSZ.js +88 -0
- package/dist/chunks/{chunk-PN5ULTTH.js → chunk-HWIQ2S7K.js} +5 -5
- package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
- package/dist/chunks/{chunk-XEVHP5ZW.js → chunk-M7EKRGVD.js} +8 -8
- package/dist/chunks/chunk-MR77L2GK.js +340 -0
- package/dist/chunks/{chunk-L36GBUBB.js → chunk-RNAS7JHE.js} +1755 -522
- package/dist/chunks/{chunk-5GBMR4HM.js → chunk-RWIXDDCK.js} +4 -192
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{chunk-YV7GE6EV.js → chunk-YEPFSLQR.js} +480 -375
- package/dist/chunks/{live-app-PI3BAN6Y.js → live-app-R76JQXZL.js} +15 -13
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
- package/dist/commands/exec/across-sandboxes-outcomes.js +4 -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 +39 -4
- 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 +38 -9
- package/dist/commands/exec/outcomes.js +32 -25
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +232 -88
- package/dist/commands/exec/planned-outcome.js +8 -1
- 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 +5 -5
- 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 +9 -4
- package/dist/commands/runs/facts.js +28 -11
- package/dist/commands/runs/list/command.d.ts +16 -6
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +8 -3
- package/dist/commands/runs/logs/command.d.ts +6 -2
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/logs/outcomes.d.ts +3 -1
- package/dist/commands/runs/past-run.d.ts +14 -5
- package/dist/commands/runs/past-run.js +16 -5
- package/dist/commands/runs/show/command.d.ts +20 -8
- package/dist/commands/runs/show/command.js +30 -28
- package/dist/commands/runs/show/outcomes.d.ts +10 -4
- package/dist/commands/runs/show/outcomes.js +7 -5
- package/dist/commands/snapshots/access.d.ts +111 -0
- package/dist/commands/snapshots/access.js +96 -0
- package/dist/commands/snapshots/build/command.d.ts +360 -93
- package/dist/commands/snapshots/build/command.js +446 -150
- package/dist/commands/snapshots/build/metadata.d.ts +10 -0
- package/dist/commands/snapshots/build/metadata.js +31 -11
- package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +368 -27
- package/dist/commands/snapshots/list/command.js +296 -66
- package/dist/commands/snapshots/list/metadata.d.ts +16 -0
- package/dist/commands/snapshots/list/metadata.js +29 -6
- package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
- package/dist/commands/snapshots/list/outcomes.js +221 -50
- package/dist/commands/snapshots/metadata.js +1 -1
- package/dist/commands/snapshots/prune/command.d.ts +430 -0
- package/dist/commands/snapshots/prune/command.js +161 -0
- package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
- package/dist/commands/snapshots/prune/metadata.js +39 -0
- package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
- package/dist/commands/snapshots/prune/outcomes.js +78 -0
- package/dist/commands/suites/list/command.js +19 -18
- package/dist/commands/suites/list/outcomes.js +4 -4
- package/dist/commands/test/command.d.ts +39 -4
- package/dist/commands/test/command.js +50 -255
- package/dist/commands/test/metadata.js +1 -1
- package/dist/commands/test/outcomes.d.ts +19 -2
- package/dist/commands/test/outcomes.js +2 -2
- package/dist/config/check-runner.d.ts +5 -3
- package/dist/config/check-runner.js +33 -7
- package/dist/config/check-suites.js +1 -0
- 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/gateways.d.ts +7 -3
- package/dist/config/index.d.ts +4 -5
- package/dist/config/index.js +3 -4
- package/dist/config/live/config-gateway.js +5 -2
- package/dist/config/load.d.ts +21 -4
- package/dist/config/load.js +129 -15
- package/dist/config/runner.d.ts +7 -8
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +17 -5
- package/dist/config/schema.js +11 -3
- package/dist/config/typed-options.d.ts +1 -6
- package/dist/config/typed-options.js +2 -10
- package/dist/config-file/define.d.ts +1 -11
- package/dist/config-file/define.js +3 -3
- package/dist/config-file/runner.d.ts +5 -6
- package/dist/config-file/toolchain.d.ts +13 -7
- package/dist/config-file/toolchain.js +53 -37
- package/dist/context.d.ts +8 -6
- package/dist/context.js +7 -6
- package/dist/core/across-sandboxes.d.ts +7 -6
- package/dist/core/across-sandboxes.js +123 -152
- package/dist/core/coordinator.d.ts +166 -0
- package/dist/core/coordinator.js +233 -0
- package/dist/core/events.d.ts +2 -2
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +1 -1
- package/dist/core/outcomes.d.ts +148 -0
- package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
- package/dist/core/resources.d.ts +31 -53
- package/dist/core/resources.js +32 -70
- package/dist/core/run-state.d.ts +7 -1
- package/dist/core/run-state.js +2 -0
- package/dist/core/run.d.ts +32 -236
- package/dist/core/run.js +106 -266
- package/dist/core/state-directory.d.ts +1 -1
- package/dist/core/state-directory.js +2 -2
- package/dist/credential/gateways.d.ts +15 -1
- package/dist/credential/index.d.ts +4 -3
- package/dist/credential/index.js +3 -2
- package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
- package/dist/credential/live/vercel-cli-gateway.js +1 -1
- package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
- package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
- package/dist/credential/source.d.ts +73 -6
- package/dist/credential/source.js +55 -2
- package/dist/extension-commands.d.ts +6 -1
- package/dist/extension-commands.js +15 -1
- package/dist/extensions/github/resource.d.ts +1 -1
- package/dist/extensions/github/resource.js +1 -1
- package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
- package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
- package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
- package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
- package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
- package/dist/extensions/testserver/credential-facts.d.ts +6 -2
- package/dist/extensions/testserver/credential-facts.js +29 -11
- package/dist/extensions/testserver/lifecycle.js +7 -1
- package/dist/extensions/testserver/limit.d.ts +3 -0
- package/dist/extensions/testserver/limit.js +3 -0
- package/dist/extensions/testserver/provision.d.ts +8 -1
- package/dist/extensions/testserver/provision.js +8 -3
- package/dist/extensions/testserver/refusals.d.ts +6 -1
- package/dist/extensions/testserver/refusals.js +16 -1
- package/dist/extensions/testserver/resource.d.ts +2 -2
- package/dist/extensions/testserver/resource.js +2 -2
- 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 +7 -15
- package/dist/planning/plan-only.js +16 -22
- package/dist/planning/run-kind-flags.js +2 -2
- package/dist/planning/run-plan.d.ts +45 -13
- 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 +10 -2
- package/dist/run-directory/recording.js +2 -2
- package/dist/run-directory/run-record.d.ts +21 -6
- package/dist/run-directory/run-record.js +12 -9
- package/dist/runner/base.d.ts +0 -6
- package/dist/runner/base.js +1 -16
- package/dist/runner/build-snapshots.d.ts +55 -29
- package/dist/runner/build-snapshots.js +135 -35
- 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 +92 -21
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/index.d.ts +11 -7
- package/dist/runner/index.js +9 -4
- package/dist/runner/live/sandbox-errors.d.ts +2 -0
- package/dist/runner/live/sandbox-errors.js +4 -0
- package/dist/runner/live/sandbox-gateway.js +141 -3
- package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
- package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
- package/dist/runner/live/snapshot-records.js +6 -7
- package/dist/runner/local-snapshot-index.d.ts +199 -0
- package/dist/runner/local-snapshot-index.js +211 -0
- package/dist/runner/network-policy.d.ts +6 -6
- package/dist/runner/network-policy.js +7 -7
- package/dist/runner/policy-writes.d.ts +1 -1
- package/dist/runner/policy-writes.js +1 -1
- package/dist/runner/prepare.d.ts +25 -24
- package/dist/runner/prepare.js +28 -20
- package/dist/runner/ready.d.ts +18 -10
- package/dist/runner/ready.js +104 -33
- package/dist/runner/sandboxed-command.d.ts +3 -3
- package/dist/runner/sandboxed-command.js +3 -3
- package/dist/runner/scope.d.ts +10 -6
- package/dist/runner/scope.js +10 -3
- package/dist/runner/secrets.d.ts +13 -13
- package/dist/runner/secrets.js +18 -15
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +3 -3
- package/dist/runner/shared-snapshot-entry.d.ts +92 -0
- package/dist/runner/shared-snapshot-entry.js +168 -0
- package/dist/runner/shared-snapshot-list.d.ts +81 -0
- package/dist/runner/shared-snapshot-list.js +155 -0
- package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
- package/dist/runner/shared-snapshot-lookup.js +118 -0
- package/dist/runner/shared-snapshot-prune.d.ts +58 -0
- package/dist/runner/shared-snapshot-prune.js +133 -0
- package/dist/runner/snapshot-build.d.ts +42 -14
- package/dist/runner/snapshot-build.js +38 -28
- package/dist/runner/snapshot-choice.js +1 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +58 -38
- package/dist/runner/snapshot-key.d.ts +30 -21
- package/dist/runner/snapshot-key.js +49 -29
- package/dist/runner/steps.d.ts +1 -1
- package/dist/runner/steps.js +1 -1
- package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +82 -82
- package/dist/runner/vercel-sandbox-options.js +510 -0
- package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
- package/dist/sdk/extension/commands.d.ts +8 -3
- package/dist/sdk/extension/commands.js +3 -1
- package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
- package/dist/sdk/extension/credential-diagnosis.js +25 -5
- package/dist/sdk/extension/credential-source.d.ts +20 -3
- package/dist/sdk/extension/credential-source.js +4 -4
- package/dist/sdk/extension/index.d.ts +3 -2
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +4 -3
- package/dist/sdk/extension/resource-definition.js +3 -2
- package/dist/sdk/extension/resource-factory.js +3 -4
- 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/sdk/run/present.d.ts +3 -3
- package/dist/sdk/run/present.js +1 -3
- package/dist/shared/cleanup.d.ts +3 -3
- package/dist/shared/cleanup.js +15 -5
- package/dist/shared/snapshot-text.d.ts +4 -4
- package/dist/shared/snapshot-text.js +11 -11
- package/dist/time/duration.js +1 -1
- package/package.json +3 -2
- package/skills/overview.md +6 -4
- package/skills/plan-runs.md +2 -2
- package/skills/read-run-output.md +6 -6
- package/dist/chunks/chunk-E4PJNZVG.js +0 -783
- package/dist/chunks/chunk-RAQEXKL6.js +0 -2591
- 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 -46
- package/dist/commands/exec/run-command.d.ts +0 -476
- package/dist/commands/exec/run-command.js +0 -604
- 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 -128
- package/dist/config/recipe-run.d.ts +0 -33
- package/dist/config/recipe-run.js +0 -28
- package/dist/core/sandbox-end.d.ts +0 -64
- package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
- package/dist/runner/recipe.js +0 -425
- package/dist/runner/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
package/dist/runner/recipe.js
DELETED
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
// The runner recipe, the `runner` key of `storm.config.ts`: what a repository's runner snapshot holds and what
|
|
2
|
-
// each run does on top of it. `checkRecipe` holds the recipe's static rules; `resolveSteps` and `resolveVcpus`
|
|
3
|
-
// evaluate the parts a recipe may give as functions, and check what they return. The module names no resource: a
|
|
4
|
-
// `vcpus` function's run is a type parameter, which the config module declares (`RecipeRun`).
|
|
5
|
-
import { parseKeepTime, parseTtl } from "../time/index.js";
|
|
6
|
-
import { RUN_PAYLOAD_VARIABLE } from "../sdk/run/launcher.js";
|
|
7
|
-
import { describeRecipeValue, reportUnknownKeys } from "./recipe-check.js";
|
|
8
|
-
import { checkCredentials, checkUnsafeSecretEnvVars, credentialSourceIds, } from "./recipe-secrets.js";
|
|
9
|
-
export { credentialSourceIds };
|
|
10
|
-
/**
|
|
11
|
-
* storm's own limit on the number of runner sandboxes, which `runner.sandboxes.max` can't pass: a guard against a
|
|
12
|
-
* typing mistake that would start hundreds of runner sandboxes, not a claim about what Vercel Sandbox holds.
|
|
13
|
-
*/
|
|
14
|
-
export const MAX_RUNNER_SANDBOXES = 32;
|
|
15
|
-
/** The defaults of a recipe's optional keys. */
|
|
16
|
-
export const RECIPE_DEFAULTS = {
|
|
17
|
-
cwd: ".",
|
|
18
|
-
timeout: "60m",
|
|
19
|
-
baseRefs: ["main", "origin/main"],
|
|
20
|
-
region: "iad1",
|
|
21
|
-
runtime: "node22",
|
|
22
|
-
};
|
|
23
|
-
const RECIPE_KEYS = new Set([
|
|
24
|
-
"name",
|
|
25
|
-
"snapshot",
|
|
26
|
-
"run",
|
|
27
|
-
"cwd",
|
|
28
|
-
"vcpus",
|
|
29
|
-
"env",
|
|
30
|
-
"credentials",
|
|
31
|
-
"unsafeSecretEnvVars",
|
|
32
|
-
"allowedDomains",
|
|
33
|
-
"timeout",
|
|
34
|
-
"keepSandbox",
|
|
35
|
-
"baseRefs",
|
|
36
|
-
"region",
|
|
37
|
-
"runtime",
|
|
38
|
-
"sandboxes",
|
|
39
|
-
]);
|
|
40
|
-
const SANDBOXES_KEYS = new Set(["max", "default"]);
|
|
41
|
-
const SNAPSHOT_KEYS = new Set(["vcpus", "summary", "toolchains", "prebuild"]);
|
|
42
|
-
const RUN_KEYS = new Set(["install", "build"]);
|
|
43
|
-
const STEP_KEYS = new Set(["label", "script"]);
|
|
44
|
-
const NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
45
|
-
/** A domain the recipe's `allowedDomains` lists: a bare hostname, or one with a leading `*.`. */
|
|
46
|
-
const ALLOWED_DOMAIN_PATTERN = /^(?:\*\.)?(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;
|
|
47
|
-
/**
|
|
48
|
-
* Checks a recipe against its static rules: the keys it may hold and each value's shape. Functions are checked only
|
|
49
|
-
* for being functions, so a `vcpus` function is taken to take `Run`; `resolveSteps` and `resolveVcpus` check what they
|
|
50
|
-
* return. Every problem is reported.
|
|
51
|
-
*/
|
|
52
|
-
export function checkRecipe(value) {
|
|
53
|
-
const problems = [];
|
|
54
|
-
const report = (path, problem) => problems.push({ path, problem });
|
|
55
|
-
if (!isRecord(value)) {
|
|
56
|
-
report([], `must be an object, not ${describeRecipeValue(value)}`);
|
|
57
|
-
return { ok: false, problems };
|
|
58
|
-
}
|
|
59
|
-
reportUnknownKeys(value, RECIPE_KEYS, [], "a runner recipe key", report);
|
|
60
|
-
const name = value["name"];
|
|
61
|
-
if (typeof name !== "string" || !NAME_PATTERN.test(name))
|
|
62
|
-
report(["name"], `must be lowercase letters, digits and dashes, starting with a letter or digit, not ${describeRecipeValue(name)}`);
|
|
63
|
-
const snapshot = checkSnapshot(value["snapshot"], report);
|
|
64
|
-
const run = checkRun(value["run"], report);
|
|
65
|
-
const cwd = orDefault(value["cwd"], RECIPE_DEFAULTS.cwd);
|
|
66
|
-
if (!isRelativePath(cwd))
|
|
67
|
-
report(["cwd"], `must be a path relative to the repository's root, without "..", not ${describeRecipeValue(cwd)}`);
|
|
68
|
-
const vcpus = value["vcpus"];
|
|
69
|
-
if (typeof vcpus !== "function" && !isPositiveInteger(vcpus))
|
|
70
|
-
report(["vcpus"], `must be a positive whole number, or a function of the run, not ${describeRecipeValue(vcpus)}`);
|
|
71
|
-
const env = checkEnv(value["env"], report);
|
|
72
|
-
const credentials = checkCredentials(value["credentials"], report);
|
|
73
|
-
const unsafeSecretEnvVars = checkUnsafeSecretEnvVars(value["unsafeSecretEnvVars"], env, credentials, report);
|
|
74
|
-
const allowedDomains = checkAllowedDomains(value["allowedDomains"], report);
|
|
75
|
-
const timeout = orDefault(value["timeout"], RECIPE_DEFAULTS.timeout);
|
|
76
|
-
const timeoutMinutes = typeof timeout === "string" ? parseTtl(timeout) : undefined;
|
|
77
|
-
if (timeoutMinutes === undefined)
|
|
78
|
-
report(["timeout"], `must be a whole number of minutes or hours from 10m to 5h, not ${describeRecipeValue(timeout)}`);
|
|
79
|
-
const keepSandbox = value["keepSandbox"];
|
|
80
|
-
const keepSandboxMinutes = typeof keepSandbox === "string" ? parseKeepTime(keepSandbox) : undefined;
|
|
81
|
-
if (keepSandbox !== undefined && keepSandboxMinutes === undefined)
|
|
82
|
-
report(["keepSandbox"], `must be 0, or a whole number of minutes or hours up to 5h, not ${describeRecipeValue(keepSandbox)}`);
|
|
83
|
-
else if (unsafeSecretEnvVars !== undefined &&
|
|
84
|
-
unsafeSecretEnvVars.length > 0 &&
|
|
85
|
-
keepSandboxMinutes !== undefined &&
|
|
86
|
-
keepSandboxMinutes > 0)
|
|
87
|
-
report(["keepSandbox"], "can't be above 0 when runner.unsafeSecretEnvVars is set: a run that passes secrets into the runner sandbox's environment never keeps its runner sandbox");
|
|
88
|
-
const baseRefs = checkBaseRefs(value["baseRefs"], report);
|
|
89
|
-
const region = orDefault(value["region"], RECIPE_DEFAULTS.region);
|
|
90
|
-
if (!isNonEmptyString(region))
|
|
91
|
-
report(["region"], `must be a non-empty string, not ${describeRecipeValue(region)}`);
|
|
92
|
-
const runtime = orDefault(value["runtime"], RECIPE_DEFAULTS.runtime);
|
|
93
|
-
if (!isNonEmptyString(runtime))
|
|
94
|
-
report(["runtime"], `must be a non-empty string, not ${describeRecipeValue(runtime)}`);
|
|
95
|
-
const sandboxes = checkSandboxes(value["sandboxes"], report);
|
|
96
|
-
if (problems.length > 0 ||
|
|
97
|
-
snapshot === undefined ||
|
|
98
|
-
run === undefined ||
|
|
99
|
-
env === undefined ||
|
|
100
|
-
credentials === undefined ||
|
|
101
|
-
unsafeSecretEnvVars === undefined ||
|
|
102
|
-
allowedDomains === null ||
|
|
103
|
-
baseRefs === undefined ||
|
|
104
|
-
timeoutMinutes === undefined ||
|
|
105
|
-
sandboxes === false)
|
|
106
|
-
return { ok: false, problems };
|
|
107
|
-
return {
|
|
108
|
-
ok: true,
|
|
109
|
-
value: {
|
|
110
|
-
name: name,
|
|
111
|
-
snapshot,
|
|
112
|
-
run,
|
|
113
|
-
cwd: cwd,
|
|
114
|
-
vcpus: vcpus,
|
|
115
|
-
env,
|
|
116
|
-
credentials,
|
|
117
|
-
unsafeSecretEnvVars,
|
|
118
|
-
...(allowedDomains === undefined ? {} : { allowedDomains }),
|
|
119
|
-
timeout: timeout,
|
|
120
|
-
timeoutMinutes,
|
|
121
|
-
keepSandboxMinutes,
|
|
122
|
-
baseRefs,
|
|
123
|
-
region: region,
|
|
124
|
-
runtime: runtime,
|
|
125
|
-
...(sandboxes === undefined ? {} : { sandboxes }),
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* The recipe's `sandboxes`: an object whose `max` is a whole number from 1 to `MAX_RUNNER_SANDBOXES`, and whose
|
|
131
|
-
* optional `default` is a whole number from 1 to `MAX_RUNNER_SANDBOXES` or a function, which is checked only for being
|
|
132
|
-
* one (`resolveSandboxCountDefault` checks what it returns); undefined when absent, and false when it is wrong, which
|
|
133
|
-
* is reported.
|
|
134
|
-
*/
|
|
135
|
-
function checkSandboxes(value, report) {
|
|
136
|
-
if (value === undefined)
|
|
137
|
-
return undefined;
|
|
138
|
-
if (!isRecord(value)) {
|
|
139
|
-
report(["sandboxes"], `must be an object with max, not ${describeRecipeValue(value)}`);
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
let ok = reportUnknownKeys(value, SANDBOXES_KEYS, ["sandboxes"], "a runner recipe sandboxes key", report);
|
|
143
|
-
const max = value["max"];
|
|
144
|
-
if (!isPositiveInteger(max) || max > MAX_RUNNER_SANDBOXES) {
|
|
145
|
-
report(["sandboxes", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeRecipeValue(max)}`);
|
|
146
|
-
ok = false;
|
|
147
|
-
}
|
|
148
|
-
const sandboxesDefault = value["default"];
|
|
149
|
-
if (sandboxesDefault !== undefined &&
|
|
150
|
-
typeof sandboxesDefault !== "function" &&
|
|
151
|
-
!(isPositiveInteger(sandboxesDefault) && sandboxesDefault <= MAX_RUNNER_SANDBOXES)) {
|
|
152
|
-
report(["sandboxes", "default"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or a function of the run's test plan, not ${describeRecipeValue(sandboxesDefault)}`);
|
|
153
|
-
ok = false;
|
|
154
|
-
}
|
|
155
|
-
if (!ok)
|
|
156
|
-
return false;
|
|
157
|
-
return {
|
|
158
|
-
max: max,
|
|
159
|
-
...(sandboxesDefault === undefined ? {} : { default: sandboxesDefault }),
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
function checkSnapshot(value, report) {
|
|
163
|
-
if (!isRecord(value)) {
|
|
164
|
-
report(["snapshot"], `must be an object of vcpus, toolchains, prebuild, and an optional summary, not ${describeRecipeValue(value)}`);
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
|
167
|
-
let ok = reportUnknownKeys(value, SNAPSHOT_KEYS, ["snapshot"], "a runner recipe snapshot key", report);
|
|
168
|
-
const vcpus = value["vcpus"];
|
|
169
|
-
if (!isPositiveInteger(vcpus)) {
|
|
170
|
-
report(["snapshot", "vcpus"], `must be a positive whole number, not ${describeRecipeValue(vcpus)}`);
|
|
171
|
-
ok = false;
|
|
172
|
-
}
|
|
173
|
-
const summary = value["summary"];
|
|
174
|
-
if (summary !== undefined && !isNonEmptyString(summary)) {
|
|
175
|
-
report(["snapshot", "summary"], `must be a non-empty string, not ${describeRecipeValue(summary)}`);
|
|
176
|
-
ok = false;
|
|
177
|
-
}
|
|
178
|
-
const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], report);
|
|
179
|
-
const prebuild = checkSteps(value["prebuild"], ["snapshot", "prebuild"], report);
|
|
180
|
-
if (!ok || toolchains === undefined || prebuild === undefined)
|
|
181
|
-
return undefined;
|
|
182
|
-
return {
|
|
183
|
-
vcpus: vcpus,
|
|
184
|
-
...(summary === undefined ? {} : { summary: summary }),
|
|
185
|
-
toolchains,
|
|
186
|
-
prebuild,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
function checkRun(value, report) {
|
|
190
|
-
if (!isRecord(value)) {
|
|
191
|
-
report(["run"], `must be an object of install and build steps, not ${describeRecipeValue(value)}`);
|
|
192
|
-
return undefined;
|
|
193
|
-
}
|
|
194
|
-
const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a runner recipe run key", report);
|
|
195
|
-
const install = checkStep(value["install"], ["run", "install"], report);
|
|
196
|
-
const build = checkStep(value["build"], ["run", "build"], report);
|
|
197
|
-
return ok && install !== undefined && build !== undefined ? { install, build } : undefined;
|
|
198
|
-
}
|
|
199
|
-
function checkSteps(value, path, report) {
|
|
200
|
-
if (typeof value === "function")
|
|
201
|
-
return value;
|
|
202
|
-
if (!Array.isArray(value)) {
|
|
203
|
-
report(path, `must be a list of steps, or a function that returns one, not ${describeRecipeValue(value)}`);
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
const steps = value.map((step, index) => checkStep(step, [...path, String(index)], report));
|
|
207
|
-
return steps.every((step) => step !== undefined) ? steps : undefined;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* One step: a label and a script. A step's `secrets` key is refused with its own problem, since every recipe step gets
|
|
211
|
-
* every credential the recipe declares and a step names none itself.
|
|
212
|
-
*/
|
|
213
|
-
function checkStep(value, path, report) {
|
|
214
|
-
if (!isRecord(value)) {
|
|
215
|
-
report(path, `must be a step, { label, script }, not ${describeRecipeValue(value)}`);
|
|
216
|
-
return undefined;
|
|
217
|
-
}
|
|
218
|
-
let ok = true;
|
|
219
|
-
for (const key of Object.keys(value)) {
|
|
220
|
-
if (STEP_KEYS.has(key))
|
|
221
|
-
continue;
|
|
222
|
-
report([...path, key], key === "secrets"
|
|
223
|
-
? "is not a step key: every recipe step gets every credential runner.credentials declares"
|
|
224
|
-
: "is not a step key");
|
|
225
|
-
ok = false;
|
|
226
|
-
}
|
|
227
|
-
const label = value["label"];
|
|
228
|
-
const script = value["script"];
|
|
229
|
-
if (!isNonEmptyString(label)) {
|
|
230
|
-
report([...path, "label"], `must be a non-empty string, not ${describeRecipeValue(label)}`);
|
|
231
|
-
ok = false;
|
|
232
|
-
}
|
|
233
|
-
if (!isNonEmptyString(script)) {
|
|
234
|
-
report([...path, "script"], `must be a non-empty string, not ${describeRecipeValue(script)}`);
|
|
235
|
-
ok = false;
|
|
236
|
-
}
|
|
237
|
-
return ok ? { label: label, script: script } : undefined;
|
|
238
|
-
}
|
|
239
|
-
function checkEnv(value, report) {
|
|
240
|
-
if (value === undefined)
|
|
241
|
-
return {};
|
|
242
|
-
if (!isRecord(value)) {
|
|
243
|
-
report(["env"], `must be an object of strings, not ${describeRecipeValue(value)}`);
|
|
244
|
-
return undefined;
|
|
245
|
-
}
|
|
246
|
-
let ok = true;
|
|
247
|
-
const env = {};
|
|
248
|
-
for (const [key, variable] of Object.entries(value)) {
|
|
249
|
-
if (key === RUN_PAYLOAD_VARIABLE) {
|
|
250
|
-
report(["env", key], "can't be set: storm sets it for the command");
|
|
251
|
-
ok = false;
|
|
252
|
-
}
|
|
253
|
-
else if (typeof variable !== "string") {
|
|
254
|
-
report(["env", key], `must be a string, not ${describeRecipeValue(variable)}`);
|
|
255
|
-
ok = false;
|
|
256
|
-
}
|
|
257
|
-
else
|
|
258
|
-
env[key] = variable;
|
|
259
|
-
}
|
|
260
|
-
return ok ? env : undefined;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* The recipe's `allowedDomains`: a non-empty list of domains (`ALLOWED_DOMAIN_PATTERN`), none listed twice; undefined
|
|
264
|
-
* when absent, for full access, and null when it is wrong.
|
|
265
|
-
*/
|
|
266
|
-
function checkAllowedDomains(value, report) {
|
|
267
|
-
if (value === undefined)
|
|
268
|
-
return undefined;
|
|
269
|
-
if (!Array.isArray(value)) {
|
|
270
|
-
report(["allowedDomains"], `must be a list of domains, such as ["registry.npmjs.org", "*.example.com"], not ${describeRecipeValue(value)}`);
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
if (value.length === 0) {
|
|
274
|
-
report(["allowedDomains"], "must list at least one domain: leave the key out for full access");
|
|
275
|
-
return null;
|
|
276
|
-
}
|
|
277
|
-
let ok = true;
|
|
278
|
-
const seen = new Set();
|
|
279
|
-
value.forEach((domain, index) => {
|
|
280
|
-
const at = ["allowedDomains", String(index)];
|
|
281
|
-
if (domain === "*") {
|
|
282
|
-
report(at, "can't be *, which would allow every domain: leave runner.allowedDomains out for full access");
|
|
283
|
-
ok = false;
|
|
284
|
-
}
|
|
285
|
-
else if (typeof domain !== "string" || !ALLOWED_DOMAIN_PATTERN.test(domain)) {
|
|
286
|
-
report(at, `must be a hostname, such as example.com, or a wildcard with one leading *., such as *.example.com: lowercase letters, digits, dots, and hyphens, with at least one dot, and no scheme, port, or path, not ${describeRecipeValue(domain)}`);
|
|
287
|
-
ok = false;
|
|
288
|
-
}
|
|
289
|
-
else if (seen.has(domain)) {
|
|
290
|
-
report(at, `lists ${domain} again`);
|
|
291
|
-
ok = false;
|
|
292
|
-
}
|
|
293
|
-
if (typeof domain === "string")
|
|
294
|
-
seen.add(domain);
|
|
295
|
-
});
|
|
296
|
-
return ok ? [...value] : null;
|
|
297
|
-
}
|
|
298
|
-
function checkBaseRefs(value, report) {
|
|
299
|
-
if (value === undefined)
|
|
300
|
-
return [...RECIPE_DEFAULTS.baseRefs];
|
|
301
|
-
if (!Array.isArray(value) || value.length === 0) {
|
|
302
|
-
report(["baseRefs"], `must be a non-empty list of refs, not ${describeRecipeValue(value)}`);
|
|
303
|
-
return undefined;
|
|
304
|
-
}
|
|
305
|
-
let ok = true;
|
|
306
|
-
value.forEach((ref, index) => {
|
|
307
|
-
if (!isNonEmptyString(ref)) {
|
|
308
|
-
report(["baseRefs", String(index)], `must be a non-empty string, not ${describeRecipeValue(ref)}`);
|
|
309
|
-
ok = false;
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
return ok ? [...value] : undefined;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* What a recipe's steps are at one base: the list as given, or what the function returns for `context`, checked. A
|
|
316
|
-
* function that throws or rejects, or returns anything but a list of steps, is a problem worded to follow the key.
|
|
317
|
-
*/
|
|
318
|
-
export async function resolveSteps(steps, context) {
|
|
319
|
-
// A list passed `checkRecipe`.
|
|
320
|
-
if (typeof steps !== "function")
|
|
321
|
-
return { ok: true, steps: steps.map(({ label, script }) => ({ label, script })) };
|
|
322
|
-
let returned;
|
|
323
|
-
try {
|
|
324
|
-
returned = await steps(context);
|
|
325
|
-
}
|
|
326
|
-
catch (error) {
|
|
327
|
-
return { ok: false, problem: `threw at base ${context.base.slice(0, 12)}: ${errorMessage(error)}` };
|
|
328
|
-
}
|
|
329
|
-
if (!Array.isArray(returned))
|
|
330
|
-
return { ok: false, problem: `must return a list of steps, not ${describeRecipeValue(returned)}` };
|
|
331
|
-
const problems = [];
|
|
332
|
-
const checked = returned.map((step, index) => checkStep(step, [String(index)], (path, problem) => problems.push({ path, problem })));
|
|
333
|
-
const first = problems[0];
|
|
334
|
-
if (first !== undefined)
|
|
335
|
-
return {
|
|
336
|
-
ok: false,
|
|
337
|
-
problem: `must return a list of { label, script } steps, but item ${first.path.join(".")} ${first.problem}`,
|
|
338
|
-
};
|
|
339
|
-
return { ok: true, steps: checked };
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* The runner sandbox's vCPUs for `run`: the recipe's number, or what its function returns for the run, which must be a
|
|
343
|
-
* positive whole number.
|
|
344
|
-
*/
|
|
345
|
-
export function resolveVcpus(recipe, { run, resourceKeys }) {
|
|
346
|
-
if (typeof recipe.vcpus !== "function")
|
|
347
|
-
return { ok: true, vcpus: recipe.vcpus };
|
|
348
|
-
let returned;
|
|
349
|
-
try {
|
|
350
|
-
returned = recipe.vcpus(run);
|
|
351
|
-
}
|
|
352
|
-
catch (error) {
|
|
353
|
-
return { ok: false, problem: `threw for ${describeResourceKeys(resourceKeys)}: ${errorMessage(error)}` };
|
|
354
|
-
}
|
|
355
|
-
return isPositiveInteger(returned)
|
|
356
|
-
? { ok: true, vcpus: returned }
|
|
357
|
-
: {
|
|
358
|
-
ok: false,
|
|
359
|
-
problem: `must return a positive whole number, not ${describeRecipeValue(returned)} for ${describeResourceKeys(resourceKeys)}`,
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the recipe's number,
|
|
364
|
-
* or what its function returns for `{ testPlan }`, which must be a whole number from 1. A number above the limit is not
|
|
365
|
-
* a problem here: the run lowers it to `max` and says so. A function that throws, or returns anything else, is a
|
|
366
|
-
* problem worded to follow the key, which names the test plan.
|
|
367
|
-
*/
|
|
368
|
-
export function resolveSandboxCountDefault(sandboxesDefault, testPlan) {
|
|
369
|
-
if (typeof sandboxesDefault !== "function")
|
|
370
|
-
return { ok: true, sandboxes: sandboxesDefault };
|
|
371
|
-
let returned;
|
|
372
|
-
try {
|
|
373
|
-
returned = sandboxesDefault(Object.freeze({ testPlan }));
|
|
374
|
-
}
|
|
375
|
-
catch (error) {
|
|
376
|
-
return { ok: false, problem: `threw for ${describeTestPlan(testPlan)}: ${errorMessage(error)}` };
|
|
377
|
-
}
|
|
378
|
-
return isPositiveInteger(returned)
|
|
379
|
-
? { ok: true, sandboxes: returned }
|
|
380
|
-
: {
|
|
381
|
-
ok: false,
|
|
382
|
-
problem: `must return a whole number from 1, not ${describeRecipeValue(returned)} for ${describeTestPlan(testPlan)}`,
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* A test plan as a problem names it: `a test plan of 57 test files`, `a test plan of 65 tests in 19 test files`, or
|
|
387
|
-
* `a test plan that counted nothing`.
|
|
388
|
-
*/
|
|
389
|
-
function describeTestPlan(testPlan) {
|
|
390
|
-
if (testPlan.kind !== "counted")
|
|
391
|
-
return "a test plan that counted nothing";
|
|
392
|
-
const files = `${testPlan.files} test ${testPlan.files === 1 ? "file" : "files"}`;
|
|
393
|
-
return testPlan.tests === undefined
|
|
394
|
-
? `a test plan of ${files}`
|
|
395
|
-
: `a test plan of ${testPlan.tests} ${testPlan.tests === 1 ? "test" : "tests"} in ${files}`;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* The run as a problem names it, by the keys of its resources: `a run with no resource`, or `a run with` and the
|
|
399
|
-
* keys, as `a`, `a and b` or `a, b and c`.
|
|
400
|
-
*/
|
|
401
|
-
function describeResourceKeys(names) {
|
|
402
|
-
const last = names.at(-1);
|
|
403
|
-
if (last === undefined)
|
|
404
|
-
return "a run with no resource";
|
|
405
|
-
return `a run with ${names.length === 1 ? last : `${names.slice(0, -1).join(", ")} and ${last}`}`;
|
|
406
|
-
}
|
|
407
|
-
function errorMessage(error) {
|
|
408
|
-
return error instanceof Error ? error.message : String(error);
|
|
409
|
-
}
|
|
410
|
-
/** `value`, or `fallback` when the key is absent or set to `undefined`. A `null` stays, to be refused. */
|
|
411
|
-
function orDefault(value, fallback) {
|
|
412
|
-
return value === undefined ? fallback : value;
|
|
413
|
-
}
|
|
414
|
-
function isRecord(value) {
|
|
415
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
416
|
-
}
|
|
417
|
-
function isNonEmptyString(value) {
|
|
418
|
-
return typeof value === "string" && value.length > 0;
|
|
419
|
-
}
|
|
420
|
-
function isPositiveInteger(value) {
|
|
421
|
-
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
422
|
-
}
|
|
423
|
-
function isRelativePath(value) {
|
|
424
|
-
return (typeof value === "string" && value.length > 0 && !value.startsWith("/") && !value.split(/[/\\]/).includes(".."));
|
|
425
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import type { Clock } from "../time/index.ts";
|
|
2
|
-
import type { CheckoutGateway, RunnerSnapshotCacheFailure, RunnerSnapshotCacheGateway, RunnerSnapshotEntry } from "./gateways.ts";
|
|
3
|
-
import type { CheckedRecipe } from "./recipe.ts";
|
|
4
|
-
/** The subpath of storm's state directory that holds the runner snapshot cache. */
|
|
5
|
-
export declare const RUNNER_SNAPSHOTS_SUBPATH: readonly string[];
|
|
6
|
-
/** How long a runner snapshot lives after it is built: 7 days. The Sandbox API needs 0 or at least a day. */
|
|
7
|
-
export declare const SNAPSHOT_EXPIRATION_MS: number;
|
|
8
|
-
/** A run never picks a runner snapshot with this little left or less, 1 hour, so it can't expire before the start. */
|
|
9
|
-
export declare const SNAPSHOT_MIN_REMAINING_MS: number;
|
|
10
|
-
/**
|
|
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 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.
|
|
14
|
-
*/
|
|
15
|
-
export declare function snapshotEntryIdentity(entry: RunnerSnapshotEntry): string;
|
|
16
|
-
/** The name of the file that records `entry`: its identity and `.json`. */
|
|
17
|
-
export declare function snapshotEntryFileName(entry: RunnerSnapshotEntry): string;
|
|
18
|
-
/** Whether `entry`'s snapshot has expired at `now`. */
|
|
19
|
-
export declare function isExpiredEntry(entry: RunnerSnapshotEntry, now: Date): boolean;
|
|
20
|
-
/** Whether `entry`'s snapshot has more than `SNAPSHOT_MIN_REMAINING_MS` left at `now`. */
|
|
21
|
-
export declare function hasTimeLeft(entry: RunnerSnapshotEntry, now: Date): boolean;
|
|
22
|
-
/**
|
|
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.
|
|
25
|
-
*/
|
|
26
|
-
export interface RunnerSnapshotCandidate {
|
|
27
|
-
readonly entry: RunnerSnapshotEntry;
|
|
28
|
-
/**
|
|
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.
|
|
31
|
-
*/
|
|
32
|
-
readonly builtBehind: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Why a run doesn't start from a cached snapshot of its recipe.
|
|
36
|
-
*
|
|
37
|
-
* - `expired`: it has expired. A run's path removes the file first (`removeExpiredEntries`), so only a list of
|
|
38
|
-
* entries that still holds it, as `storm snapshots list`'s does, gets this reason.
|
|
39
|
-
* - `expires-soon`: it has `SNAPSHOT_MIN_REMAINING_MS` or less left.
|
|
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.
|
|
42
|
-
* - `steps-changed`: its snapshot key isn't the run's, the one the recipe's snapshot steps give at the merge-base.
|
|
43
|
-
* - `other-owner`: it was built for another team or project than the run's credential names.
|
|
44
|
-
*
|
|
45
|
-
* The classification gives all but the last, in that order of checks (`classifySnapshotEntries`); `other-owner`
|
|
46
|
-
* needs the team and project (`snapshotRejections`).
|
|
47
|
-
*/
|
|
48
|
-
export type SnapshotRejectionReason = "expired" | "expires-soon" | "other-base" | "steps-changed" | "other-owner";
|
|
49
|
-
/** A cached snapshot of the run's recipe that the run doesn't start from, and why. */
|
|
50
|
-
export interface RejectedSnapshot {
|
|
51
|
-
readonly entry: RunnerSnapshotEntry;
|
|
52
|
-
readonly reason: SnapshotRejectionReason;
|
|
53
|
-
}
|
|
54
|
-
/** What the cache read found: the candidates, and the recipe's other entries with why each isn't one. */
|
|
55
|
-
export interface SnapshotCacheRead {
|
|
56
|
-
readonly candidates: readonly RunnerSnapshotCandidate[];
|
|
57
|
-
readonly rejected: readonly RejectedSnapshot[];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* What the classification says of one `entry` it was given: a candidate, a rejection with its reason, or that the
|
|
61
|
-
* entry is of another recipe, region or runtime (`other-recipe`), which no run of the recipe looks at.
|
|
62
|
-
*/
|
|
63
|
-
export type SnapshotVerdict = {
|
|
64
|
-
readonly kind: "candidate";
|
|
65
|
-
readonly entry: RunnerSnapshotEntry;
|
|
66
|
-
readonly candidate: RunnerSnapshotCandidate;
|
|
67
|
-
} | {
|
|
68
|
-
readonly kind: "rejected";
|
|
69
|
-
readonly entry: RunnerSnapshotEntry;
|
|
70
|
-
readonly rejection: RejectedSnapshot;
|
|
71
|
-
} | {
|
|
72
|
-
readonly kind: "other-recipe";
|
|
73
|
-
readonly entry: RunnerSnapshotEntry;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* What `classifySnapshotEntries` found: the cache read's candidates and rejections, and one verdict per entry it was
|
|
77
|
-
* given, in the order given. Each verdict holds the same candidate or rejection object as the lists.
|
|
78
|
-
*/
|
|
79
|
-
export interface SnapshotClassification extends SnapshotCacheRead {
|
|
80
|
-
readonly verdicts: readonly SnapshotVerdict[];
|
|
81
|
-
}
|
|
82
|
-
/** What `removeExpiredEntries` left: the cache's unexpired entries, and its notes. */
|
|
83
|
-
export interface SnapshotCacheListing {
|
|
84
|
-
readonly entries: readonly RunnerSnapshotEntry[];
|
|
85
|
-
readonly notes: readonly SnapshotCacheNote[];
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Something removing expired entries noticed (`removeExpiredEntries`), which the run reports and goes on from.
|
|
89
|
-
*
|
|
90
|
-
* - `cache-unreadable`: the cache couldn't be listed, so the run treats it as empty.
|
|
91
|
-
* - `expired-entry-not-removed`: an expired entry's file couldn't be removed.
|
|
92
|
-
*/
|
|
93
|
-
export type SnapshotCacheNote = {
|
|
94
|
-
readonly kind: "cache-unreadable";
|
|
95
|
-
readonly failure: RunnerSnapshotCacheFailure;
|
|
96
|
-
} | {
|
|
97
|
-
readonly kind: "expired-entry-not-removed";
|
|
98
|
-
readonly entry: RunnerSnapshotEntry;
|
|
99
|
-
readonly failure: RunnerSnapshotCacheFailure;
|
|
100
|
-
};
|
|
101
|
-
/** What the cache context needs: the checkout, the cache and the clock. */
|
|
102
|
-
export interface SnapshotCacheContext {
|
|
103
|
-
readonly checkout: CheckoutGateway;
|
|
104
|
-
readonly runnerSnapshots: RunnerSnapshotCacheGateway;
|
|
105
|
-
readonly clock: Clock;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Lists the cache and removes the files of expired entries, as a run's read does before it classifies the rest
|
|
109
|
-
* (`classifySnapshotEntries`). It gives the unexpired entries, and notes `expired-entry-not-removed` for a file it
|
|
110
|
-
* couldn't remove, whose entry it leaves out all the same. A cache it can't list is empty, with the note
|
|
111
|
-
* `cache-unreadable`. Only a run's path calls it: `storm snapshots list` removes no file.
|
|
112
|
-
*/
|
|
113
|
-
export declare function removeExpiredEntries(context: Pick<SnapshotCacheContext, "runnerSnapshots" | "clock">): Promise<SnapshotCacheListing>;
|
|
114
|
-
/**
|
|
115
|
-
* Classifies `entries`, cache entries a caller listed, for a run of `recipe`: which ones it may start from, and why
|
|
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.
|
|
120
|
-
*/
|
|
121
|
-
export declare function classifySnapshotEntries(context: Pick<SnapshotCacheContext, "clock">, request: {
|
|
122
|
-
readonly entries: readonly RunnerSnapshotEntry[];
|
|
123
|
-
readonly recipe: Pick<CheckedRecipe, "name" | "region" | "runtime">;
|
|
124
|
-
/** The run's base, HEAD's merge-base with a base ref: a candidate's base is this one. */
|
|
125
|
-
readonly base: string;
|
|
126
|
-
/** The run's snapshot key, the recipe's snapshot steps at `base`: a candidate's key is this one. */
|
|
127
|
-
readonly snapshotKey: string;
|
|
128
|
-
/** How many commits HEAD has that `base` lacks: each candidate's `builtBehind`. */
|
|
129
|
-
readonly commitsAfterBase: number;
|
|
130
|
-
}): SnapshotClassification;
|
|
131
|
-
/**
|
|
132
|
-
* Why a run for `owner`'s team and project starts from none of the recipe's cached snapshots, when the pick found no
|
|
133
|
-
* candidate of theirs: every candidate is then another team's or project's, `other-owner`; an entry for another team
|
|
134
|
-
* or project is `other-owner`, whatever else rules it out; and any other entry keeps the classification's reason.
|
|
135
|
-
*/
|
|
136
|
-
export declare function snapshotRejections(read: SnapshotCacheRead, owner: {
|
|
137
|
-
readonly teamId: string;
|
|
138
|
-
readonly projectId: string;
|
|
139
|
-
}): RejectedSnapshot[];
|
|
140
|
-
/**
|
|
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.
|
|
144
|
-
*/
|
|
145
|
-
export declare function pickSnapshot(candidates: readonly RunnerSnapshotCandidate[], owner: {
|
|
146
|
-
readonly teamId: string;
|
|
147
|
-
readonly projectId: string;
|
|
148
|
-
}): RunnerSnapshotCandidate | undefined;
|