@cnc-tools/storm 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/storm.js +1 -1
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-QUHY6FGN.js → chunk-2MAD5NKK.js} +1 -1
- package/dist/chunks/{chunk-XEVHP5ZW.js → chunk-3L52KNQA.js} +1 -1
- package/dist/chunks/{chunk-E4PJNZVG.js → chunk-7EENF73W.js} +12 -13
- package/dist/chunks/{chunk-4U4DZ7VG.js → chunk-CK2GZEPK.js} +1 -1
- package/dist/chunks/{chunk-L36GBUBB.js → chunk-DC2CDHNK.js} +398 -158
- package/dist/chunks/{chunk-PN5ULTTH.js → chunk-DWEAHX4T.js} +1 -1
- package/dist/chunks/{chunk-5GBMR4HM.js → chunk-FCQUJDA4.js} +4 -7
- package/dist/chunks/{chunk-YV7GE6EV.js → chunk-FOZWA52V.js} +1 -1
- package/dist/chunks/{chunk-OX7X4B2L.js → chunk-G3PHMXH5.js} +1 -1
- package/dist/chunks/{chunk-CXAT7ZKP.js → chunk-HVNK3I45.js} +1 -1
- package/dist/chunks/{chunk-QVS7HRU7.js → chunk-OIY3DMF2.js} +2 -2
- package/dist/chunks/{chunk-SZEURWRS.js → chunk-P357TZAY.js} +2 -2
- package/dist/chunks/{chunk-KC4KDJ5K.js → chunk-V4IKA3WI.js} +153 -139
- package/dist/chunks/{chunk-RAQEXKL6.js → chunk-Z5PBVG3Y.js} +26 -18
- package/dist/chunks/{live-app-PI3BAN6Y.js → live-app-WECQOQ4C.js} +4 -4
- package/dist/commands/exec/across-sandboxes-outcomes.js +2 -1
- package/dist/commands/exec/command.d.ts +8 -2
- package/dist/commands/exec/command.js +11 -11
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +4 -1
- package/dist/commands/exec/outcomes.js +2 -2
- package/dist/commands/exec/plan-only.js +1 -2
- package/dist/commands/exec/planned-outcome.js +8 -1
- package/dist/commands/exec/run-command.d.ts +6 -7
- package/dist/commands/exec/run-command.js +8 -9
- package/dist/commands/exec/run-metadata.js +1 -1
- package/dist/commands/runs/facts.d.ts +2 -1
- package/dist/commands/runs/facts.js +11 -3
- package/dist/commands/runs/list/command.d.ts +2 -0
- package/dist/commands/runs/list/command.js +6 -6
- package/dist/commands/runs/list/outcomes.d.ts +1 -0
- package/dist/commands/runs/logs/command.d.ts +6 -2
- package/dist/commands/runs/logs/command.js +6 -6
- 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 +6 -2
- package/dist/commands/runs/show/command.js +9 -9
- package/dist/commands/runs/show/outcomes.d.ts +3 -1
- package/dist/commands/snapshots/build/command.js +11 -11
- package/dist/commands/snapshots/list/command.d.ts +3 -3
- package/dist/commands/snapshots/list/command.js +6 -6
- package/dist/commands/snapshots/list/metadata.js +1 -1
- package/dist/commands/suites/list/command.js +7 -6
- package/dist/commands/suites/list/outcomes.js +2 -2
- package/dist/commands/test/command.d.ts +8 -2
- package/dist/commands/test/command.js +38 -40
- package/dist/commands/test/metadata.js +1 -1
- package/dist/commands/test/outcomes.d.ts +4 -1
- package/dist/commands/test/outcomes.js +2 -2
- package/dist/commands/test/plan.d.ts +2 -2
- package/dist/commands/test/plan.js +2 -5
- package/dist/config/check-runner.d.ts +4 -2
- package/dist/config/check-runner.js +27 -2
- package/dist/config/check-suites.js +1 -0
- package/dist/config/gateways.d.ts +7 -3
- package/dist/config/index.d.ts +2 -3
- package/dist/config/index.js +2 -3
- 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 +5 -6
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +15 -3
- package/dist/config/schema.js +10 -2
- 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 +2 -3
- package/dist/config-file/toolchain.d.ts +13 -7
- package/dist/config-file/toolchain.js +51 -35
- 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.js +1 -1
- package/dist/extensions/testserver/resource.d.ts +2 -2
- package/dist/extensions/testserver/resource.js +2 -2
- package/dist/planning/plan-only.d.ts +4 -1
- package/dist/planning/plan-only.js +5 -2
- package/dist/planning/run-plan.d.ts +1 -2
- package/dist/planning/test-plan.js +1 -2
- package/dist/runner/base.d.ts +0 -6
- package/dist/runner/base.js +0 -15
- package/dist/runner/build-snapshots.js +7 -8
- package/dist/runner/gateways.d.ts +5 -0
- package/dist/runner/index.d.ts +1 -1
- package/dist/runner/live/sandbox-gateway.js +12 -0
- package/dist/runner/prepare.d.ts +16 -15
- package/dist/runner/prepare.js +11 -12
- package/dist/runner/recipe.d.ts +66 -67
- package/dist/runner/recipe.js +204 -120
- package/dist/runner/snapshot-build.d.ts +1 -1
- package/dist/runner/snapshot-build.js +10 -3
- package/dist/runner/snapshot-inspect.d.ts +4 -4
- package/dist/runner/snapshot-inspect.js +7 -7
- package/dist/runner/snapshot-key.d.ts +23 -15
- package/dist/runner/snapshot-key.js +46 -27
- package/dist/sdk/extension/resource-definition.d.ts +3 -2
- package/dist/sdk/extension/resource-definition.js +3 -2
- package/dist/sdk/extension/resource-factory.js +3 -4
- package/dist/sdk/run/present.d.ts +3 -3
- package/dist/sdk/run/present.js +1 -3
- package/package.json +1 -1
- package/skills/overview.md +2 -0
- package/skills/plan-runs.md +1 -1
- package/dist/config/recipe-run.d.ts +0 -33
- package/dist/config/recipe-run.js +0 -28
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
configErrors,
|
|
28
28
|
credentialErrors,
|
|
29
29
|
credentialSourceErrors
|
|
30
|
-
} from "../../../../../chunks/chunk-
|
|
30
|
+
} from "../../../../../chunks/chunk-DC2CDHNK.js";
|
|
31
31
|
import "../../../../../chunks/chunk-AWBSONHB.js";
|
|
32
32
|
import {
|
|
33
33
|
defineOutcomes,
|
|
@@ -9,8 +9,8 @@ export type { TestserverPoolOptions } from "./options/index.ts";
|
|
|
9
9
|
*
|
|
10
10
|
* Its presence gives a run the Testserver pool; `testserverPool()` takes every default. `storm test` and
|
|
11
11
|
* `storm exec` override each option with its own flag, `--testserver-<option>`, and `storm ext testserver pool create`
|
|
12
|
-
* reads `build` and `ttl`. A runner recipe
|
|
13
|
-
* `
|
|
12
|
+
* reads `build` and `ttl`. A runner recipe's declared `vcpus` rule can scale from its options by resource key
|
|
13
|
+
* `"testserverPool"`, such as `option: "sandboxes"`.
|
|
14
14
|
*/
|
|
15
15
|
export declare const testserverPool: import("../../sdk/extension/resource-factory.ts").ResourceFactory<import("../../sdk/extension/resource-definition.ts").ResourceDefinition<"testserverPool", {
|
|
16
16
|
readonly sandboxes: {
|
|
@@ -13,7 +13,7 @@ import { testserverPoolDefinition } from "./definition.js";
|
|
|
13
13
|
*
|
|
14
14
|
* Its presence gives a run the Testserver pool; `testserverPool()` takes every default. `storm test` and
|
|
15
15
|
* `storm exec` override each option with its own flag, `--testserver-<option>`, and `storm ext testserver pool create`
|
|
16
|
-
* reads `build` and `ttl`. A runner recipe
|
|
17
|
-
* `
|
|
16
|
+
* reads `build` and `ttl`. A runner recipe's declared `vcpus` rule can scale from its options by resource key
|
|
17
|
+
* `"testserverPool"`, such as `option: "sandboxes"`.
|
|
18
18
|
*/
|
|
19
19
|
export const testserverPool = resourceFactory(testserverPoolDefinition);
|
|
@@ -38,7 +38,10 @@ export declare const plannedSchema: z.ZodObject<{
|
|
|
38
38
|
testFiles: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
39
39
|
runnerSandboxes: z.ZodNullable<z.ZodObject<{
|
|
40
40
|
max: z.ZodNumber;
|
|
41
|
-
default: z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.
|
|
41
|
+
default: z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
42
|
+
filesPerSandbox: z.ZodNumber;
|
|
43
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
}, z.core.$strip>]>>;
|
|
42
45
|
}, z.core.$strip>>;
|
|
43
46
|
sandboxes: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
44
47
|
sandbox: z.ZodNumber;
|
|
@@ -23,7 +23,10 @@ export const plannedSchema = z.object({
|
|
|
23
23
|
plan: planSchema.nullable(),
|
|
24
24
|
testFiles: z.array(z.string()).nullable(),
|
|
25
25
|
runnerSandboxes: z
|
|
26
|
-
.object({
|
|
26
|
+
.object({
|
|
27
|
+
max: z.number(),
|
|
28
|
+
default: z.union([z.number(), z.object({ filesPerSandbox: z.number(), max: z.number().optional() })]).nullable(),
|
|
29
|
+
})
|
|
27
30
|
.nullable(),
|
|
28
31
|
sandboxes: z
|
|
29
32
|
.array(z.object({ sandbox: z.number(), argv: z.array(z.string()), files: z.array(z.string()).nullable() }))
|
|
@@ -60,7 +63,7 @@ export function buildPlannedFacts(input) {
|
|
|
60
63
|
? null
|
|
61
64
|
: {
|
|
62
65
|
max: policy.max,
|
|
63
|
-
default: policy.default
|
|
66
|
+
default: policy.default ?? null,
|
|
64
67
|
},
|
|
65
68
|
sandboxes: sandboxes === undefined
|
|
66
69
|
? null
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RecipeRun } from "../config/index.ts";
|
|
2
1
|
import type { MintTarget } from "../credential/index.ts";
|
|
3
2
|
import type { PlannedSandboxCount, RecordedSandboxStart } from "../run-directory/index.ts";
|
|
4
3
|
import type { CheckedRecipe, UnsafeSecretEnvVarMap } from "../runner/index.ts";
|
|
@@ -13,7 +12,7 @@ export type PlannedWhere = {
|
|
|
13
12
|
} | {
|
|
14
13
|
readonly kind: "runner";
|
|
15
14
|
readonly configFile: string;
|
|
16
|
-
readonly recipe: CheckedRecipe
|
|
15
|
+
readonly recipe: CheckedRecipe;
|
|
17
16
|
readonly target: MintTarget;
|
|
18
17
|
readonly credentials: readonly Required<SandboxCredential>[];
|
|
19
18
|
readonly unsafeSecretEnvVars: UnsafeSecretEnvVarMap;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// whose default is a function of the planned run, with its value and where that came from. Their `ran` outcomes,
|
|
3
3
|
// `run.json` and `runs show` share its shape, which the run directory module declares (`run-directory/plan.ts`), and
|
|
4
4
|
// their line before the run and `runs show`'s row its text.
|
|
5
|
-
import { CONFIG_FILE_NAME } from "../config/index.js";
|
|
6
5
|
import { optionKeyPath } from "../sdk/extension/index.js";
|
|
7
6
|
import { RESOURCE_FLAGS } from "./resource-flags.js";
|
|
8
7
|
/** The plan a run records: with a counted test plan, its counts and `options`; none for a run that counted nothing. */
|
|
@@ -72,7 +71,7 @@ function fromText(path, from) {
|
|
|
72
71
|
case "flag":
|
|
73
72
|
return RESOURCE_FLAGS.find(({ resource, option }) => optionKeyPath(resource, option) === path)?.flag ?? "a flag";
|
|
74
73
|
case "file":
|
|
75
|
-
return
|
|
74
|
+
return "config file";
|
|
76
75
|
case "default":
|
|
77
76
|
return "default";
|
|
78
77
|
}
|
package/dist/runner/base.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CheckoutFailure, CheckoutGateway } from "./gateways.ts";
|
|
2
|
-
import type { RunnerStepContext } from "./recipe.ts";
|
|
3
2
|
/** Why one of `baseRefs` gave no base: it doesn't exist locally, or it shares no history with HEAD. */
|
|
4
3
|
export interface RefusedBaseRef {
|
|
5
4
|
readonly ref: string;
|
|
@@ -33,8 +32,3 @@ export declare function resolveBase(checkout: CheckoutGateway, request: {
|
|
|
33
32
|
readonly repoRoot: string;
|
|
34
33
|
readonly baseRefs: readonly string[];
|
|
35
34
|
}): Promise<BaseResolution>;
|
|
36
|
-
/** The context a recipe's step functions get at `base`: `readBaseFile` rejects for a file the base doesn't have. */
|
|
37
|
-
export declare function baseStepContext(checkout: CheckoutGateway, request: {
|
|
38
|
-
readonly repoRoot: string;
|
|
39
|
-
readonly base: string;
|
|
40
|
-
}): RunnerStepContext;
|
package/dist/runner/base.js
CHANGED
|
@@ -35,18 +35,3 @@ export async function resolveBase(checkout, request) {
|
|
|
35
35
|
}
|
|
36
36
|
return best === undefined ? { kind: "no-base-ref", refs: refused } : { kind: "resolved", ...best };
|
|
37
37
|
}
|
|
38
|
-
/** The context a recipe's step functions get at `base`: `readBaseFile` rejects for a file the base doesn't have. */
|
|
39
|
-
export function baseStepContext(checkout, request) {
|
|
40
|
-
const { repoRoot, base } = request;
|
|
41
|
-
return {
|
|
42
|
-
base,
|
|
43
|
-
readBaseFile: async (path) => {
|
|
44
|
-
const file = await checkout.readFileAt({ repoRoot, commit: base, path });
|
|
45
|
-
if (file.kind === "found")
|
|
46
|
-
return file.text;
|
|
47
|
-
if (file.kind === "missing")
|
|
48
|
-
throw new Error(`${path} doesn't exist at ${base.slice(0, 12)}`);
|
|
49
|
-
throw new Error(`can't read ${path} at ${base.slice(0, 12)}: ${file.failure.message}`);
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
@@ -7,7 +7,7 @@ import { runnerNetworkPolicy } from "./network-policy.js";
|
|
|
7
7
|
import { runnerSandboxScope } from "./scope.js";
|
|
8
8
|
import { buildSnapshot } from "./snapshot-build.js";
|
|
9
9
|
import { hasTimeLeft } from "./snapshot-cache.js";
|
|
10
|
-
import {
|
|
10
|
+
import { snapshotInputsAt } from "./snapshot-key.js";
|
|
11
11
|
/**
|
|
12
12
|
* Runs a build's local checks, before anything is minted or started: the repository's root, HEAD, the submodule
|
|
13
13
|
* refusal, HEAD's merge-base (`resolveBase`, which refuses with `no-base-ref` only without `--base`), the commit
|
|
@@ -47,9 +47,9 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
47
47
|
return { kind: "ref-not-found", ref };
|
|
48
48
|
base = commit.value;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
52
|
-
return { kind: "invalid-recipe", path:
|
|
50
|
+
const inputs = await snapshotInputsAt(checkout, { repoRoot, base, recipe });
|
|
51
|
+
if (!inputs.ok)
|
|
52
|
+
return { kind: "invalid-recipe", path: inputs.path, problem: inputs.problem };
|
|
53
53
|
// An unreadable cache holds nothing to reuse: the build goes on, and builds.
|
|
54
54
|
const listed = await context.runnerSnapshots.listEntries();
|
|
55
55
|
const now = context.clock.now();
|
|
@@ -57,7 +57,7 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
57
57
|
entry.recipeName === recipe.name &&
|
|
58
58
|
entry.region === recipe.region &&
|
|
59
59
|
entry.runtime === recipe.runtime &&
|
|
60
|
-
entry.snapshotKey ===
|
|
60
|
+
entry.snapshotKey === inputs.key &&
|
|
61
61
|
hasTimeLeft(entry, now));
|
|
62
62
|
const atMergeBase = base === mergeBase?.commit;
|
|
63
63
|
// The built snapshot's count behind HEAD, for a build at the merge-base, the one snapshot a run here starts from.
|
|
@@ -75,9 +75,8 @@ export async function prepareSnapshotBuild(context, request) {
|
|
|
75
75
|
recipe,
|
|
76
76
|
repoRoot,
|
|
77
77
|
base,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
snapshotKey: steps.key,
|
|
78
|
+
baseFiles: inputs.baseFiles,
|
|
79
|
+
snapshotKey: inputs.key,
|
|
81
80
|
commitsAfterBase,
|
|
82
81
|
},
|
|
83
82
|
head: head.value,
|
|
@@ -331,6 +331,11 @@ export interface RunnerSandboxGateway {
|
|
|
331
331
|
upload(sandbox: RunnerSandbox, files: readonly StagedFile[], signal?: AbortSignal): Promise<RunnerSandboxResult<{
|
|
332
332
|
readonly directory: string;
|
|
333
333
|
}>>;
|
|
334
|
+
/**
|
|
335
|
+
* Places declared base files at their repository-relative paths under `/vercel/sandbox` before toolchain steps run
|
|
336
|
+
* in a build sandbox.
|
|
337
|
+
*/
|
|
338
|
+
placeBaseFiles(sandbox: RunnerSandbox, files: readonly StagedFile[], signal?: AbortSignal): Promise<RunnerSandboxOperation>;
|
|
334
339
|
/** Runs a bash script with `bash -lc` in the repository's root, streaming its output to `onOutput`. */
|
|
335
340
|
runScript(sandbox: RunnerSandbox, request: {
|
|
336
341
|
readonly script: string;
|
package/dist/runner/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { liveRunnerSnapshotCacheGateway, unavailableRunnerSnapshotCacheGateway,
|
|
|
10
10
|
export { lineSplitter } from "./output.ts";
|
|
11
11
|
export { prepareRunner, type PrepareRunnerOutcome } from "./prepare.ts";
|
|
12
12
|
export type { ChosenSnapshot, ReadyRunnerOutcome } from "./ready.ts";
|
|
13
|
-
export { type CheckedRecipe, checkRecipe, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, type SandboxCountDefault, type
|
|
13
|
+
export { type CheckedRecipe, checkRecipe, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, type RunnerVcpuCount, type RunnerVcpuRule, type SandboxCountDefault, type SandboxCountDefaultRule, type RunnerSandboxCount, type ToolchainStep, type VcpuRun, } from "./recipe.ts";
|
|
14
14
|
export { chooseSnapshotForRun, type SnapshotChoice, type SnapshotChoiceEnd } from "./snapshot-choice.ts";
|
|
15
15
|
export { SANDBOX_TEST_EVENTS_PATH } from "./sandboxed-command.ts";
|
|
16
16
|
export type { RunnerFenceOutcome } from "./scope.ts";
|
|
@@ -99,6 +99,18 @@ export function liveRunnerSandboxGateway() {
|
|
|
99
99
|
return { ok: false, failure: sandboxFailure(error, signal) };
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
|
+
async placeBaseFiles(sandbox, files, signal) {
|
|
103
|
+
if (files.length === 0)
|
|
104
|
+
return { ok: true };
|
|
105
|
+
const holder = holding(sandbox);
|
|
106
|
+
try {
|
|
107
|
+
await holder.sandbox.writeFiles(writes(SANDBOX_ROOT, files), signal === undefined ? undefined : { signal });
|
|
108
|
+
return { ok: true };
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return { ok: false, failure: sandboxFailure(error, signal) };
|
|
112
|
+
}
|
|
113
|
+
},
|
|
102
114
|
async runScript(sandbox, request, onOutput, signal) {
|
|
103
115
|
const holder = holding(sandbox);
|
|
104
116
|
try {
|
package/dist/runner/prepare.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { type RefusedBaseRef } from "./base.ts";
|
|
2
2
|
import type { CheckoutFailure, CheckoutUpload } from "./gateways.ts";
|
|
3
|
-
import { type CheckedRecipe, type
|
|
3
|
+
import { type CheckedRecipe, type VcpuRun } from "./recipe.ts";
|
|
4
4
|
import { type RejectedSnapshot, type RunnerSnapshotCandidate, type SnapshotCacheContext, type SnapshotCacheNote } from "./snapshot-cache.ts";
|
|
5
|
+
import { type DeclaredBaseFile } from "./snapshot-key.ts";
|
|
5
6
|
/** What `prepareRunner` needs: the checkout, the runner snapshot cache and the clock. */
|
|
6
7
|
export type RunnerPrepareContext = SnapshotCacheContext;
|
|
7
|
-
/** What `prepareRunner` checks a run with
|
|
8
|
-
export interface PrepareRunnerRequest
|
|
8
|
+
/** What `prepareRunner` checks a run with. */
|
|
9
|
+
export interface PrepareRunnerRequest {
|
|
9
10
|
/** The directory the run started in, inside the checkout. */
|
|
10
11
|
readonly cwd: string;
|
|
11
|
-
readonly recipe: CheckedRecipe
|
|
12
|
-
/** The run
|
|
13
|
-
readonly
|
|
12
|
+
readonly recipe: CheckedRecipe;
|
|
13
|
+
/** The run's resolved resource options and sandbox count, for evaluating a declared `vcpus` rule. */
|
|
14
|
+
readonly vcpuRun: VcpuRun;
|
|
14
15
|
}
|
|
15
16
|
/** The runner, checked on this machine, ready for the runner sandbox. */
|
|
16
17
|
export interface PreparedRunner {
|
|
@@ -19,9 +20,9 @@ export interface PreparedRunner {
|
|
|
19
20
|
/** The run's base, HEAD's merge-base with a base ref, as a full SHA, and that ref. */
|
|
20
21
|
readonly base: string;
|
|
21
22
|
readonly baseRef: string;
|
|
22
|
-
/**
|
|
23
|
-
readonly
|
|
24
|
-
|
|
23
|
+
/** Declared base files read at the base, to stage in `/vercel/sandbox/<path>` before toolchain steps. */
|
|
24
|
+
readonly baseFiles: readonly DeclaredBaseFile[];
|
|
25
|
+
/** The recipe's snapshot key at the base. */
|
|
25
26
|
readonly snapshotKey: string;
|
|
26
27
|
/** The runner sandbox's vCPUs for the run. */
|
|
27
28
|
readonly vcpus: number;
|
|
@@ -45,8 +46,8 @@ export interface PreparedRunner {
|
|
|
45
46
|
* - `ok`: the checks passed, so the runner can ready the runner sandbox.
|
|
46
47
|
* - `no-base-ref`: no ref in `baseRefs` exists locally and shares history with HEAD; `refs` says why for each.
|
|
47
48
|
* - `submodules`: the checkout has Git submodules, at `paths`.
|
|
48
|
-
* - `invalid-recipe`: a
|
|
49
|
-
*
|
|
49
|
+
* - `invalid-recipe`: a declared base file couldn't be read at the run's base or a `vcpus` rule's resource option
|
|
50
|
+
* wasn't a non-negative number for the run; `path` is the key inside the recipe.
|
|
50
51
|
* - `checkout-failed`: git or tar failed, such as outside a Git checkout.
|
|
51
52
|
*/
|
|
52
53
|
export type PrepareRunnerOutcome = {
|
|
@@ -67,10 +68,10 @@ export type PrepareRunnerOutcome = {
|
|
|
67
68
|
readonly failure: CheckoutFailure;
|
|
68
69
|
};
|
|
69
70
|
/**
|
|
70
|
-
* Runs the local checks in order: the repository's root, the base, the submodule refusal, the snapshot
|
|
71
|
+
* Runs the local checks in order: the repository's root, the base, the submodule refusal, the snapshot inputs at
|
|
71
72
|
* the base and their key, the runner's vCPUs, the upload, HEAD's count of commits after the base, and the cache read,
|
|
72
73
|
* which removes expired entries' files (`removeExpiredEntries`) and classifies the rest (`classifySnapshotEntries`)
|
|
73
|
-
* against the merge-base and its snapshot key. So every git call and
|
|
74
|
-
* is minted. It never mints, acquires or creates.
|
|
74
|
+
* against the merge-base and its snapshot key. So every git call and declared base-file read happens here, before
|
|
75
|
+
* anything is minted. It never mints, acquires, or creates.
|
|
75
76
|
*/
|
|
76
|
-
export declare function prepareRunner
|
|
77
|
+
export declare function prepareRunner(context: RunnerPrepareContext, request: PrepareRunnerRequest): Promise<PrepareRunnerOutcome>;
|
package/dist/runner/prepare.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
import { resolveBase } from "./base.js";
|
|
5
5
|
import { resolveVcpus } from "./recipe.js";
|
|
6
6
|
import { classifySnapshotEntries, removeExpiredEntries, } from "./snapshot-cache.js";
|
|
7
|
-
import {
|
|
7
|
+
import { snapshotInputsAt } from "./snapshot-key.js";
|
|
8
8
|
/**
|
|
9
|
-
* Runs the local checks in order: the repository's root, the base, the submodule refusal, the snapshot
|
|
9
|
+
* Runs the local checks in order: the repository's root, the base, the submodule refusal, the snapshot inputs at
|
|
10
10
|
* the base and their key, the runner's vCPUs, the upload, HEAD's count of commits after the base, and the cache read,
|
|
11
11
|
* which removes expired entries' files (`removeExpiredEntries`) and classifies the rest (`classifySnapshotEntries`)
|
|
12
|
-
* against the merge-base and its snapshot key. So every git call and
|
|
13
|
-
* is minted. It never mints, acquires or creates.
|
|
12
|
+
* against the merge-base and its snapshot key. So every git call and declared base-file read happens here, before
|
|
13
|
+
* anything is minted. It never mints, acquires, or creates.
|
|
14
14
|
*/
|
|
15
15
|
export async function prepareRunner(context, request) {
|
|
16
16
|
const { checkout } = context;
|
|
@@ -30,10 +30,10 @@ export async function prepareRunner(context, request) {
|
|
|
30
30
|
return { kind: "checkout-failed", failure: submodules.failure };
|
|
31
31
|
if (submodules.value.length > 0)
|
|
32
32
|
return { kind: "submodules", paths: [...submodules.value] };
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
35
|
-
return { kind: "invalid-recipe", path:
|
|
36
|
-
const vcpus = resolveVcpus(recipe, request.
|
|
33
|
+
const inputs = await snapshotInputsAt(checkout, { repoRoot, base, recipe });
|
|
34
|
+
if (!inputs.ok)
|
|
35
|
+
return { kind: "invalid-recipe", path: inputs.path, problem: inputs.problem };
|
|
36
|
+
const vcpus = resolveVcpus(recipe, request.vcpuRun);
|
|
37
37
|
if (!vcpus.ok)
|
|
38
38
|
return { kind: "invalid-recipe", path: ["vcpus"], problem: vcpus.problem };
|
|
39
39
|
const upload = await checkout.assembleUpload({ repoRoot, base });
|
|
@@ -47,7 +47,7 @@ export async function prepareRunner(context, request) {
|
|
|
47
47
|
entries: listing.entries,
|
|
48
48
|
recipe,
|
|
49
49
|
base,
|
|
50
|
-
snapshotKey:
|
|
50
|
+
snapshotKey: inputs.key,
|
|
51
51
|
commitsAfterBase: afterBase.value,
|
|
52
52
|
});
|
|
53
53
|
return {
|
|
@@ -57,9 +57,8 @@ export async function prepareRunner(context, request) {
|
|
|
57
57
|
repoRoot,
|
|
58
58
|
base,
|
|
59
59
|
baseRef: resolved.ref,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
snapshotKey: steps.key,
|
|
60
|
+
baseFiles: inputs.baseFiles,
|
|
61
|
+
snapshotKey: inputs.key,
|
|
63
62
|
vcpus: vcpus.vcpus,
|
|
64
63
|
upload: upload.value,
|
|
65
64
|
candidates: cache.candidates,
|
package/dist/runner/recipe.d.ts
CHANGED
|
@@ -6,21 +6,32 @@ export interface RunnerStep {
|
|
|
6
6
|
readonly label: string;
|
|
7
7
|
readonly script: string;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
/**
|
|
10
|
+
* A toolchain step in `snapshot.toolchains`: a step that runs before the base's files are committed in the build
|
|
11
|
+
* sandbox, with optional `baseFiles` — repository-relative paths that storm reads at the base, places in
|
|
12
|
+
* `/vercel/sandbox/<path>` before the first toolchain step runs, and hashes into the snapshot key.
|
|
13
|
+
*/
|
|
14
|
+
export interface ToolchainStep extends RunnerStep {
|
|
15
|
+
readonly baseFiles?: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A declared scaling rule for `runner.vcpus`: reads numeric option `option` from resource `resource` (by its resource
|
|
19
|
+
* key), divides it across the run's runner sandboxes (`Math.ceil(value / run.sandboxes)`), multiplies by `per`, and
|
|
20
|
+
* clamps the result between `min` and `max`. When the resource is absent from the run, `min` is used.
|
|
21
|
+
*/
|
|
22
|
+
export interface RunnerVcpuRule {
|
|
23
|
+
readonly resource: string;
|
|
24
|
+
readonly option: string;
|
|
25
|
+
readonly per: number;
|
|
26
|
+
readonly min: number;
|
|
27
|
+
readonly max: number;
|
|
15
28
|
}
|
|
16
|
-
/**
|
|
17
|
-
export type
|
|
29
|
+
/** `runner.vcpus`: a positive whole number of vCPUs, or a declared resource-scaling rule (`RunnerVcpuRule`). */
|
|
30
|
+
export type RunnerVcpuCount = number | RunnerVcpuRule;
|
|
18
31
|
/**
|
|
19
|
-
* What a repository declares about its runner snapshot and what each run does on top of it.
|
|
20
|
-
* function is called with, which the module that calls it declares (`config`'s `RecipeRun`); the default, `never`,
|
|
21
|
-
* takes a recipe whatever its `vcpus` function takes, for code that never calls it.
|
|
32
|
+
* What a repository declares about its runner snapshot and what each run does on top of it.
|
|
22
33
|
*/
|
|
23
|
-
export interface RunnerRecipe
|
|
34
|
+
export interface RunnerRecipe {
|
|
24
35
|
/** Lowercase letters, digits and dashes. Names the recipe's sandboxes (`storm-runner-<name>`) and cache entries. */
|
|
25
36
|
readonly name: string;
|
|
26
37
|
readonly snapshot: {
|
|
@@ -29,12 +40,12 @@ export interface RunnerRecipe<Run = never> {
|
|
|
29
40
|
/** A few words on what a snapshot build does; by default the steps' labels. */
|
|
30
41
|
readonly summary?: string;
|
|
31
42
|
/** Steps run before the base's files are committed in the build sandbox. They must put `git` on `PATH`. */
|
|
32
|
-
readonly toolchains:
|
|
43
|
+
readonly toolchains: readonly ToolchainStep[];
|
|
33
44
|
/**
|
|
34
45
|
* Steps run after the base's files are committed, such as a frozen install and a full build, saved in the runner
|
|
35
46
|
* snapshot so each run's install and build have little left to do.
|
|
36
47
|
*/
|
|
37
|
-
readonly prebuild:
|
|
48
|
+
readonly prebuild: readonly RunnerStep[];
|
|
38
49
|
};
|
|
39
50
|
readonly run: {
|
|
40
51
|
/** Installs dependencies on every run. */
|
|
@@ -44,8 +55,8 @@ export interface RunnerRecipe<Run = never> {
|
|
|
44
55
|
};
|
|
45
56
|
/** The command's directory, relative to the repository's root, without `..`; `"."` by default. */
|
|
46
57
|
readonly cwd?: string;
|
|
47
|
-
/** The runner sandbox's vCPUs, or a
|
|
48
|
-
readonly vcpus:
|
|
58
|
+
/** The runner sandbox's vCPUs: a positive whole number, or a declared resource-scaling rule (`RunnerVcpuRule`). */
|
|
59
|
+
readonly vcpus: RunnerVcpuCount;
|
|
49
60
|
/**
|
|
50
61
|
* Extra environment variables for the command. It can't set `STORM_RUN`. When it sets neither `FORCE_COLOR` nor
|
|
51
62
|
* `NO_COLOR`, storm sets `FORCE_COLOR=1` when the local terminal asks for color (a TTY or `FORCE_COLOR`),
|
|
@@ -123,28 +134,30 @@ export interface RunnerSandboxCount {
|
|
|
123
134
|
readonly max: number;
|
|
124
135
|
/**
|
|
125
136
|
* The number of runner sandboxes of a run with a runner and no `--sandboxes` or `--file-lists`, of a run command that
|
|
126
|
-
* makes file lists, such as `storm
|
|
127
|
-
*
|
|
128
|
-
* line says so. With it, every run of such a command with a runner
|
|
129
|
-
* runner sandbox. `storm exec` and a run with no runner ignore it.
|
|
130
|
-
* with `--sandboxes` or `--file-lists`.
|
|
137
|
+
* makes file lists, such as `storm test`: a whole number from 1 to 32, or a declared rule
|
|
138
|
+
* (`SandboxCountDefaultRule`) giving how many test files go to each runner sandbox with an optional limit. A number
|
|
139
|
+
* above `max` is lowered to it, and the run's plan line says so. With it, every run of such a command with a runner
|
|
140
|
+
* is a run across runner sandboxes, also with one runner sandbox. `storm exec` and a run with no runner ignore it.
|
|
141
|
+
* Without it, a run is across runner sandboxes only with `--sandboxes` or `--file-lists`.
|
|
131
142
|
*/
|
|
132
143
|
readonly default?: SandboxCountDefault;
|
|
133
144
|
}
|
|
134
145
|
/**
|
|
135
|
-
* `runner.sandboxes.default`:
|
|
136
|
-
*
|
|
146
|
+
* A declared rule for `runner.sandboxes.default`: assigns one runner sandbox per `filesPerSandbox` test files
|
|
147
|
+
* (`Math.max(1, Math.min(max, Math.ceil(testPlan.files / filesPerSandbox)))`), or `1` when the test plan counted
|
|
148
|
+
* nothing.
|
|
137
149
|
*/
|
|
138
|
-
export
|
|
150
|
+
export interface SandboxCountDefaultRule {
|
|
151
|
+
/** Positive whole number of test files per runner sandbox. */
|
|
152
|
+
readonly filesPerSandbox: number;
|
|
153
|
+
/** Optional ceiling on the default sandbox count, from 1 to `MAX_RUNNER_SANDBOXES`. */
|
|
154
|
+
readonly max?: number;
|
|
155
|
+
}
|
|
139
156
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* config file, so its test plan is `counted`, with `files`, the number of test files, and `tests` when the run counted
|
|
143
|
-
* each test too. storm calls the function once for the run, before it mints, acquires, or starts anything.
|
|
157
|
+
* `runner.sandboxes.default`: a whole number of runner sandboxes, or a declared rule (`SandboxCountDefaultRule`), such
|
|
158
|
+
* as `{ filesPerSandbox: 50, max: 4 }`.
|
|
144
159
|
*/
|
|
145
|
-
export
|
|
146
|
-
readonly testPlan: RunTestPlan;
|
|
147
|
-
}
|
|
160
|
+
export type SandboxCountDefault = number | SandboxCountDefaultRule;
|
|
148
161
|
/**
|
|
149
162
|
* storm's own limit on the number of runner sandboxes, which `runner.sandboxes.max` can't pass: a guard against a
|
|
150
163
|
* typing mistake that would start hundreds of runner sandboxes, not a claim about what Vercel Sandbox holds.
|
|
@@ -159,7 +172,7 @@ export declare const RECIPE_DEFAULTS: {
|
|
|
159
172
|
readonly runtime: "node22";
|
|
160
173
|
};
|
|
161
174
|
/** A recipe that passed `checkRecipe`, with every optional key's default filled in. */
|
|
162
|
-
export interface CheckedRecipe
|
|
175
|
+
export interface CheckedRecipe extends RunnerRecipe {
|
|
163
176
|
readonly run: {
|
|
164
177
|
readonly install: RunnerStep;
|
|
165
178
|
readonly build: RunnerStep;
|
|
@@ -193,43 +206,36 @@ export interface RecipeProblem {
|
|
|
193
206
|
readonly path: readonly string[];
|
|
194
207
|
readonly problem: string;
|
|
195
208
|
}
|
|
196
|
-
export type RecipeCheck
|
|
209
|
+
export type RecipeCheck = {
|
|
197
210
|
readonly ok: true;
|
|
198
|
-
readonly value: CheckedRecipe
|
|
211
|
+
readonly value: CheckedRecipe;
|
|
199
212
|
} | {
|
|
200
213
|
readonly ok: false;
|
|
201
214
|
readonly problems: readonly RecipeProblem[];
|
|
202
215
|
};
|
|
203
216
|
/**
|
|
204
|
-
* Checks a recipe against its static rules: the keys it may hold and each value's shape.
|
|
205
|
-
*
|
|
206
|
-
* return. Every problem is reported.
|
|
217
|
+
* Checks a recipe against its static rules: the keys it may hold and each value's shape. Every value must be plain
|
|
218
|
+
* data; functions are refused with the declared form to use instead. Every problem is reported.
|
|
207
219
|
*/
|
|
208
|
-
export declare function checkRecipe
|
|
209
|
-
/**
|
|
210
|
-
|
|
211
|
-
* function that throws or rejects, or returns anything but a list of steps, is a problem worded to follow the key.
|
|
212
|
-
*/
|
|
213
|
-
export declare function resolveSteps(steps: RunnerStepList, context: RunnerStepContext): Promise<{
|
|
214
|
-
readonly ok: true;
|
|
215
|
-
readonly steps: readonly RunnerStep[];
|
|
216
|
-
} | {
|
|
217
|
-
readonly ok: false;
|
|
218
|
-
readonly problem: string;
|
|
219
|
-
}>;
|
|
220
|
+
export declare function checkRecipe(value: unknown): RecipeCheck;
|
|
221
|
+
/** The sorted, unique repository-relative base file paths declared across `toolchains`. */
|
|
222
|
+
export declare function declaredBaseFilePaths(toolchains: readonly ToolchainStep[]): readonly string[];
|
|
220
223
|
/**
|
|
221
|
-
* What
|
|
222
|
-
*
|
|
224
|
+
* What `resolveVcpus` reads about a run: each present resource's resolved options by resource key, and the run's
|
|
225
|
+
* number of runner sandboxes.
|
|
223
226
|
*/
|
|
224
|
-
export interface
|
|
225
|
-
readonly
|
|
226
|
-
|
|
227
|
+
export interface VcpuRun {
|
|
228
|
+
readonly resources: {
|
|
229
|
+
readonly [key: string]: Readonly<Record<string, unknown>>;
|
|
230
|
+
};
|
|
231
|
+
readonly sandboxes: number;
|
|
227
232
|
}
|
|
228
233
|
/**
|
|
229
|
-
* The runner sandbox's vCPUs for `run`: the recipe's number, or
|
|
230
|
-
*
|
|
234
|
+
* The runner sandbox's vCPUs for `run`: the recipe's number, or the declared resource-scaling rule evaluated against
|
|
235
|
+
* `run.resources` and `run.sandboxes`. When the named resource is absent from the run, `min` is used. When the named
|
|
236
|
+
* resource is present and its named option is missing or not a non-negative finite number, returns a problem.
|
|
231
237
|
*/
|
|
232
|
-
export declare function resolveVcpus
|
|
238
|
+
export declare function resolveVcpus(recipe: Pick<RunnerRecipe, "vcpus">, run: VcpuRun): {
|
|
233
239
|
readonly ok: true;
|
|
234
240
|
readonly vcpus: number;
|
|
235
241
|
} | {
|
|
@@ -238,14 +244,7 @@ export declare function resolveVcpus<Run>(recipe: Pick<RunnerRecipe<Run>, "vcpus
|
|
|
238
244
|
};
|
|
239
245
|
/**
|
|
240
246
|
* The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the recipe's number,
|
|
241
|
-
* or
|
|
242
|
-
* a problem here: the run lowers it to `max` and says so.
|
|
243
|
-
* problem worded to follow the key, which names the test plan.
|
|
247
|
+
* or the declared `{ filesPerSandbox, max? }` rule evaluated against `testPlan`. A number above `sandboxes.max` is not
|
|
248
|
+
* a problem here: the run lowers it to `sandboxes.max` and says so.
|
|
244
249
|
*/
|
|
245
|
-
export declare function resolveSandboxCountDefault(sandboxesDefault: SandboxCountDefault, testPlan: RunTestPlan):
|
|
246
|
-
readonly ok: true;
|
|
247
|
-
readonly sandboxes: number;
|
|
248
|
-
} | {
|
|
249
|
-
readonly ok: false;
|
|
250
|
-
readonly problem: string;
|
|
251
|
-
};
|
|
250
|
+
export declare function resolveSandboxCountDefault(sandboxesDefault: SandboxCountDefault, testPlan: RunTestPlan): number;
|