@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
|
@@ -1,604 +0,0 @@
|
|
|
1
|
-
// What `storm test` and `storm exec` share: the request fields and flag checks every run takes, planning a run
|
|
2
|
-
// (`planCommandRun`) from the effective config, and running a planned run that is not across runner sandboxes once its
|
|
3
|
-
// resources' `beforeRun` let it go on (`runPlannedCommand`). The commands differ only in their part of planning the
|
|
4
|
-
// run (`PlanCommand`, `plan-run.ts`): `storm exec` runs the command after `--` directly, and `storm test` plans
|
|
5
|
-
// through `planDriverCommand` with the driver named in `storm.config.ts`. `run-planned.ts` does what the request asks
|
|
6
|
-
// of a planned run: this file's run, a run across runner sandboxes (`across-sandboxes-run.ts`), or only the planned run
|
|
7
|
-
// (`plan-only.ts`).
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
import { forwardSigterm } from "../../forward-sigterm.js";
|
|
10
|
-
import { describeMintFailure } from "../../credential/index.js";
|
|
11
|
-
import { prepareRunner, } from "../../runner/index.js";
|
|
12
|
-
import { invalidConfig, recipeRun } from "../../config/index.js";
|
|
13
|
-
import { commandExitStatus, executeRun, timedProgress, } from "../../core/index.js";
|
|
14
|
-
import { DEFINITION_SET } from "../../extensions.js";
|
|
15
|
-
import { recordRun, } from "../../run-directory/index.js";
|
|
16
|
-
import { parseKeepTime } from "../../time/index.js";
|
|
17
|
-
import { lacksFinalResults } from "../../planning/final-results.js";
|
|
18
|
-
import { redactingObserver, redactingTerminal, redactor, redactStrings, } from "../../planning/redaction.js";
|
|
19
|
-
import { resourceFlagFields, resourceFlagProblems, resourceFlagValues } from "../../planning/resource-flags.js";
|
|
20
|
-
import { recordedPlan, testPlanLine } from "../../planning/test-plan.js";
|
|
21
|
-
import { keptText, RUN_CLEANUP, notDeletedText, notKeptText, notStoppedText, } from "../../shared/cleanup.js";
|
|
22
|
-
import { jobSummaryMarkdown } from "../../shared/job-summary.js";
|
|
23
|
-
import { testsSummaryLines } from "../../shared/tests-summary.js";
|
|
24
|
-
import { waterfallLines } from "../../shared/waterfall.js";
|
|
25
|
-
import { hasPoorParallelism, testsChart } from "../../shared/worker-chart.js";
|
|
26
|
-
import { mintFailedErrors } from "./mint-failed.js";
|
|
27
|
-
import { outcomes, runErrors } from "./outcomes.js";
|
|
28
|
-
import { canceledBeforeStart, planRun, resourcesBeforeRun, } from "./plan-run.js";
|
|
29
|
-
import { resourceRefused } from "./resource-refusals.js";
|
|
30
|
-
import { runView } from "./view.js";
|
|
31
|
-
/** The run's own request fields, which every run takes beside the resources' flags. */
|
|
32
|
-
const OWN_RUN_FIELDS = {
|
|
33
|
-
scope: z.string().min(1).optional(),
|
|
34
|
-
project: z.string().min(1).optional(),
|
|
35
|
-
credential: z.enum(["mint", "github-actions"]).optional(),
|
|
36
|
-
showOutput: z.boolean().default(false),
|
|
37
|
-
keepSandbox: z.string().optional(),
|
|
38
|
-
verbose: z.boolean().default(false),
|
|
39
|
-
planOnly: z.boolean().default(false),
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* The request fields every run takes, `storm test`'s and `storm exec`'s: the run's own, and each resource option's
|
|
43
|
-
* flag (`resource-flags.ts`). Each command adds its own fields (`--runner` on `exec`, `--suite` and `--count-tests`
|
|
44
|
-
* on `test`).
|
|
45
|
-
*/
|
|
46
|
-
export const RUN_REQUEST_FIELDS = { ...OWN_RUN_FIELDS, ...resourceFlagFields(Object.keys(OWN_RUN_FIELDS)) };
|
|
47
|
-
/** The CLI spellings of the fields every run takes. */
|
|
48
|
-
export const RUN_CLI_OPTIONS = { project: { short: "p" } };
|
|
49
|
-
const runRequestSchema = z.object(RUN_REQUEST_FIELDS);
|
|
50
|
-
/**
|
|
51
|
-
* What a planned run does before it starts, across runner sandboxes or not: calls each resource's `beforeRun`
|
|
52
|
-
* (`resourcesBeforeRun`), cancels on a signal by then, and says the run's test plan (`plan`) when it has one.
|
|
53
|
-
*/
|
|
54
|
-
export async function beforeRunStarts({ ui, signal }, lifecycles, planned, request, plan) {
|
|
55
|
-
const before = await resourcesBeforeRun(lifecycles, planned, request);
|
|
56
|
-
if (!before.ok)
|
|
57
|
-
return before;
|
|
58
|
-
if (signal.aborted)
|
|
59
|
-
return { ok: false, refusal: canceledBeforeStart() };
|
|
60
|
-
if (plan !== undefined)
|
|
61
|
-
await ui.progress?.(testPlanLine(plan));
|
|
62
|
-
return before;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Prepares a planned run that is not across runner sandboxes for execution: what every run does before it starts
|
|
66
|
-
* (`beforeRunStarts`), then the run's request, from where it runs, the shared secret redactor, and the checkout's git
|
|
67
|
-
* state. Both kinds of run take the same requests. A run with no runner carries the credential choice it made, if any,
|
|
68
|
-
* whose source the core builds; a run with a runner carries the runner's part (`runnerRequestFor`), and its resources
|
|
69
|
-
* share its one mint.
|
|
70
|
-
*/
|
|
71
|
-
export async function prepareRunSession(context, lifecycles, planned, request) {
|
|
72
|
-
const { app } = context;
|
|
73
|
-
const { configFile, argv, testPlan, planOptions } = planned;
|
|
74
|
-
const plan = recordedPlan(testPlan, planOptions);
|
|
75
|
-
const before = await beforeRunStarts(context, lifecycles, planned, request, plan);
|
|
76
|
-
if (!before.ok)
|
|
77
|
-
return before;
|
|
78
|
-
const { where, used } = before;
|
|
79
|
-
const base = {
|
|
80
|
-
argv,
|
|
81
|
-
env: Object.fromEntries(Object.entries(app.env).filter(([name]) => !used.hiddenVariables.includes(name))),
|
|
82
|
-
version: app.version,
|
|
83
|
-
commit: app.commit,
|
|
84
|
-
configFile,
|
|
85
|
-
verbose: request.verbose,
|
|
86
|
-
resources: used.requests,
|
|
87
|
-
skipped: used.skipped,
|
|
88
|
-
};
|
|
89
|
-
let run;
|
|
90
|
-
if (where.kind === "runner") {
|
|
91
|
-
const keepMs = keepSandboxMinutes(request.keepSandbox, where.recipe) * 60_000;
|
|
92
|
-
const requested = await runnerRequestFor(app, where, used, { configFile, sandboxes: 1, keepMs });
|
|
93
|
-
if (!requested.ok)
|
|
94
|
-
return requested;
|
|
95
|
-
run = { ...base, runner: requested.runner };
|
|
96
|
-
}
|
|
97
|
-
else
|
|
98
|
-
run = { ...base, ...(where.credential === undefined ? {} : { credential: where.credential }) };
|
|
99
|
-
// The resources' secrets, the credentials' values, and any unsafe secret environment variables' values: every event
|
|
100
|
-
// and the command's output pass through `redact` before any view, the run directory, or the summary sees them.
|
|
101
|
-
const secrets = [...used.secrets, ...(where.kind === "runner" ? where.secrets : [])];
|
|
102
|
-
const git = await checkoutGit(app.context.checkout, app.cwd);
|
|
103
|
-
return { ok: true, plan, run, secrets, redact: redactor(secrets), git };
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Executes a run inside the shared lifecycle guard: redacts the returned outcome when the run carries secrets, and
|
|
107
|
-
* ensures the view finishes and the recording is abandoned if execution throws.
|
|
108
|
-
*/
|
|
109
|
-
export async function runLifecycle(options) {
|
|
110
|
-
try {
|
|
111
|
-
const ended = await options.execute();
|
|
112
|
-
// An outcome's facts, such as a failed Sandbox call's message, can quote what the run handed its command.
|
|
113
|
-
return options.hasSecrets ? redactStrings(ended, options.redact) : ended;
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
// A live region must not outlive the run, however it ends, and abandoning the recording completes the run
|
|
117
|
-
// directory and removes the test events an unsandboxed command staged there, unredacted. They are never saved: the
|
|
118
|
-
// run didn't end.
|
|
119
|
-
await options.finishView();
|
|
120
|
-
await options.abandonRecording();
|
|
121
|
-
throw error;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/** Maps a stopped run outcome to its Clinkr error outcome, including cleanup and cancellation facts. */
|
|
125
|
-
export function mapStoppedOutcome(outcome, canceledOptions) {
|
|
126
|
-
switch (outcome.kind) {
|
|
127
|
-
case "resource_refused":
|
|
128
|
-
return resourceRefused(outcome, RUN_CLEANUP.facts(outcome));
|
|
129
|
-
case "mint_failed":
|
|
130
|
-
return mintFailedErrors.mintFailed({
|
|
131
|
-
...outcome.target,
|
|
132
|
-
...describeMintFailure(outcome.failure, outcome.target),
|
|
133
|
-
runner: outcome.runner,
|
|
134
|
-
cleanup: RUN_CLEANUP.facts(outcome),
|
|
135
|
-
});
|
|
136
|
-
case "spawn_failed":
|
|
137
|
-
return runErrors.spawnFailed({
|
|
138
|
-
executable: outcome.executable,
|
|
139
|
-
message: outcome.message,
|
|
140
|
-
cleanup: RUN_CLEANUP.facts({ runnerCleanup: null, resourceCleanup: outcome.resourceCleanup }),
|
|
141
|
-
});
|
|
142
|
-
case "canceled":
|
|
143
|
-
return outcomes.canceled({ changed: canceledChanges(outcome, canceledOptions) });
|
|
144
|
-
case "runner_failed":
|
|
145
|
-
return runErrors.runnerFailed({
|
|
146
|
-
failure: runnerFailureFacts(outcome.failure),
|
|
147
|
-
cleanup: RUN_CLEANUP.facts(outcome),
|
|
148
|
-
});
|
|
149
|
-
case "snapshot_gone":
|
|
150
|
-
return runErrors.snapshotGone({
|
|
151
|
-
snapshotId: outcome.entry.snapshotId,
|
|
152
|
-
base: outcome.entry.base,
|
|
153
|
-
removal: outcome.removal === undefined ? null : { ...outcome.removal },
|
|
154
|
-
cleanup: RUN_CLEANUP.facts(outcome),
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Plans a run command's run (`planRun`) from `request`, with the command's part of planning (`planCommand`), over the resources'
|
|
160
|
-
* lifecycles, which it binds: the planned run with those lifecycles, or the refusal that ends the command before
|
|
161
|
-
* anything is minted, acquired or started. Every run command plans through it, a run across runner sandboxes too, whose
|
|
162
|
-
* part of planning also plans the runner sandboxes (`across-sandboxes-run.ts`).
|
|
163
|
-
*/
|
|
164
|
-
export async function planCommandRun(app, request, planCommand, signal) {
|
|
165
|
-
const lifecycles = DEFINITION_SET.lifecycles(app.resourceContexts);
|
|
166
|
-
const planned = await planRun(app, lifecycles, { ...request, given: resourceFlagValues(request) }, planCommand, signal);
|
|
167
|
-
if (!planned.ok)
|
|
168
|
-
return planned;
|
|
169
|
-
return { ok: true, planned, lifecycles };
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Runs a planned run that is not across runner sandboxes: the command, the argv its plan holds (`exec`'s command after
|
|
173
|
-
* `--`, or the `vitest run` argv `vitest` builds), with the run payload in `STORM_RUN` and the launcher environment
|
|
174
|
-
* variables the run's used resources hide removed (`ResourceUse.hiddenVariables`), waits for it, and prints a
|
|
175
|
-
* waterfall. It first acquires each resource the run holds and says what each one acquired, and releases them once the
|
|
176
|
-
* command has stopped. The process exits with the command's code, or `128 + n` when signal `n` ended it: `bin/storm.ts`
|
|
177
|
-
* applies the status this records in `app.exit`, which Clinkr's 0 or 1 can't carry.
|
|
178
|
-
*
|
|
179
|
-
* A run has a resource when `storm.config.ts` has it under `resources` or the command line gives one of its
|
|
180
|
-
* options' own flags, `--<prefix>-<option>`, which the registry's resource definitions declare (`resource-flags.ts`).
|
|
181
|
-
* Without one, the run payload names no resource.
|
|
182
|
-
*
|
|
183
|
-
* Signals: before the command starts, the first signal stops the run at its next step, lets each resource's acquire
|
|
184
|
-
* end, releases what it took, and cancels (exit `128 + n`). A signal while the command's part of planning runs (`PlanCommand`), such as while
|
|
185
|
-
* `vitest` counts the tests, stops it and cancels the run before anything is minted, acquired or started
|
|
186
|
-
* (`canceledBeforeStart`). While the command runs, Ctrl+C and a closed terminal reach it directly through its process
|
|
187
|
-
* group, so only SIGTERM is passed on; either way the run waits for the command. A second signal makes Clinkr's host
|
|
188
|
-
* exit at once with `128 + n`, leaving what the resources took for a later run to recover, since its holder is gone.
|
|
189
|
-
*
|
|
190
|
-
* `scope` and `project` come from `--scope` and `--project`, else `storm.config.ts` (found from the working
|
|
191
|
-
* directory and checked whole); they have no default, so one of the two must give them when the run mints. Each
|
|
192
|
-
* resource's options come from the command line, else the file's section, else the option's default (the registry's
|
|
193
|
-
* resource definitions, `src/extensions.ts`), which may be a function of the planned run, sized from the tests
|
|
194
|
-
* `vitest` counted. On the command line, an option comes only from its own flag; an option with none comes only from
|
|
195
|
-
* the file. A flag value its option's schema refuses is a usage error. Options that don't fit together once merged, as
|
|
196
|
-
* the definition's `check` says, are `invalid_resource_options`, which names each value's source.
|
|
197
|
-
*
|
|
198
|
-
* Where the command runs is declared under `runner` in `storm.config.ts` (`launchMachine()` or `vercelSandbox({ … })`,
|
|
199
|
-
* inherited or overridden by suites); `storm exec` also takes `--runner launch-machine`. Without either, the run
|
|
200
|
-
* refuses with `missing_runner`. When using the Vercel Sandbox runner, the runner's local checks (`prepareRunner`) run
|
|
201
|
-
* before anything is minted, acquired, or created, and the run always mints for the runner sandbox, so it needs `scope`
|
|
202
|
-
* and `project` whatever its resources are. In a runner sandbox, the first SIGINT, SIGTERM, or SIGHUP stops the run in
|
|
203
|
-
* any phase: the command is killed, every sandbox the run started is stopped and deleted, the resources are released,
|
|
204
|
-
* and the run cancels. `storm snapshots build` builds runner snapshots without a run. A run saves no runner snapshot as
|
|
205
|
-
* it ends, and keeps the runner sandbox only for the keep time `--keep-sandbox` or the recipe's `keepSandbox` gives.
|
|
206
|
-
*
|
|
207
|
-
* `--credential` (no config key) picks the credential source: `mint`, the default, or `github-actions`, which requests
|
|
208
|
-
* a GitHub Actions OIDC token instead and so needs no `--scope` or `--project`; any given are unused. The Vercel
|
|
209
|
-
* Sandbox runner needs the mint, so `--credential github-actions` with it is `conflicting_options`. Each resource's
|
|
210
|
-
* `beforeRun` says whether it needs the Vercel credential (`needsVercelCredential`), from its options. A `--credential`
|
|
211
|
-
* given to a run where none does is `credential_unused`.
|
|
212
|
-
*
|
|
213
|
-
* Progress shows by the app's presentation (`presentation.ts`): a live view on a terminal a person watches, plain lines
|
|
214
|
-
* elsewhere, folded for GitHub Actions, nothing under `--json`. `--show-output` (no config key, Vercel Sandbox runner
|
|
215
|
-
* only) prints the runner's step output above the live view. `--verbose` (no config key) prints each resource's
|
|
216
|
-
* detailed progress and the runner's step output, and sets `verbose` in the run payload. Every run, `--json` included,
|
|
217
|
-
* writes a run directory (`recordRun`, `run-directory/`), and a run that can't make one goes on without it; the
|
|
218
|
-
* waterfall names it and the `storm runs show` command that reads the run back by its run id, which a ran outcome
|
|
219
|
-
* carries as `runId`, and in a GitHub Actions step with a job summary the run appends a Markdown summary there.
|
|
220
|
-
*
|
|
221
|
-
* Each resource comes from an extension (the registry, `src/extensions.ts`, lists them), whose folder under
|
|
222
|
-
* `src/extensions/` says what the run does with it. storm first plans the run (`planRun`), then calls each resource's
|
|
223
|
-
* `beforeRun` and chooses the credential source (`resourcesBeforeRun`), and only then mints, acquires, or starts
|
|
224
|
-
* anything or opens the run directory. A `beforeRun` may skip its resource, and the run says so right after it starts.
|
|
225
|
-
* With a test plan (`storm test`), it says the plan on stderr once the resources' `beforeRun` let the run go on, unless
|
|
226
|
-
* under `--json`. The run refuses in this order: `invalid_config`; `missing_runner`; `conflicting_options`; for Vercel
|
|
227
|
-
* Sandbox, `missing_target`, then `credentials_invalid`, then `keep_sandbox_unsafe_secret_env_vars`, then
|
|
228
|
-
* `unsafe_secret_env_vars_invalid`; then `invalid_resource_options` for a required option nothing gives, which no count
|
|
229
|
-
* can change; then `spec.planCommand`'s refusal, if any; `invalid_resource_options` for the checks across a resource's
|
|
230
|
-
* options, which may read a default sized from the count; each resource's `beforeRun` refusal, in registry order
|
|
231
|
-
* (`resource_refused_before_run`), with the config file beside it; `credential_unused`; on the launch machine,
|
|
232
|
-
* `resource_needs_runner_sandbox` when a resource it uses needs a runner sandbox (a resource whose acquire gives the
|
|
233
|
-
* command sandbox credentials, which only the runner sandbox's firewall can add); and on the launch machine where a
|
|
234
|
-
* resource needs the credential, `missing_target` for the mint. A resource's secrets, such as a token, and in a runner
|
|
235
|
-
* sandbox the credentials' and unsafe secret environment variables' values, are hidden as `<token>` in the run's
|
|
236
|
-
* progress, its run directory, its job summary, its outcome, a runner sandbox's preparation refusal
|
|
237
|
-
* (`prepareRunner`'s), its command's output and step output, and `spec.planCommand`'s refusal. That refusal comes
|
|
238
|
-
* before `beforeRun`, which may do I/O, so storm reads the resources' secrets for it from each one's pure `secrets`,
|
|
239
|
-
* over its options merged once, each function default given `NOT_COUNTED` (`settleRunResources`), whether or not the
|
|
240
|
-
* checks across them pass.
|
|
241
|
-
*/
|
|
242
|
-
export async function runPlannedCommand(context, request, spec, planned, lifecycles) {
|
|
243
|
-
const { app, ui, signal } = context;
|
|
244
|
-
const { configFile, argv, testPlan, planOptions } = planned;
|
|
245
|
-
const session = await prepareRunSession(context, lifecycles, planned, request);
|
|
246
|
-
if (!session.ok)
|
|
247
|
-
return session.refusal;
|
|
248
|
-
const { plan, run, secrets, redact, git } = session;
|
|
249
|
-
// Only SIGTERM is passed on to the command (`forwardSigterm`); a run in a runner sandbox stops on any signal itself
|
|
250
|
-
// (`RunControl`).
|
|
251
|
-
const sigterm = forwardSigterm(signal);
|
|
252
|
-
const view = runView({
|
|
253
|
-
presentation: app.presentation,
|
|
254
|
-
progress: ui.progress,
|
|
255
|
-
context: app.context,
|
|
256
|
-
showOutput: request.showOutput,
|
|
257
|
-
verbose: request.verbose,
|
|
258
|
-
});
|
|
259
|
-
const recording = await recordRun(app.context.runDirectories, {
|
|
260
|
-
definitionSet: DEFINITION_SET,
|
|
261
|
-
clock: app.context.clock,
|
|
262
|
-
cwd: app.cwd,
|
|
263
|
-
configFile,
|
|
264
|
-
argv,
|
|
265
|
-
...(spec.test === undefined ? {} : { test: spec.test }),
|
|
266
|
-
plan,
|
|
267
|
-
run,
|
|
268
|
-
git,
|
|
269
|
-
redact: (value) => redactStrings(value, redact),
|
|
270
|
-
});
|
|
271
|
-
// The recording folds each event, hands it to the view, then writes it; its terminal writes `command.log`, then the
|
|
272
|
-
// view's.
|
|
273
|
-
const observer = recording.observer(view.observer);
|
|
274
|
-
const terminal = recording.terminal(view.runnerTerminal);
|
|
275
|
-
// Where the command reports its tests: a runner sandbox's own file, which the runner follows, or the run directory's
|
|
276
|
-
// test events file, which a run with no runner hands its command only once the run directory opened.
|
|
277
|
-
const collected = run.runner !== undefined || recording.testEvents !== undefined;
|
|
278
|
-
const outcome = await runLifecycle({
|
|
279
|
-
execute: async () => await executeRun(DEFINITION_SET, { ...app.context, runnerTerminal: secrets.length === 0 ? terminal : redactingTerminal(terminal, redact) }, app.resourceContexts, run.runner === undefined && recording.testEvents !== undefined
|
|
280
|
-
? { ...run, testEvents: recording.testEvents }
|
|
281
|
-
: run, { signal, terminate: sigterm.terminate }, timedProgress(app.context.clock, secrets.length === 0 ? observer : redactingObserver(observer, redact))),
|
|
282
|
-
redact,
|
|
283
|
-
hasSecrets: secrets.length > 0,
|
|
284
|
-
finishView: async () => await view.finish([]),
|
|
285
|
-
abandonRecording: async () => await recording.abandon(),
|
|
286
|
-
});
|
|
287
|
-
sigterm.release();
|
|
288
|
-
const { timeline: ran, finalResults } = await summarize(app, {
|
|
289
|
-
command: spec.name,
|
|
290
|
-
hints: spec.hints,
|
|
291
|
-
view,
|
|
292
|
-
recording,
|
|
293
|
-
outcome,
|
|
294
|
-
});
|
|
295
|
-
if (outcome.kind !== "ran")
|
|
296
|
-
return mapStoppedOutcome(outcome);
|
|
297
|
-
const { command } = outcome;
|
|
298
|
-
const runId = recording.opened.ok ? recording.opened.id : null;
|
|
299
|
-
app.exit.status = commandExitStatus(outcome.command);
|
|
300
|
-
return spec.ran({
|
|
301
|
-
version: app.version,
|
|
302
|
-
commit: app.commit,
|
|
303
|
-
configFile,
|
|
304
|
-
resources: DEFINITION_SET.reports.ranFacts(outcome.resources),
|
|
305
|
-
cleanup: RUN_CLEANUP.facts(outcome),
|
|
306
|
-
command: command.kind === "exited"
|
|
307
|
-
? { exitCode: command.code, signal: null }
|
|
308
|
-
: command.kind === "signaled"
|
|
309
|
-
? { exitCode: null, signal: command.signal }
|
|
310
|
-
: { exitCode: null, signal: null },
|
|
311
|
-
runner: outcome.runner === undefined
|
|
312
|
-
? null
|
|
313
|
-
: {
|
|
314
|
-
snapshotId: outcome.runner.snapshotId,
|
|
315
|
-
base: outcome.runner.base,
|
|
316
|
-
builtBehind: outcome.runner.builtBehind,
|
|
317
|
-
uploadBytes: outcome.runner.uploadBytes,
|
|
318
|
-
built: outcome.runner.built,
|
|
319
|
-
vcpus: outcome.runner.vcpus,
|
|
320
|
-
region: outcome.runner.region,
|
|
321
|
-
runtime: outcome.runner.runtime,
|
|
322
|
-
buildMs: outcome.runner.buildMs,
|
|
323
|
-
},
|
|
324
|
-
timeline: ran,
|
|
325
|
-
runId,
|
|
326
|
-
}, { testPlan, options: planOptions }, lacksFinalResults(command.kind === "exited" ? command.code : null, {
|
|
327
|
-
...finalResults,
|
|
328
|
-
collected,
|
|
329
|
-
}));
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* What is wrong with `--sandboxes` or `--file-lists` combined with other run flags, whatever the runner, as `validate`
|
|
333
|
-
* reports it. The launch machine runner refuses both flags in `planRun` (`conflicting_options`), once it knows the
|
|
334
|
-
* effective runner.
|
|
335
|
-
*/
|
|
336
|
-
export function sandboxesFlagProblems(request) {
|
|
337
|
-
const flag = request.sandboxes !== undefined ? "--sandboxes" : request.fileLists !== undefined ? "--file-lists" : undefined;
|
|
338
|
-
if (flag === undefined)
|
|
339
|
-
return [];
|
|
340
|
-
return request.showOutput
|
|
341
|
-
? [
|
|
342
|
-
{
|
|
343
|
-
field: "showOutput",
|
|
344
|
-
message: `A run with ${flag} prints status lines and no step output, and each runner sandbox entry of its run directory keeps its step logs; drop --show-output.`,
|
|
345
|
-
},
|
|
346
|
-
]
|
|
347
|
-
: [];
|
|
348
|
-
}
|
|
349
|
-
/** Flag checks that hold regardless of which runner the run uses (`validate`). */
|
|
350
|
-
export function runFlagProblems(request) {
|
|
351
|
-
const { keepSandbox } = request;
|
|
352
|
-
return [
|
|
353
|
-
...resourceFlagProblems(request),
|
|
354
|
-
...(keepSandbox !== undefined && parseKeepTime(keepSandbox) === undefined
|
|
355
|
-
? [
|
|
356
|
-
{
|
|
357
|
-
field: "keepSandbox",
|
|
358
|
-
message: `--keep-sandbox takes 0, or a whole number of minutes or hours up to 5h, such as 30m or 2h, not ${JSON.stringify(keepSandbox)}.`,
|
|
359
|
-
},
|
|
360
|
-
]
|
|
361
|
-
: []),
|
|
362
|
-
];
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* The runner's part of the request of a run with a runner, which starts `sandboxes` runner sandboxes, each kept running
|
|
366
|
-
* for `keepMs` once the run ends. The runner's local checks run here (`prepareRunner`), before anything is minted,
|
|
367
|
-
* acquired or started. Their refusal ends the command and leaves no run directory; it can quote what preparation ran
|
|
368
|
-
* with this machine's environment, such as what a recipe's step function or `vcpus` function threw, so it shows the
|
|
369
|
-
* resources' secrets and the runner secrets' values as `<token>`.
|
|
370
|
-
*/
|
|
371
|
-
export async function runnerRequestFor(app, where, used, options) {
|
|
372
|
-
const prepared = await prepareRunner(app.context, {
|
|
373
|
-
cwd: app.cwd,
|
|
374
|
-
recipe: where.recipe,
|
|
375
|
-
vcpusRun: recipeRun(recipeResources(used.requests), options.sandboxes),
|
|
376
|
-
});
|
|
377
|
-
if (prepared.kind !== "ok") {
|
|
378
|
-
const refusal = prepareRefusal(prepared, options.configFile);
|
|
379
|
-
const secrets = [...used.secrets, ...where.secrets];
|
|
380
|
-
return {
|
|
381
|
-
ok: false,
|
|
382
|
-
refusal: secrets.length === 0 ? refusal : redactStrings(refusal, redactor(secrets)),
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
const runner = {
|
|
386
|
-
prepared: prepared.prepared,
|
|
387
|
-
target: where.target,
|
|
388
|
-
user: app.user,
|
|
389
|
-
credentials: where.credentials,
|
|
390
|
-
...(Object.keys(where.unsafeSecretEnvVars).length === 0 ? {} : { unsafeSecretEnvVars: where.unsafeSecretEnvVars }),
|
|
391
|
-
keepMs: options.keepMs,
|
|
392
|
-
};
|
|
393
|
-
return { ok: true, runner };
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* The refusal for a runner whose local checks failed: no base, submodules, a recipe storm can't use at the run's
|
|
397
|
-
* base or for its sandbox count (`invalid_config`, naming the key inside `runner`), or git or tar failing.
|
|
398
|
-
*/
|
|
399
|
-
export function prepareRefusal(prepared, configFile) {
|
|
400
|
-
switch (prepared.kind) {
|
|
401
|
-
case "no-base-ref":
|
|
402
|
-
return runErrors.noBaseRef({ refs: prepared.refs.map(({ ref, reason }) => ({ ref, reason })) });
|
|
403
|
-
case "submodules":
|
|
404
|
-
return runErrors.submodulesRefused({ paths: [...prepared.paths] });
|
|
405
|
-
case "invalid-recipe":
|
|
406
|
-
return invalidConfig(configFile ?? "", [
|
|
407
|
-
{ key: ["runner", ...prepared.path].join("."), location: null, problem: prepared.problem },
|
|
408
|
-
]);
|
|
409
|
-
case "checkout-failed":
|
|
410
|
-
return checkoutFailedRefusal(prepared.failure);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* The refusal for a sandboxed run whose checkout git couldn't read before anything was minted, acquired or started:
|
|
415
|
-
* `runner_failed` with `checkout-failed`, holding nothing.
|
|
416
|
-
*/
|
|
417
|
-
export function checkoutFailedRefusal(failure) {
|
|
418
|
-
return runErrors.runnerFailed({
|
|
419
|
-
failure: runnerFailureFacts({ kind: "checkout-failed", failure }),
|
|
420
|
-
cleanup: RUN_CLEANUP.facts(NOTHING_RELEASED),
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Once the run is done: ends its recording, which writes how the run ended to the run directory and closes it
|
|
425
|
-
* (`RunRecording.end`). Then it appends the job summary, and has the view print the waterfall, with the worker chart
|
|
426
|
-
* under its command row, the tests' summary, the logs of failed steps, and what went wrong with the run directory. The
|
|
427
|
-
* job summary leaves the worker chart out. It answers the timeline, which a ran outcome carries, and how many final
|
|
428
|
-
* test results the run's test events held (`FinalResultsRead`).
|
|
429
|
-
*/
|
|
430
|
-
async function summarize(app, run) {
|
|
431
|
-
const { view, recording } = run;
|
|
432
|
-
const recorded = await recording.end(run.outcome);
|
|
433
|
-
const { timeline, tests } = recorded;
|
|
434
|
-
const logs = recording.opened.ok ? recording.opened.path : undefined;
|
|
435
|
-
const failed = tests.events.some((event) => event.kind === "test-result" && event.state === "fail");
|
|
436
|
-
const testsLines = testsSummaryLines(tests.events, run.hints, tests.unreadable, tests.incomplete);
|
|
437
|
-
const stepLogs = failedStepLogs(timeline, recording, app.env);
|
|
438
|
-
const clock = workerClock(recorded);
|
|
439
|
-
const charted = clock === undefined ? undefined : testsChart(tests.events, run.hints, tests.unreadable, clock, tests.incomplete);
|
|
440
|
-
const workersHint = charted !== undefined && hasPoorParallelism(charted.parallelism);
|
|
441
|
-
const summarized = await app.context.jobSummary.appendJobSummary(jobSummaryMarkdown(timeline, {
|
|
442
|
-
command: run.command,
|
|
443
|
-
logs,
|
|
444
|
-
details: [...testsLines, ...stepLogs],
|
|
445
|
-
}));
|
|
446
|
-
await view.finish(waterfallLines(timeline, {
|
|
447
|
-
width: view.width,
|
|
448
|
-
colorDepth: view.colorDepth,
|
|
449
|
-
logs: logsText(recording, recorded.writeFailure, app.env, failed, workersHint),
|
|
450
|
-
...(charted === undefined ? {} : { workers: charted.lanes }),
|
|
451
|
-
details: [
|
|
452
|
-
...(charted?.notes ?? testsLines),
|
|
453
|
-
...stepLogs,
|
|
454
|
-
...(summarized.kind === "failed"
|
|
455
|
-
? [` couldn't append to the job summary at ${summarized.failure.path}: ${summarized.failure.message}`]
|
|
456
|
-
: []),
|
|
457
|
-
],
|
|
458
|
-
}));
|
|
459
|
-
return {
|
|
460
|
-
timeline,
|
|
461
|
-
finalResults: {
|
|
462
|
-
finalResults: tests.events.filter((event) => event.kind === "test-result").length,
|
|
463
|
-
partial: tests.unreadable > 0 || tests.incomplete !== undefined,
|
|
464
|
-
},
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* How the workers' clock maps to the run's, for the worker chart under the command row; undefined without one. The
|
|
469
|
-
* offset comes from when the run heard each worker test event it followed, and is 0 when it followed none: workers
|
|
470
|
-
* whose test events the command staged in the run directory share the run's clock.
|
|
471
|
-
*/
|
|
472
|
-
function workerClock({ timeline, workerOffsetMs }) {
|
|
473
|
-
const tests = timeline.rows.find((row) => row.name === "command");
|
|
474
|
-
if (tests === undefined)
|
|
475
|
-
return undefined;
|
|
476
|
-
return { runStartedAt: Date.parse(timeline.startedAt), offsetMs: workerOffsetMs, tests };
|
|
477
|
-
}
|
|
478
|
-
/** A path as a person reads it: under `HOME`, starting `~/`. */
|
|
479
|
-
export function displayPath(path, env) {
|
|
480
|
-
const home = env["HOME"];
|
|
481
|
-
if (home === undefined || home === "" || !path.startsWith(`${home}/`))
|
|
482
|
-
return path;
|
|
483
|
-
return `~${path.slice(home.length)}`;
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Where the run directory is, for the summary's logs line, and what went wrong with it: it couldn't be made, a write
|
|
487
|
-
* failed, or pruning couldn't remove an older one or the staged test events left in one. The run goes on whichever it
|
|
488
|
-
* was. Then the command that reads the run back by its run id, with `--failed` when a test `failed` and `--workers`
|
|
489
|
-
* when parallelism was poor.
|
|
490
|
-
*/
|
|
491
|
-
export function logsText({ opened }, writeFailure, env, failed, workersHint) {
|
|
492
|
-
if (!opened.ok)
|
|
493
|
-
return `none: couldn't make ${opened.failure.path}: ${opened.failure.message}`;
|
|
494
|
-
const path = `${displayPath(opened.path, env)}/`;
|
|
495
|
-
const problems = [
|
|
496
|
-
...(writeFailure === undefined ? [] : [`couldn't write ${writeFailure.path}: ${writeFailure.message}`]),
|
|
497
|
-
...opened.pruneFailures.slice(0, 1).map((failure) => `couldn't remove ${failure.path}: ${failure.message}`),
|
|
498
|
-
];
|
|
499
|
-
const flags = `${failed ? " --failed" : ""}${workersHint ? " --workers" : ""}`;
|
|
500
|
-
const show = `storm runs show ${opened.id}${flags}`;
|
|
501
|
-
return `${problems.length === 0 ? path : `${path} (${problems.join("; ")})`} · ${show}`;
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Where the checkout `cwd` is in was as the run starts, for `run.json`; null outside a Git checkout, or when git
|
|
505
|
-
* can't say. The run goes on either way.
|
|
506
|
-
*/
|
|
507
|
-
export async function checkoutGit(checkout, cwd) {
|
|
508
|
-
const root = await checkout.repositoryRoot({ cwd });
|
|
509
|
-
if (!root.ok)
|
|
510
|
-
return null;
|
|
511
|
-
const head = await checkout.head({ repoRoot: root.value });
|
|
512
|
-
return head.ok ? { ...head.value } : null;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Each resource's definition and options, by resource key, in order: what a runner recipe's `vcpus`
|
|
516
|
-
* function reads.
|
|
517
|
-
*/
|
|
518
|
-
export function recipeResources(requests) {
|
|
519
|
-
return Object.fromEntries(Object.entries(requests).map(([key, { definition, options }]) => {
|
|
520
|
-
// A resource's options are the plain values its definition merges to: always an object.
|
|
521
|
-
if (typeof options !== "object" || options === null)
|
|
522
|
-
throw new Error(`${key}'s options are not an object`);
|
|
523
|
-
return [key, { definition, options }];
|
|
524
|
-
}));
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* How long the runner sandbox keeps running once the run ends, in minutes: `--keep-sandbox`, else the recipe's
|
|
528
|
-
* `keepSandbox`, else 0. A run keeps its runner sandbox only on request, since anyone who can update the Vercel project
|
|
529
|
-
* can connect to it.
|
|
530
|
-
*/
|
|
531
|
-
function keepSandboxMinutes(flag, recipe) {
|
|
532
|
-
// `validate` refused a flag this can't read.
|
|
533
|
-
const fromFlag = flag === undefined ? undefined : parseKeepTime(flag);
|
|
534
|
-
return fromFlag ?? recipe.keepSandboxMinutes ?? 0;
|
|
535
|
-
}
|
|
536
|
-
/** For each runner step that failed, where its whole output is: the summary's lines after the critical path. */
|
|
537
|
-
function failedStepLogs(timeline, recording, env) {
|
|
538
|
-
const runner = timeline.rows.find((row) => row.name === "runner");
|
|
539
|
-
return (runner?.steps ?? [])
|
|
540
|
-
.filter((step) => step.outcome === "failed")
|
|
541
|
-
.flatMap((step) => {
|
|
542
|
-
const log = recording.stepLog(step.name);
|
|
543
|
-
return log === undefined ? [] : [` failed ${step.name}, whole output: ${displayPath(log, env)}`];
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
/** A runner failure as outcomes report it. */
|
|
547
|
-
export function runnerFailureFacts(failure) {
|
|
548
|
-
switch (failure.kind) {
|
|
549
|
-
case "snapshot-build-step-failed":
|
|
550
|
-
case "apply-failed":
|
|
551
|
-
case "install-failed":
|
|
552
|
-
case "build-failed":
|
|
553
|
-
return { kind: failure.kind, label: failure.label, exitCode: failure.exitCode, tail: [...failure.tail] };
|
|
554
|
-
case "sandbox-api-failed":
|
|
555
|
-
return { kind: failure.kind, operation: failure.operation, status: failure.status, message: failure.message };
|
|
556
|
-
case "checkout-failed":
|
|
557
|
-
return { kind: failure.kind, message: failure.failure.message, command: failure.failure.displayCommand ?? null };
|
|
558
|
-
case "network-policy-failed":
|
|
559
|
-
return {
|
|
560
|
-
kind: failure.kind,
|
|
561
|
-
operation: failure.operation,
|
|
562
|
-
around: failure.around,
|
|
563
|
-
reason: failure.reason,
|
|
564
|
-
status: failure.status,
|
|
565
|
-
message: failure.message,
|
|
566
|
-
};
|
|
567
|
-
case "credential-claims-missing":
|
|
568
|
-
return { kind: failure.kind, ...failure.target };
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
/** The cleanup of a run that never started a runner sandbox or acquired a resource. */
|
|
572
|
-
const NOTHING_RELEASED = { runnerCleanup: null, resourceCleanup: {} };
|
|
573
|
-
/**
|
|
574
|
-
* What a canceled run changed, for a person: whether its command ran, what happened to a sandboxed run's sandboxes, and
|
|
575
|
-
* what each of its resource instances says of what it changed (`DEFINITION_SET.reports.canceledLines`).
|
|
576
|
-
*/
|
|
577
|
-
export function canceledChanges(outcome, options = {}) {
|
|
578
|
-
const { commandStopped } = outcome;
|
|
579
|
-
const lines = [
|
|
580
|
-
options.commandLine ??
|
|
581
|
-
(commandStopped === true ? "The command was stopped in the runner sandbox." : "The command didn't run."),
|
|
582
|
-
];
|
|
583
|
-
const cleanup = RUN_CLEANUP.facts(outcome).runner;
|
|
584
|
-
if (cleanup !== null)
|
|
585
|
-
lines.push(...runnerCleanupLines(cleanup, options.keptLines));
|
|
586
|
-
else if (options.keptLines !== undefined)
|
|
587
|
-
lines.push(...options.keptLines);
|
|
588
|
-
lines.push(...DEFINITION_SET.reports.canceledLines(outcome.resourceCleanup));
|
|
589
|
-
return lines.join("\n");
|
|
590
|
-
}
|
|
591
|
-
function runnerCleanupLines({ kept, notKept, notStopped, notDeleted }, keptLines) {
|
|
592
|
-
const problems = [
|
|
593
|
-
...(notKept === null ? [] : [notKeptText(notKept)]),
|
|
594
|
-
...notStopped.map(notStoppedText),
|
|
595
|
-
...notDeleted.map(notDeletedText),
|
|
596
|
-
];
|
|
597
|
-
const allKept = [...(kept === null ? [] : [keptText(kept)]), ...(keptLines ?? [])];
|
|
598
|
-
if (allKept.length === 0)
|
|
599
|
-
return problems.length === 0 ? ["Every sandbox the runner started is stopped and deleted."] : problems;
|
|
600
|
-
return [
|
|
601
|
-
...allKept,
|
|
602
|
-
...(problems.length === 0 ? ["Every other sandbox the runner started is stopped and deleted."] : problems),
|
|
603
|
-
];
|
|
604
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { CommandResult, ExecutionContext } from "@vercel/clinkr";
|
|
2
|
-
import type { StormApp } from "../../context.ts";
|
|
3
|
-
import type { PlannedFacts } from "../../planning/plan-only.ts";
|
|
4
|
-
import type { RunTestPlan } from "../../sdk/extension/index.ts";
|
|
5
|
-
import { type PlannedRun, type RunCommandRequest, type RunCommandSpec } from "./run-command.ts";
|
|
6
|
-
import { type AcrossSandboxesSpec } from "./across-sandboxes-run.ts";
|
|
7
|
-
/**
|
|
8
|
-
* How one command ends its planned run: its name and its words, and its outcome for each way the run can go: `ran`,
|
|
9
|
-
* `sandboxes_ran`, and under `--plan-only`, `planned`.
|
|
10
|
-
*/
|
|
11
|
-
export interface PlannedRunSpec<TTestPlan extends RunTestPlan, TRan, TSandboxesRan, TPlanned> extends RunCommandSpec<TTestPlan, TRan>, AcrossSandboxesSpec<TSandboxesRan> {
|
|
12
|
-
/** The `planned` outcome, for a run with `--plan-only`. */
|
|
13
|
-
planned(facts: PlannedFacts): TPlanned;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Does what `request` asks of planned run `plan`: with `--plan-only`, answers the planned run and starts nothing
|
|
17
|
-
* (`plannedRun`); else runs it, as a run across runner sandboxes when its plan holds them
|
|
18
|
-
* (`runPlannedAcrossSandboxes`), and else as a run that is not (`runPlannedCommand`).
|
|
19
|
-
*/
|
|
20
|
-
export declare function runPlanned<TTestPlan extends RunTestPlan, TRan extends CommandResult, TSandboxesRan, TPlanned>(context: ExecutionContext<StormApp>, request: RunCommandRequest, spec: PlannedRunSpec<TTestPlan, TRan, TSandboxesRan, TPlanned>, plan: PlannedRun<TTestPlan>): Promise<TPlanned | TRan | TSandboxesRan | import("@vercel/clinkr").ClinkrError<"canceled"> | import("@vercel/clinkr").CommandError<"credential_unused"> | import("@vercel/clinkr").CommandError<"invalid_config"> | import("@vercel/clinkr").CommandError<"mint_failed"> | import("@vercel/clinkr").CommandError<"missing_target"> | import("@vercel/clinkr").CommandError<"no_base_ref"> | import("@vercel/clinkr").CommandError<"resource_needs_runner_sandbox"> | import("@vercel/clinkr").CommandError<"resource_refused"> | import("@vercel/clinkr").CommandError<"resource_refused_before_run"> | import("@vercel/clinkr").CommandError<"runner_failed"> | import("@vercel/clinkr").CommandError<"snapshot_gone"> | import("@vercel/clinkr").CommandError<"spawn_failed"> | import("@vercel/clinkr").CommandError<"submodules_refused">>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// What a run command does with its planned run, which `exec`, `vitest` and `playwright` share: the one place that tells
|
|
2
|
-
// `--plan-only`, a run that is not across runner sandboxes, and a run across runner sandboxes apart. A command plans
|
|
3
|
-
// its run first, in the way its request asks (`planCommandRun`, `planAskedSandboxesRun`, or `planDefaultSandboxesRun`),
|
|
4
|
-
// and hands the plan here, so no way of planning has a `--plan-only` branch of its own.
|
|
5
|
-
import { plannedRun } from "./plan-only.js";
|
|
6
|
-
import { runPlannedCommand } from "./run-command.js";
|
|
7
|
-
import { runPlannedAcrossSandboxes, acrossSandboxesWhere } from "./across-sandboxes-run.js";
|
|
8
|
-
/**
|
|
9
|
-
* Does what `request` asks of planned run `plan`: with `--plan-only`, answers the planned run and starts nothing
|
|
10
|
-
* (`plannedRun`); else runs it, as a run across runner sandboxes when its plan holds them
|
|
11
|
-
* (`runPlannedAcrossSandboxes`), and else as a run that is not (`runPlannedCommand`).
|
|
12
|
-
*/
|
|
13
|
-
export async function runPlanned(context, request, spec, plan) {
|
|
14
|
-
const { planned, lifecycles } = plan;
|
|
15
|
-
if (request.planOnly)
|
|
16
|
-
return await plannedRun(context.app, planned, lifecycles, (facts) => spec.planned(facts));
|
|
17
|
-
const { sandboxes } = planned;
|
|
18
|
-
if (sandboxes === undefined)
|
|
19
|
-
return await runPlannedCommand(context, request, spec, planned, lifecycles);
|
|
20
|
-
const where = acrossSandboxesWhere(planned.where);
|
|
21
|
-
return await runPlannedAcrossSandboxes(context, request, spec, { ...planned, sandboxes, where }, lifecycles);
|
|
22
|
-
}
|