@cnc-tools/storm 0.16.0 → 0.18.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 +54 -40
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/chunk-AS37D43E.js +2173 -0
- package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
- package/dist/chunks/chunk-DZLU7BYK.js +340 -0
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
- package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
- package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
- package/dist/chunks/chunk-SZMYIIG2.js +88 -0
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
- package/dist/cli.d.ts +28 -0
- package/dist/cli.js +64 -0
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
- package/dist/commands/exec/across-sandboxes-outcomes.js +3 -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 +67 -14
- 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 +104 -22
- package/dist/commands/exec/outcomes.js +73 -26
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +239 -90
- 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 +4 -4
- 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 +8 -4
- package/dist/commands/runs/facts.js +19 -10
- package/dist/commands/runs/list/command.d.ts +16 -8
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +8 -4
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +16 -8
- package/dist/commands/runs/show/command.js +31 -29
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +8 -4
- package/dist/commands/runs/show/outcomes.js +8 -6
- 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 +376 -101
- package/dist/commands/snapshots/build/command.js +447 -149
- 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 +242 -47
- 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 +298 -68
- 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 +247 -15
- package/dist/commands/snapshots/list/outcomes.js +223 -52
- 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 +17 -17
- package/dist/commands/suites/list/outcomes.js +2 -2
- package/dist/commands/test/command.d.ts +67 -14
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +33 -7
- package/dist/config/check-runner.d.ts +3 -3
- package/dist/config/check-runner.js +8 -7
- 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/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/config/runner.d.ts +5 -5
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +1 -1
- package/dist/config-file/define.d.ts +1 -1
- package/dist/config-file/define.js +1 -1
- package/dist/config-file/runner.d.ts +5 -5
- package/dist/config-file/toolchain.d.ts +14 -4
- package/dist/config-file/toolchain.js +43 -7
- package/dist/context.d.ts +10 -6
- package/dist/context.js +8 -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 +107 -267
- 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 +1 -1
- package/dist/extension-commands.js +2 -2
- 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 +1 -1
- package/dist/extensions/testserver/resource.js +1 -1
- 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 +3 -14
- package/dist/planning/plan-only.js +11 -20
- package/dist/planning/run-kind-flags.js +2 -2
- package/dist/planning/run-plan.d.ts +45 -12
- 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 +9 -0
- package/dist/run-directory/recording.js +3 -3
- package/dist/run-directory/run-record.d.ts +26 -11
- package/dist/run-directory/run-record.js +16 -13
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +60 -29
- package/dist/runner/build-snapshots.js +136 -29
- 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 +122 -23
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/gh.d.ts +42 -0
- package/dist/runner/gh.js +58 -0
- package/dist/runner/index.d.ts +13 -8
- package/dist/runner/index.js +12 -6
- package/dist/runner/live/checkout-gateway.js +7 -0
- package/dist/runner/live/gh-output.d.ts +17 -0
- package/dist/runner/live/gh-output.js +37 -0
- package/dist/runner/live/gh-token-gateway.d.ts +13 -0
- package/dist/runner/live/gh-token-gateway.js +51 -0
- 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 +140 -4
- 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 +12 -12
- package/dist/runner/local-snapshot-index.d.ts +205 -0
- package/dist/runner/local-snapshot-index.js +210 -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 +14 -14
- package/dist/runner/prepare.js +20 -11
- package/dist/runner/ready.d.ts +19 -11
- 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 +15 -8
- package/dist/runner/scope.js +16 -5
- package/dist/runner/secrets.d.ts +41 -18
- package/dist/runner/secrets.js +226 -30
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +6 -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 +79 -47
- package/dist/runner/snapshot-choice.js +2 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +52 -35
- package/dist/runner/snapshot-key.d.ts +32 -17
- package/dist/runner/snapshot-key.js +43 -18
- package/dist/runner/snapshot-source.d.ts +31 -0
- package/dist/runner/snapshot-source.js +122 -0
- 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} +4 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
- package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
- 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 +1 -1
- 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/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 +5 -3
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- package/dist/application.d.ts +0 -21
- package/dist/application.js +0 -30
- package/dist/chunks/chunk-7EENF73W.js +0 -782
- package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
- 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 -45
- package/dist/commands/exec/run-command.d.ts +0 -475
- package/dist/commands/exec/run-command.js +0 -603
- 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 -125
- package/dist/core/sandbox-end.d.ts +0 -64
- package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
- package/dist/runner/recipe-secrets.d.ts +0 -67
- package/dist/runner/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
|
@@ -1,2599 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
versionText
|
|
3
|
-
} from "./chunk-I5GZLOLQ.js";
|
|
4
|
-
import {
|
|
5
|
-
comparedPath,
|
|
6
|
-
criticalPathStep,
|
|
7
|
-
fileListMismatchText,
|
|
8
|
-
hasPoorParallelism,
|
|
9
|
-
recordedPlan,
|
|
10
|
-
resourceFlagFields,
|
|
11
|
-
resourceFlagProblems,
|
|
12
|
-
resourceFlagValues,
|
|
13
|
-
testPlanLine,
|
|
14
|
-
testsChart,
|
|
15
|
-
testsSummaryLines,
|
|
16
|
-
waterfallLines
|
|
17
|
-
} from "./chunk-FCQUJDA4.js";
|
|
18
|
-
import {
|
|
19
|
-
DEFINITION_SET
|
|
20
|
-
} from "./chunk-DWEAHX4T.js";
|
|
21
|
-
import {
|
|
22
|
-
redactStrings,
|
|
23
|
-
redactingObserver,
|
|
24
|
-
redactingTerminal,
|
|
25
|
-
redactor
|
|
26
|
-
} from "./chunk-HVNK3I45.js";
|
|
27
|
-
import {
|
|
28
|
-
builtAtText,
|
|
29
|
-
rejectionLines,
|
|
30
|
-
snapshotCacheNoteText
|
|
31
|
-
} from "./chunk-3L52KNQA.js";
|
|
32
|
-
import {
|
|
33
|
-
NodeSignalCancellation
|
|
34
|
-
} from "./chunk-VUPZH7J2.js";
|
|
35
|
-
import {
|
|
36
|
-
SANDBOX_TABLE_HEADER,
|
|
37
|
-
sandboxConnectPage,
|
|
38
|
-
sandboxTableRows,
|
|
39
|
-
sandboxTotalsLine
|
|
40
|
-
} from "./chunk-2MAD5NKK.js";
|
|
41
|
-
import {
|
|
42
|
-
planSchema,
|
|
43
|
-
recordRun,
|
|
44
|
-
sandboxRecordSchema,
|
|
45
|
-
timelineSchema
|
|
46
|
-
} from "./chunk-P357TZAY.js";
|
|
47
|
-
import {
|
|
48
|
-
isoSecondsText,
|
|
49
|
-
keepTimeText,
|
|
50
|
-
orderText,
|
|
51
|
-
paint,
|
|
52
|
-
releaseText,
|
|
53
|
-
seconds,
|
|
54
|
-
short,
|
|
55
|
-
shortFile,
|
|
56
|
-
spread,
|
|
57
|
-
truncate,
|
|
58
|
-
visibleLength,
|
|
59
|
-
withArticle
|
|
60
|
-
} from "./chunk-G3PHMXH5.js";
|
|
61
|
-
import {
|
|
62
|
-
EMPTY_RUN_STATE,
|
|
63
|
-
cleanupProblems,
|
|
64
|
-
commandExitStatus,
|
|
65
|
-
executeRun,
|
|
66
|
-
megabytesText,
|
|
67
|
-
secondsOf,
|
|
68
|
-
secondsText,
|
|
69
|
-
setupPhaseKey,
|
|
70
|
-
setupPhaseWords,
|
|
71
|
-
timedProgress,
|
|
72
|
-
warningTally
|
|
73
|
-
} from "./chunk-FOZWA52V.js";
|
|
74
|
-
import {
|
|
75
|
-
CONFIG_FILE_NAMES_TEXT,
|
|
76
|
-
MAX_RUNNER_SANDBOXES,
|
|
77
|
-
configErrors,
|
|
78
|
-
credentialErrors,
|
|
79
|
-
fileSettings,
|
|
80
|
-
invalidConfig,
|
|
81
|
-
mintTargetText,
|
|
82
|
-
parseKeepTime,
|
|
83
|
-
prepareRunner,
|
|
84
|
-
readCredentials,
|
|
85
|
-
readUnsafeSecretEnvVars,
|
|
86
|
-
requireTarget,
|
|
87
|
-
settleCredential,
|
|
88
|
-
settleRunResources
|
|
89
|
-
} from "./chunk-DC2CDHNK.js";
|
|
90
|
-
import {
|
|
91
|
-
SECRET_MIN_LENGTH,
|
|
92
|
-
describeMintFailure,
|
|
93
|
-
optionKeyPath
|
|
94
|
-
} from "./chunk-AWBSONHB.js";
|
|
95
|
-
import {
|
|
96
|
-
defineErrors,
|
|
97
|
-
defineOutcomes,
|
|
98
|
-
refused,
|
|
99
|
-
renderOutcome
|
|
100
|
-
} from "./chunk-VL7WFTVQ.js";
|
|
101
|
-
|
|
102
|
-
// src/shared/cleanup.ts
|
|
103
|
-
import { z } from "zod";
|
|
104
|
-
var notStoppedSchema = z.object({
|
|
105
|
-
name: z.string(),
|
|
106
|
-
role: z.enum(["runner", "snapshot-build"]),
|
|
107
|
-
/** The sandbox's own timeout, in minutes, within which it stops. */
|
|
108
|
-
timeoutMinutes: z.number(),
|
|
109
|
-
message: z.string()
|
|
110
|
-
});
|
|
111
|
-
var notDeletedSchema = z.object({
|
|
112
|
-
name: z.string(),
|
|
113
|
-
role: z.enum(["runner", "snapshot-build"]),
|
|
114
|
-
message: z.string()
|
|
115
|
-
});
|
|
116
|
-
var keptSchema = z.object({
|
|
117
|
-
name: z.string(),
|
|
118
|
-
/** When its timeout stops it, as an ISO time: the keep time from when the run ended, or later. */
|
|
119
|
-
stopsAt: z.string(),
|
|
120
|
-
/** Its Connect page in the Vercel dashboard, which says how to open a shell in it. */
|
|
121
|
-
url: z.string()
|
|
122
|
-
});
|
|
123
|
-
var notKeptSchema = z.object({ name: z.string(), message: z.string() });
|
|
124
|
-
var runnerCleanupSchema = z.object({
|
|
125
|
-
kept: keptSchema.nullable(),
|
|
126
|
-
notKept: notKeptSchema.nullable(),
|
|
127
|
-
notStopped: z.array(notStoppedSchema),
|
|
128
|
-
notDeleted: z.array(notDeletedSchema)
|
|
129
|
-
});
|
|
130
|
-
function sandboxRole(role) {
|
|
131
|
-
return role === "runner" ? "runner sandbox" : "build sandbox";
|
|
132
|
-
}
|
|
133
|
-
function notStoppedText(sandbox) {
|
|
134
|
-
return `Couldn't stop the ${sandboxRole(sandbox.role)} ${sandbox.name}: ${sandbox.message}. Its own timeout stops it within ${sandbox.timeoutMinutes} minutes.`;
|
|
135
|
-
}
|
|
136
|
-
function notDeletedText(sandbox) {
|
|
137
|
-
return `Stopped the ${sandboxRole(sandbox.role)} ${sandbox.name}, but couldn't delete it: ${sandbox.message}. It stays listed in the Vercel project.`;
|
|
138
|
-
}
|
|
139
|
-
function keptText(kept) {
|
|
140
|
-
return `Kept the runner sandbox ${kept.name} running until ${isoSecondsText(kept.stopsAt)}, with no network access, so you can connect to it: ${kept.url}`;
|
|
141
|
-
}
|
|
142
|
-
function notKeptText(sandbox) {
|
|
143
|
-
return `Couldn't keep the runner sandbox ${sandbox.name} running: ${sandbox.message}. Stopped and deleted it instead.`;
|
|
144
|
-
}
|
|
145
|
-
function runnerCleanupRows(cleanup) {
|
|
146
|
-
if (cleanup === null) return [];
|
|
147
|
-
const { kept, notKept } = cleanup;
|
|
148
|
-
return [
|
|
149
|
-
...kept === null ? [] : [
|
|
150
|
-
[
|
|
151
|
-
"Runner sandbox kept",
|
|
152
|
-
[`${kept.name}, running until ${isoSecondsText(kept.stopsAt)}, with no network access`, kept.url]
|
|
153
|
-
]
|
|
154
|
-
],
|
|
155
|
-
...notKept === null ? [] : [["Runner sandbox not kept", notKeptText(notKept)]],
|
|
156
|
-
...cleanup.notStopped.length === 0 ? [] : [["Sandboxes not stopped", cleanup.notStopped.map(notStoppedText)]],
|
|
157
|
-
...cleanup.notDeleted.length === 0 ? [] : [["Sandboxes not deleted", cleanup.notDeleted.map(notDeletedText)]]
|
|
158
|
-
];
|
|
159
|
-
}
|
|
160
|
-
function runnerCleanupWarnings(cleanup) {
|
|
161
|
-
if (cleanup === null) return [];
|
|
162
|
-
return [
|
|
163
|
-
...cleanup.notKept === null ? [] : [{ reason: "runner_sandbox_not_kept", message: notKeptText(cleanup.notKept) }],
|
|
164
|
-
...cleanup.notStopped.map((sandbox) => ({
|
|
165
|
-
reason: "runner_sandbox_not_stopped",
|
|
166
|
-
message: notStoppedText(sandbox)
|
|
167
|
-
})),
|
|
168
|
-
...cleanup.notDeleted.map((sandbox) => ({
|
|
169
|
-
reason: "runner_sandbox_not_deleted",
|
|
170
|
-
message: notDeletedText(sandbox)
|
|
171
|
-
}))
|
|
172
|
-
];
|
|
173
|
-
}
|
|
174
|
-
function runCleanupOf(reports) {
|
|
175
|
-
const schema = z.object({ runner: runnerCleanupSchema.nullable(), resources: reports.cleanupSchema });
|
|
176
|
-
const rows = (cleanup) => [
|
|
177
|
-
...runnerCleanupRows(cleanup.runner),
|
|
178
|
-
...reports.cleanupRows(cleanup.resources)
|
|
179
|
-
];
|
|
180
|
-
return {
|
|
181
|
-
schema,
|
|
182
|
-
facts: ({ runnerCleanup, resourceCleanup }) => ({
|
|
183
|
-
runner: runnerCleanupOf(runnerCleanup),
|
|
184
|
-
resources: reports.cleanupFacts(resourceCleanup)
|
|
185
|
-
}),
|
|
186
|
-
rows
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
var RUN_CLEANUP = runCleanupOf(DEFINITION_SET.reports);
|
|
190
|
-
function runnerCleanupOf(report) {
|
|
191
|
-
if (report === null) return null;
|
|
192
|
-
const { kept, target } = report;
|
|
193
|
-
return {
|
|
194
|
-
kept: kept === null ? null : { name: kept.name, stopsAt: kept.stopsAt, url: sandboxConnectPage(target, kept.name) },
|
|
195
|
-
notKept: report.notKept === null ? null : { ...report.notKept },
|
|
196
|
-
notStopped: report.notStopped.map(({ name, role, timeoutMinutes, message }) => ({
|
|
197
|
-
name,
|
|
198
|
-
role,
|
|
199
|
-
timeoutMinutes,
|
|
200
|
-
message
|
|
201
|
-
})),
|
|
202
|
-
notDeleted: report.notDeleted.map(({ name, role, message }) => ({ name, role, message }))
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// src/commands/exec/outcomes.ts
|
|
207
|
-
import { z as z6 } from "zod";
|
|
208
|
-
|
|
209
|
-
// src/planning/final-results.ts
|
|
210
|
-
function lacksFinalResults(exitCode, read) {
|
|
211
|
-
return exitCode === 0 && read.collected && read.finalResults === 0 && !read.partial;
|
|
212
|
-
}
|
|
213
|
-
var NO_FINAL_RESULTS_MESSAGE = "The command exited 0, but storm got no final test result from it, so the run saved no test results. A test runner reports them only with storm's reporter in its config, and a --reporter on its command line replaces the config's reporters.";
|
|
214
|
-
function noFinalResultsContent(noFinalTestResults, hints) {
|
|
215
|
-
if (!noFinalTestResults) return { warnings: [], next: [] };
|
|
216
|
-
return {
|
|
217
|
-
warnings: [{ reason: "no_final_test_results", message: NO_FINAL_RESULTS_MESSAGE }],
|
|
218
|
-
next: hints.addReporter.map((text) => ({ type: "text", text }))
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// src/planning/plan-only.ts
|
|
223
|
-
import { z as z2 } from "zod";
|
|
224
|
-
var plannedOptionSchema = z2.object({
|
|
225
|
-
/** The option's key path, `resources.<key>.<option>`. */
|
|
226
|
-
path: z2.string(),
|
|
227
|
-
/** Its value; a value that is not a string, a number, or a boolean as its JSON text. */
|
|
228
|
-
value: z2.union([z2.string(), z2.number(), z2.boolean()]),
|
|
229
|
-
/** Where the value came from: its flag (`flag`), storm.config.ts (`file`), or its default (`default`). */
|
|
230
|
-
from: z2.enum(["flag", "file", "default"])
|
|
231
|
-
});
|
|
232
|
-
var plannedSchema = z2.object({
|
|
233
|
-
version: z2.string(),
|
|
234
|
-
commit: z2.string().nullable(),
|
|
235
|
-
configFile: z2.string().nullable(),
|
|
236
|
-
argv: z2.array(z2.string()),
|
|
237
|
-
plan: planSchema.nullable(),
|
|
238
|
-
testFiles: z2.array(z2.string()).nullable(),
|
|
239
|
-
runnerSandboxes: z2.object({
|
|
240
|
-
max: z2.number(),
|
|
241
|
-
default: z2.union([z2.number(), z2.object({ filesPerSandbox: z2.number(), max: z2.number().optional() })]).nullable()
|
|
242
|
-
}).nullable(),
|
|
243
|
-
sandboxes: z2.array(z2.object({ sandbox: z2.number(), argv: z2.array(z2.string()), files: z2.array(z2.string()).nullable() })).nullable(),
|
|
244
|
-
options: z2.array(plannedOptionSchema),
|
|
245
|
-
vcpus: z2.number().nullable()
|
|
246
|
-
});
|
|
247
|
-
function plannedSecrets(lifecycles, where, resources) {
|
|
248
|
-
return [...lifecycles.secrets(resources), ...where.kind === "runner" ? where.secrets : []];
|
|
249
|
-
}
|
|
250
|
-
function buildPlannedFacts(input) {
|
|
251
|
-
const { where, sandboxes, resources, lifecycles } = input;
|
|
252
|
-
const policy = where.kind === "runner" ? where.recipe.sandboxes : void 0;
|
|
253
|
-
const basePlan = recordedPlan(input.testPlan, input.planOptions);
|
|
254
|
-
const plan = sandboxes !== void 0 ? {
|
|
255
|
-
...basePlan ?? { options: [] },
|
|
256
|
-
options: (basePlan?.options ?? []).map((option) => ({ ...option })),
|
|
257
|
-
sandboxes: { ...sandboxes.count }
|
|
258
|
-
} : basePlan === void 0 ? null : { ...basePlan, options: basePlan.options.map((option) => ({ ...option })) };
|
|
259
|
-
const facts = {
|
|
260
|
-
version: input.version,
|
|
261
|
-
commit: input.commit,
|
|
262
|
-
configFile: input.configFile,
|
|
263
|
-
argv: [...input.argv],
|
|
264
|
-
plan,
|
|
265
|
-
testFiles: input.testFiles === void 0 ? null : [...input.testFiles],
|
|
266
|
-
runnerSandboxes: policy === void 0 ? null : {
|
|
267
|
-
max: policy.max,
|
|
268
|
-
default: policy.default ?? null
|
|
269
|
-
},
|
|
270
|
-
sandboxes: sandboxes === void 0 ? null : sandboxes.sandboxes.map(({ argv, files }, index) => ({
|
|
271
|
-
sandbox: index,
|
|
272
|
-
argv: [...argv],
|
|
273
|
-
files: files === null ? null : [...files]
|
|
274
|
-
})),
|
|
275
|
-
options: Object.entries(resources).flatMap(
|
|
276
|
-
([key, { options, sources }]) => Object.entries(options).map(([option, value]) => ({
|
|
277
|
-
path: optionKeyPath(key, option),
|
|
278
|
-
value: typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : JSON.stringify(value) ?? String(value),
|
|
279
|
-
from: sources[option] ?? "default"
|
|
280
|
-
}))
|
|
281
|
-
),
|
|
282
|
-
vcpus: input.vcpus
|
|
283
|
-
};
|
|
284
|
-
const redact = redactor(plannedSecrets(lifecycles, where, resources));
|
|
285
|
-
return redactStrings(facts, redact);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// src/commands/exec/mint-failed.ts
|
|
289
|
-
import { z as z3 } from "zod";
|
|
290
|
-
var mintFailedErrors = defineErrors({
|
|
291
|
-
mintFailed: {
|
|
292
|
-
exitCode: 1,
|
|
293
|
-
description: "The vercel CLI couldn't mint a credential, so the command didn't run. With the Vercel Sandbox runner, the credential was for the runner sandbox, which always needs one; on the launch machine, for a resource that couldn't go on without it.",
|
|
294
|
-
schema: z3.object({
|
|
295
|
-
team: z3.string(),
|
|
296
|
-
project: z3.string(),
|
|
297
|
-
cause: z3.string(),
|
|
298
|
-
fix: z3.string(),
|
|
299
|
-
/** Whether the credential was for the runner sandbox, not for a resource. */
|
|
300
|
-
runner: z3.boolean(),
|
|
301
|
-
/** What the run couldn't clean up. */
|
|
302
|
-
cleanup: RUN_CLEANUP.schema
|
|
303
|
-
}),
|
|
304
|
-
render: ({ cause, fix, runner, cleanup }) => {
|
|
305
|
-
const rows = RUN_CLEANUP.rows(cleanup);
|
|
306
|
-
return {
|
|
307
|
-
message: runner ? `Couldn't mint a credential for the runner sandbox: ${cause}. The command didn't run.` : `Couldn't mint a credential: ${cause}. One of the run's resources needed it, so the command didn't run.`,
|
|
308
|
-
...rows.length === 0 ? {} : { rows },
|
|
309
|
-
next: [{ type: "text", text: fix }]
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
// src/commands/exec/planned-outcome.ts
|
|
316
|
-
var PLANNED_DESCRIPTION = "With --plan-only: storm did the local checks and the plan step, and printed the planned run. It minted nothing, acquired no resource, started no sandbox, and opened no run directory. Each refusal a run gets before it mints, --plan-only gets too.";
|
|
317
|
-
function plannedText(planned) {
|
|
318
|
-
const files = (n) => `${n} test ${n === 1 ? "file" : "files"}`;
|
|
319
|
-
return [
|
|
320
|
-
...planned.plan === null ? [] : [testPlanLine(planned.plan)],
|
|
321
|
-
...(planned.sandboxes ?? []).map(
|
|
322
|
-
({ sandbox, argv, files: list }) => `runner sandbox ${sandbox}: ${list === null ? argv.join(" ") : files(list.length)}`
|
|
323
|
-
),
|
|
324
|
-
...planned.sandboxes === null ? [`command: ${planned.argv.join(" ")}`] : [],
|
|
325
|
-
...planned.vcpus === null ? [] : [
|
|
326
|
-
planned.sandboxes === null ? `runner sandbox: ${planned.vcpus} vCPUs` : `runner sandboxes: ${planned.vcpus} vCPUs each`
|
|
327
|
-
],
|
|
328
|
-
...planned.runnerSandboxes === null || planned.runnerSandboxes.default === null ? [] : [
|
|
329
|
-
`runner.sandboxes: default ${formatSandboxesDefault(planned.runnerSandboxes.default)}, max ${planned.runnerSandboxes.max}`
|
|
330
|
-
],
|
|
331
|
-
...planned.options.map(({ path, value, from }) => `${path}: ${String(value)} (${from})`)
|
|
332
|
-
].join("\n");
|
|
333
|
-
}
|
|
334
|
-
function formatSandboxesDefault(value) {
|
|
335
|
-
if (typeof value === "number") return String(value);
|
|
336
|
-
const per = `1 per ${value.filesPerSandbox} test ${value.filesPerSandbox === 1 ? "file" : "files"}`;
|
|
337
|
-
return value.max === void 0 ? per : `${per} (max ${value.max})`;
|
|
338
|
-
}
|
|
339
|
-
function renderPlanned(planned) {
|
|
340
|
-
return renderOutcome({
|
|
341
|
-
text: plannedText(planned),
|
|
342
|
-
message: "Nothing was minted, acquired, or started.",
|
|
343
|
-
next: [{ type: "text", text: "Run the same command without --plan-only to start the run." }]
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// src/commands/exec/resource-refusals.ts
|
|
348
|
-
import { z as z4 } from "zod";
|
|
349
|
-
var refusalShape = {
|
|
350
|
-
/** The resource instance that refused, by its resource key. */
|
|
351
|
-
resource: z4.string().min(1),
|
|
352
|
-
/** The resource's own snake_case reason for refusing. */
|
|
353
|
-
refusal: z4.string(),
|
|
354
|
-
/** The resource's own data about the refusal, which differs by resource and reason. */
|
|
355
|
-
data: z4.record(z4.string(), z4.unknown())
|
|
356
|
-
};
|
|
357
|
-
function contentOf({ message, next, rows: own = [] }, rows) {
|
|
358
|
-
const all = [...own, ...rows];
|
|
359
|
-
return { message, ...next === void 0 ? {} : { next }, ...all.length === 0 ? {} : { rows: all } };
|
|
360
|
-
}
|
|
361
|
-
var resourceRefusalErrors = defineErrors({
|
|
362
|
-
resourceRefusedBeforeRun: {
|
|
363
|
-
exitCode: 2,
|
|
364
|
-
description: "A resource's beforeRun refused the run before it started, so nothing was minted, acquired or started. data.resource names the resource by its key, data.refusal is the resource's own reason, and data.data its own data.",
|
|
365
|
-
schema: z4.object({
|
|
366
|
-
...refusalShape,
|
|
367
|
-
/** The config file that applied (its absolute path); null when none did. */
|
|
368
|
-
configFile: z4.string().nullable()
|
|
369
|
-
}),
|
|
370
|
-
render: (_data, refusal) => contentOf(refusal, [])
|
|
371
|
-
},
|
|
372
|
-
resourceRefused: {
|
|
373
|
-
exitCode: 1,
|
|
374
|
-
description: "A resource refused while the run acquired its resources, so the command didn't run. data.resource names the resource by its key, data.refusal is the resource's own reason, and data.data its own data.",
|
|
375
|
-
schema: z4.object({
|
|
376
|
-
...refusalShape,
|
|
377
|
-
/** What the run couldn't clean up. */
|
|
378
|
-
cleanup: RUN_CLEANUP.schema
|
|
379
|
-
}),
|
|
380
|
-
render: ({ cleanup }, refusal) => contentOf(refusal, RUN_CLEANUP.rows(cleanup))
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
function resourceRefusedBeforeRun(resource, refusal, configFile) {
|
|
384
|
-
const { refused: refused2, data, ...content } = refusal;
|
|
385
|
-
return resourceRefusalErrors.resourceRefusedBeforeRun(
|
|
386
|
-
{ resource, refusal: refused2, data: { ...data }, configFile },
|
|
387
|
-
content
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
function resourceRefused(outcome, cleanup) {
|
|
391
|
-
const { refused: refused2, data, ...content } = outcome.refusal;
|
|
392
|
-
return resourceRefusalErrors.resourceRefused(
|
|
393
|
-
{ resource: outcome.resource, refusal: refused2, data: { ...data }, cleanup },
|
|
394
|
-
content
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// src/commands/exec/across-sandboxes-outcomes.ts
|
|
399
|
-
import { z as z5 } from "zod";
|
|
400
|
-
|
|
401
|
-
// src/planning/file-lists-file.ts
|
|
402
|
-
import { isAbsolute, resolve } from "node:path";
|
|
403
|
-
async function readFileListsFile(gateway, request) {
|
|
404
|
-
const { path, cwd, sandboxes } = request;
|
|
405
|
-
const resolvedPath = path === "-" ? "-" : isAbsolute(path) ? path : resolve(cwd, path);
|
|
406
|
-
const read = await gateway.readFileListsFile({ path: resolvedPath });
|
|
407
|
-
if (read.kind !== "read") return { ok: false, kind: "unreadable", path, problem: read.kind, message: read.message };
|
|
408
|
-
const lists = fileListsOf(read.value);
|
|
409
|
-
if (!lists.ok) return { ok: false, kind: "unreadable", path, problem: "not-lists", message: lists.problem };
|
|
410
|
-
const problems = fileListsProblems(lists.lists, sandboxes);
|
|
411
|
-
if (problems.length > 0) return { ok: false, kind: "invalid", path, problems };
|
|
412
|
-
return { ok: true, lists: { path, lists: lists.lists } };
|
|
413
|
-
}
|
|
414
|
-
function fileListsOf(value) {
|
|
415
|
-
const shape = "an array with one array of test file paths for each runner sandbox";
|
|
416
|
-
if (!Array.isArray(value)) return { ok: false, problem: `holds ${describe(value)}, not ${shape}` };
|
|
417
|
-
if (value.length === 0) return { ok: false, problem: `holds an empty array, not ${shape}, at least one` };
|
|
418
|
-
const lists = [];
|
|
419
|
-
for (const [index, list] of value.entries()) {
|
|
420
|
-
if (!Array.isArray(list))
|
|
421
|
-
return {
|
|
422
|
-
ok: false,
|
|
423
|
-
problem: `holds ${describe(list)} as the list of runner sandbox ${index}, not an array of paths`
|
|
424
|
-
};
|
|
425
|
-
const bad = list.findIndex((file) => typeof file !== "string" || file === "");
|
|
426
|
-
if (bad !== -1)
|
|
427
|
-
return {
|
|
428
|
-
ok: false,
|
|
429
|
-
problem: `holds ${describe(list[bad])} in the list of runner sandbox ${index}, at item ${bad + 1}, not a test file's path`
|
|
430
|
-
};
|
|
431
|
-
lists.push(list);
|
|
432
|
-
}
|
|
433
|
-
return { ok: true, lists };
|
|
434
|
-
}
|
|
435
|
-
function describe(value) {
|
|
436
|
-
if (value === null) return "null";
|
|
437
|
-
if (Array.isArray(value)) return "an array";
|
|
438
|
-
if (typeof value === "string") return value === "" ? "an empty string" : `the string ${JSON.stringify(value)}`;
|
|
439
|
-
if (typeof value === "object") return "an object";
|
|
440
|
-
return `${typeof value} ${JSON.stringify(value) ?? typeof value}`;
|
|
441
|
-
}
|
|
442
|
-
function fileListsProblems(lists, sandboxes) {
|
|
443
|
-
const named = /* @__PURE__ */ new Map();
|
|
444
|
-
lists.forEach((list, index) => {
|
|
445
|
-
for (const file of list) {
|
|
446
|
-
const key = comparedPath(file);
|
|
447
|
-
named.set(key, [...named.get(key) ?? [], index]);
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
return [
|
|
451
|
-
...lists.flatMap((list, index) => list.length === 0 ? [{ kind: "empty-list", sandbox: index }] : []),
|
|
452
|
-
...[...named].flatMap(
|
|
453
|
-
([file, at]) => at.length > 1 ? [{ kind: "in-two-lists", file, sandboxes: at }] : []
|
|
454
|
-
),
|
|
455
|
-
...sandboxes !== void 0 && sandboxes !== lists.length ? [{ kind: "count-mismatch", lists: lists.length, sandboxes }] : []
|
|
456
|
-
];
|
|
457
|
-
}
|
|
458
|
-
function numbersText(numbers) {
|
|
459
|
-
const words = numbers.map(String);
|
|
460
|
-
if (words.length <= 2) return words.join(" and ");
|
|
461
|
-
return `${words.slice(0, -1).join(", ")}, and ${words.at(-1) ?? ""}`;
|
|
462
|
-
}
|
|
463
|
-
function fileListsProblemText(problem) {
|
|
464
|
-
switch (problem.kind) {
|
|
465
|
-
case "empty-list":
|
|
466
|
-
return `The list of runner sandbox ${problem.sandbox} holds no test file.`;
|
|
467
|
-
case "in-two-lists": {
|
|
468
|
-
const distinct = [...new Set(problem.sandboxes)];
|
|
469
|
-
return distinct.length === 1 ? `${problem.file} is in the list of runner sandbox ${distinct[0] ?? ""} ${problem.sandboxes.length} times.` : `${problem.file} is in the lists of runner sandboxes ${numbersText(problem.sandboxes)}.`;
|
|
470
|
-
}
|
|
471
|
-
case "count-mismatch":
|
|
472
|
-
return `The file holds ${problem.lists} ${problem.lists === 1 ? "list" : "lists"}, and --sandboxes asks for ${problem.sandboxes} ${problem.sandboxes === 1 ? "runner sandbox" : "runner sandboxes"}.`;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
function resolveCallerFileLists(testFiles, caller) {
|
|
476
|
-
const listed2 = new Map(testFiles.map((file) => [comparedPath(file), file]));
|
|
477
|
-
const unlisted = caller.lists.flat().filter((file) => !listed2.has(comparedPath(file)));
|
|
478
|
-
if (unlisted.length > 0) return { ok: false, unlisted, listed: listed2.size };
|
|
479
|
-
const lists = caller.lists.map((list) => list.map((file) => listed2.get(comparedPath(file)) ?? file));
|
|
480
|
-
const held = lists.reduce((sum, list) => sum + list.length, 0);
|
|
481
|
-
return { ok: true, lists, leftOut: listed2.size - held };
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// src/commands/exec/across-sandboxes-outcomes.ts
|
|
485
|
-
var keptSandboxSchema = z5.object({
|
|
486
|
-
sandbox: z5.number(),
|
|
487
|
-
name: z5.string(),
|
|
488
|
-
stopsAt: z5.string(),
|
|
489
|
-
url: z5.string()
|
|
490
|
-
});
|
|
491
|
-
var notKeptSandboxSchema = z5.object({ sandbox: z5.number(), name: z5.string(), message: z5.string() });
|
|
492
|
-
var sandboxesRanSchema = z5.object({
|
|
493
|
-
version: z5.string(),
|
|
494
|
-
commit: z5.string().nullable(),
|
|
495
|
-
configFile: z5.string().nullable(),
|
|
496
|
-
runId: z5.string().nullable(),
|
|
497
|
-
runDirectory: z5.string().nullable(),
|
|
498
|
-
sandboxes: z5.array(sandboxRecordSchema),
|
|
499
|
-
/** How many runner sandboxes are in each runner sandbox state, keyed by the state. */
|
|
500
|
-
states: z5.object({
|
|
501
|
-
passed: z5.number(),
|
|
502
|
-
failed: z5.number(),
|
|
503
|
-
"not-started": z5.number(),
|
|
504
|
-
canceled: z5.number()
|
|
505
|
-
}),
|
|
506
|
-
tests: z5.object({ passed: z5.number(), failed: z5.number(), skipped: z5.number() }).nullable(),
|
|
507
|
-
plan: planSchema,
|
|
508
|
-
resources: DEFINITION_SET.reports.ranSchema,
|
|
509
|
-
wallMs: z5.number(),
|
|
510
|
-
runner: z5.object({
|
|
511
|
-
snapshotId: z5.string(),
|
|
512
|
-
base: z5.string(),
|
|
513
|
-
builtBehind: z5.number().nullable(),
|
|
514
|
-
built: z5.boolean(),
|
|
515
|
-
vcpus: z5.number(),
|
|
516
|
-
region: z5.string(),
|
|
517
|
-
runtime: z5.string(),
|
|
518
|
-
uploadBytes: z5.number().nullable()
|
|
519
|
-
}),
|
|
520
|
-
cleanup: RUN_CLEANUP.schema,
|
|
521
|
-
kept: z5.array(keptSandboxSchema),
|
|
522
|
-
notKept: z5.array(notKeptSandboxSchema),
|
|
523
|
-
fileListMismatches: z5.array(
|
|
524
|
-
z5.object({ sandbox: z5.number(), missing: z5.array(z5.string()), extra: z5.array(z5.string()) })
|
|
525
|
-
)
|
|
526
|
-
});
|
|
527
|
-
var SANDBOXES_RAN_DESCRIPTION = "Every runner sandbox of a run across runner sandboxes ended. storm exits 0 when every runner sandbox passed, else 1, whatever this result's exit code. A runner sandbox with a file list whose command ended, and which reported nothing for a test file of its list or reported a test file not in its list, warns file_list_mismatch; the exit status is the same.";
|
|
528
|
-
function renderSandboxesRan(ran, options = {}) {
|
|
529
|
-
const noFinal = options.noFinal === void 0 ? { warnings: [], next: [] } : noFinalResultsContent(options.noFinal.noFinalTestResults, options.noFinal.hints);
|
|
530
|
-
const warnings = [
|
|
531
|
-
...ran.notKept.map((sandbox) => ({
|
|
532
|
-
reason: "runner_sandbox_not_kept",
|
|
533
|
-
message: `Runner sandbox ${sandbox.sandbox}: ${notKeptText(sandbox)}`
|
|
534
|
-
})),
|
|
535
|
-
...runnerCleanupWarnings(ran.cleanup.runner),
|
|
536
|
-
...DEFINITION_SET.reports.cleanupWarnings(ran.cleanup.resources),
|
|
537
|
-
...ran.fileListMismatches.map((mismatch) => ({
|
|
538
|
-
reason: "file_list_mismatch",
|
|
539
|
-
message: fileListMismatchText(
|
|
540
|
-
mismatch,
|
|
541
|
-
options.extraMismatchHint === void 0 ? {} : { extraHint: options.extraMismatchHint }
|
|
542
|
-
)
|
|
543
|
-
})),
|
|
544
|
-
...noFinal.warnings
|
|
545
|
-
];
|
|
546
|
-
const kept = ran.kept.map(
|
|
547
|
-
({ sandbox, name, stopsAt, url }) => `Kept runner sandbox ${sandbox}, ${name}, running until ${isoSecondsText(stopsAt)}, so you can connect to it: ${url}`
|
|
548
|
-
);
|
|
549
|
-
return renderOutcome({
|
|
550
|
-
...kept.length === 0 ? {} : { message: kept.join("\n") },
|
|
551
|
-
...warnings.length === 0 ? {} : { warnings },
|
|
552
|
-
...noFinal.next.length === 0 ? {} : { next: [...noFinal.next] }
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
var sandboxesFlagSchema = z5.enum(["--sandboxes", "--file-lists"]);
|
|
556
|
-
var fileListsProblemSchema = z5.discriminatedUnion("kind", [
|
|
557
|
-
z5.object({ kind: z5.literal("empty-list"), sandbox: z5.number() }),
|
|
558
|
-
z5.object({ kind: z5.literal("in-two-lists"), file: z5.string(), sandboxes: z5.array(z5.number()) }),
|
|
559
|
-
z5.object({ kind: z5.literal("count-mismatch"), lists: z5.number(), sandboxes: z5.number() })
|
|
560
|
-
]);
|
|
561
|
-
var NAMED_PATHS = 10;
|
|
562
|
-
function namedPaths(paths) {
|
|
563
|
-
return paths.length > NAMED_PATHS ? [...paths.slice(0, NAMED_PATHS), `and ${paths.length - NAMED_PATHS} more`] : paths;
|
|
564
|
-
}
|
|
565
|
-
var sandboxesErrors = defineErrors({
|
|
566
|
-
missingSandboxesMax: {
|
|
567
|
-
exitCode: 2,
|
|
568
|
-
description: "--sandboxes or --file-lists was given, and storm.config.ts has no runner.sandboxes key, which sets the most runner sandboxes a run can have. A repository opts in to runs across runner sandboxes. Nothing was minted, acquired, or started.",
|
|
569
|
-
schema: z5.object({
|
|
570
|
-
flag: sandboxesFlagSchema,
|
|
571
|
-
key: z5.string(),
|
|
572
|
-
configFile: z5.string().nullable()
|
|
573
|
-
}),
|
|
574
|
-
render: ({ flag, configFile }) => ({
|
|
575
|
-
message: `${flag} needs runner.sandboxes in storm.config.ts, and ${configFile === null ? `no ${CONFIG_FILE_NAMES_TEXT} applies` : `${configFile} has none`}. The run didn't start.`,
|
|
576
|
-
next: [
|
|
577
|
-
{
|
|
578
|
-
type: "text",
|
|
579
|
-
text: `Add runner: { sandboxes: { max: <n> } } to storm.config.ts, with n from 1 to ${MAX_RUNNER_SANDBOXES}: the most runner sandboxes a run can have. Or drop ${flag}.`
|
|
580
|
-
}
|
|
581
|
-
]
|
|
582
|
-
})
|
|
583
|
-
},
|
|
584
|
-
sandboxesOverMax: {
|
|
585
|
-
exitCode: 2,
|
|
586
|
-
description: "--sandboxes asked for more runner sandboxes than runner.sandboxes.max in storm.config.ts allows, or the file --file-lists names holds more lists than that. Nothing was minted, acquired, or started.",
|
|
587
|
-
schema: z5.object({
|
|
588
|
-
flag: sandboxesFlagSchema,
|
|
589
|
-
sandboxes: z5.number(),
|
|
590
|
-
key: z5.string(),
|
|
591
|
-
max: z5.number(),
|
|
592
|
-
configFile: z5.string().nullable()
|
|
593
|
-
}),
|
|
594
|
-
render: ({ flag, sandboxes, key, max }) => {
|
|
595
|
-
const raise = max < MAX_RUNNER_SANDBOXES ? `, or raise ${key} in storm.config.ts, up to ${MAX_RUNNER_SANDBOXES}` : "";
|
|
596
|
-
return {
|
|
597
|
-
message: flag === "--sandboxes" ? `--sandboxes ${sandboxes} asks for more runner sandboxes than ${key} allows: ${max}. The run didn't start.` : `--file-lists gives ${sandboxes} file lists, more than ${key} allows: ${max}. The run didn't start.`,
|
|
598
|
-
next: [
|
|
599
|
-
{
|
|
600
|
-
type: "text",
|
|
601
|
-
text: flag === "--sandboxes" ? `Give --sandboxes a number from 1 to ${max}${raise}.` : `Give at most ${max} lists in the file${raise}.`
|
|
602
|
-
}
|
|
603
|
-
]
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
});
|
|
608
|
-
var sandboxesDefaultErrors = defineErrors({
|
|
609
|
-
sandboxesDefaultRefused: {
|
|
610
|
-
exitCode: 2,
|
|
611
|
-
description: "runner.sandboxes.default in storm.config.ts makes this a run across runner sandboxes, and the run was given something a run across runner sandboxes can't take: --show-output or an argument its driver refuses in a run across runner sandboxes. Nothing was minted, acquired, or started.",
|
|
612
|
-
schema: z5.object({
|
|
613
|
-
key: z5.string(),
|
|
614
|
-
sandboxes: z5.number(),
|
|
615
|
-
field: z5.enum(["showOutput", "args"]),
|
|
616
|
-
problem: z5.string(),
|
|
617
|
-
configFile: z5.string().nullable()
|
|
618
|
-
}),
|
|
619
|
-
render: ({ key, sandboxes, problem }) => ({
|
|
620
|
-
message: `${key} in storm.config.ts makes this a run across ${sandboxes} ${sandboxes === 1 ? "runner sandbox" : "runner sandboxes"}, which can't take what the run was given: ${problem} The run didn't start.`,
|
|
621
|
-
next: [
|
|
622
|
-
{
|
|
623
|
-
type: "text",
|
|
624
|
-
text: `Drop what the problem names, or remove ${key} from storm.config.ts.`
|
|
625
|
-
}
|
|
626
|
-
]
|
|
627
|
-
})
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
var fileListErrors = defineErrors({
|
|
631
|
-
fileListsUnreadable: {
|
|
632
|
-
exitCode: 2,
|
|
633
|
-
description: "The file --file-lists names can't be read, its text isn't JSON, or its JSON isn't an array with one array of test file paths for each runner sandbox, at least one. Nothing was minted, acquired, or started.",
|
|
634
|
-
schema: z5.object({
|
|
635
|
-
path: z5.string(),
|
|
636
|
-
problem: z5.enum(["unreadable", "not-json", "not-lists"]),
|
|
637
|
-
message: z5.string()
|
|
638
|
-
}),
|
|
639
|
-
render: ({ path, problem, message }) => ({
|
|
640
|
-
message: problem === "unreadable" ? `Couldn't read the file lists file ${path}: ${message}. The run didn't start.` : problem === "not-json" ? `The file lists file ${path} isn't JSON: ${message}. The run didn't start.` : `The file lists file ${path} ${message}. The run didn't start.`,
|
|
641
|
-
next: [
|
|
642
|
-
{
|
|
643
|
-
type: "text",
|
|
644
|
-
text: 'Give --file-lists a JSON file that holds an array with one array of test file paths for each runner sandbox, in order of runner sandbox index, such as [["test/a.test.ts"], ["test/b.test.ts"]].'
|
|
645
|
-
}
|
|
646
|
-
]
|
|
647
|
-
})
|
|
648
|
-
},
|
|
649
|
-
invalidFileLists: {
|
|
650
|
-
exitCode: 2,
|
|
651
|
-
description: "The lists in the file --file-lists names can't be a run's file lists: a list holds no test file, a test file is in two lists or two times in one, or the number of lists differs from --sandboxes. Nothing was minted, acquired, or started.",
|
|
652
|
-
schema: z5.object({
|
|
653
|
-
path: z5.string(),
|
|
654
|
-
problems: z5.array(fileListsProblemSchema)
|
|
655
|
-
}),
|
|
656
|
-
render: ({ path, problems }) => ({
|
|
657
|
-
message: `The file lists in ${path} can't be used. The run didn't start.`,
|
|
658
|
-
rows: [["Problems", problems.map(fileListsProblemText)]],
|
|
659
|
-
next: [
|
|
660
|
-
{
|
|
661
|
-
type: "text",
|
|
662
|
-
text: "Give each runner sandbox a list with at least one test file, name each test file in one list at most, and drop --sandboxes or give it the number of lists."
|
|
663
|
-
}
|
|
664
|
-
]
|
|
665
|
-
})
|
|
666
|
-
},
|
|
667
|
-
fileListsUnlisted: {
|
|
668
|
-
exitCode: 2,
|
|
669
|
-
description: "A list in the file --file-lists names holds a path that the run's own listing of its test files doesn't have. Nothing was minted, acquired, or started.",
|
|
670
|
-
schema: z5.object({
|
|
671
|
-
path: z5.string(),
|
|
672
|
-
files: z5.array(z5.string()),
|
|
673
|
-
listed: z5.number()
|
|
674
|
-
}),
|
|
675
|
-
render: ({ path, files, listed: listed2 }) => ({
|
|
676
|
-
message: `The file lists in ${path} name ${files.length === 1 ? "a path" : `${files.length} paths`} that the run's listing of its ${listed2} test ${listed2 === 1 ? "file" : "files"} doesn't have. The run didn't start.`,
|
|
677
|
-
rows: [["Not listed", [...namedPaths(files)]]],
|
|
678
|
-
next: [
|
|
679
|
-
{
|
|
680
|
-
type: "text",
|
|
681
|
-
text: "Name each test file as the listing does, relative to the project, such as test/a.test.ts, and only test files the run's arguments select. Run the same command with --plan-only --json, and read testFiles."
|
|
682
|
-
}
|
|
683
|
-
]
|
|
684
|
-
})
|
|
685
|
-
}
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
// src/commands/exec/outcomes.ts
|
|
689
|
-
var runnerFailureSchema = z6.union([
|
|
690
|
-
z6.object({
|
|
691
|
-
kind: z6.enum(["snapshot-build-step-failed", "apply-failed", "install-failed", "build-failed"]),
|
|
692
|
-
/** The step's label. */
|
|
693
|
-
label: z6.string(),
|
|
694
|
-
/** Its exit code; null when it ended without one. */
|
|
695
|
-
exitCode: z6.number().nullable(),
|
|
696
|
-
/** Its last 40 output lines. */
|
|
697
|
-
tail: z6.array(z6.string())
|
|
698
|
-
}),
|
|
699
|
-
z6.object({
|
|
700
|
-
kind: z6.literal("sandbox-api-failed"),
|
|
701
|
-
/** The Sandbox call that failed. */
|
|
702
|
-
operation: z6.string(),
|
|
703
|
-
/** The HTTP status the Sandbox API answered; null when it answered none. */
|
|
704
|
-
status: z6.number().nullable(),
|
|
705
|
-
message: z6.string()
|
|
706
|
-
}),
|
|
707
|
-
z6.object({
|
|
708
|
-
kind: z6.literal("checkout-failed"),
|
|
709
|
-
/** What git or tar said. */
|
|
710
|
-
message: z6.string(),
|
|
711
|
-
/** The failed command; null when there was none. */
|
|
712
|
-
command: z6.string().nullable()
|
|
713
|
-
}),
|
|
714
|
-
z6.object({ kind: z6.literal("credential-claims-missing"), team: z6.string(), project: z6.string() }),
|
|
715
|
-
z6.object({
|
|
716
|
-
kind: z6.literal("network-policy-failed"),
|
|
717
|
-
/** The write that failed: the one that puts credentials in place, or the one that removes them. */
|
|
718
|
-
operation: z6.enum(["inject", "remove"]),
|
|
719
|
-
/** Where the write was: around the recipe's snapshot steps or its run steps and their credentials, before a runner snapshot is saved, or as the command starts, with the credentials its resources give it beside the recipe's. */
|
|
720
|
-
around: z6.enum(["snapshot-steps", "run-steps", "snapshot-save", "command"]),
|
|
721
|
-
/** `api` when the Sandbox API refused or failed, `timed-out` when it didn't answer in time. */
|
|
722
|
-
reason: z6.enum(["api", "timed-out"]),
|
|
723
|
-
/** The HTTP status the Sandbox API answered; null when it answered none. */
|
|
724
|
-
status: z6.number().nullable(),
|
|
725
|
-
/** What failed, without any credential's value. */
|
|
726
|
-
message: z6.string()
|
|
727
|
-
})
|
|
728
|
-
]);
|
|
729
|
-
function listed(names) {
|
|
730
|
-
if (names.length <= 1) return names.join("");
|
|
731
|
-
return `${names.slice(0, -1).join(", ")} and ${names.at(-1) ?? ""}`;
|
|
732
|
-
}
|
|
733
|
-
function renderInvalidSecretVariables(key, rowLabel, variables, minLength, configFile) {
|
|
734
|
-
const named = (problem) => variables.filter((variable) => variable.problem === problem).map(({ name }) => name);
|
|
735
|
-
const [missing, multiline, short2] = [named("missing"), named("multiline"), named("short")];
|
|
736
|
-
return {
|
|
737
|
-
message: `${key}${configFile === null ? "" : ` in ${configFile}`} names ${variables.length === 1 ? "a variable" : "variables"} storm can't use. The run didn't start.`,
|
|
738
|
-
rows: [
|
|
739
|
-
[
|
|
740
|
-
rowLabel,
|
|
741
|
-
variables.map(
|
|
742
|
-
({ name, problem }) => problem === "missing" ? `${name} is not set` : problem === "multiline" ? `${name} holds a carriage return or a line feed` : `${name} holds fewer than ${minLength} characters`
|
|
743
|
-
)
|
|
744
|
-
]
|
|
745
|
-
],
|
|
746
|
-
next: [
|
|
747
|
-
{
|
|
748
|
-
type: "text",
|
|
749
|
-
text: [
|
|
750
|
-
...missing.length === 0 ? [] : [`Set ${listed(missing)} in this machine's environment.`],
|
|
751
|
-
...multiline.length === 0 ? [] : [
|
|
752
|
-
`Set ${listed(multiline)} to a value on one line: storm hides each value in output a line at a time, and doesn't trim one.`
|
|
753
|
-
],
|
|
754
|
-
...short2.length === 0 ? [] : [`Set ${listed(short2)} to the whole secret.`]
|
|
755
|
-
].join(" ")
|
|
756
|
-
},
|
|
757
|
-
{
|
|
758
|
-
type: "text",
|
|
759
|
-
text: "Or run on the launch machine with runner: launchMachine() (or --runner launch-machine for storm exec), which reads none of these variables."
|
|
760
|
-
}
|
|
761
|
-
]
|
|
762
|
-
};
|
|
763
|
-
}
|
|
764
|
-
function stepEnded(exitCode) {
|
|
765
|
-
return exitCode === null ? "ended without an exit code" : `exited ${exitCode}`;
|
|
766
|
-
}
|
|
767
|
-
function runnerFailureText(failure) {
|
|
768
|
-
switch (failure.kind) {
|
|
769
|
-
case "snapshot-build-step-failed":
|
|
770
|
-
return {
|
|
771
|
-
message: `The runner snapshot build's step "${failure.label}" ${stepEnded(failure.exitCode)}. The command didn't run.`,
|
|
772
|
-
next: "Fix the step in the runner recipe, then retry. A failed build records no runner snapshot."
|
|
773
|
-
};
|
|
774
|
-
case "apply-failed":
|
|
775
|
-
return {
|
|
776
|
-
message: `Couldn't apply your changes in the runner sandbox: "${failure.label}" ${stepEnded(failure.exitCode)}. The command didn't run.`,
|
|
777
|
-
next: "Check the output for the file that didn't apply, then retry."
|
|
778
|
-
};
|
|
779
|
-
case "install-failed":
|
|
780
|
-
return {
|
|
781
|
-
message: `The runner's install, "${failure.label}", ${stepEnded(failure.exitCode)}. The command didn't run.`,
|
|
782
|
-
next: "Fix run.install in the runner recipe, or what it installs, then retry."
|
|
783
|
-
};
|
|
784
|
-
case "build-failed":
|
|
785
|
-
return {
|
|
786
|
-
message: `The runner's build, "${failure.label}", ${stepEnded(failure.exitCode)}. The command didn't run.`,
|
|
787
|
-
next: "Fix the build, or run.build in the runner recipe, then retry."
|
|
788
|
-
};
|
|
789
|
-
case "sandbox-api-failed":
|
|
790
|
-
return {
|
|
791
|
-
message: `A Vercel Sandbox call failed (${failure.operation}${failure.status === null ? "" : `, HTTP ${failure.status}`}): ${failure.message}. ${failure.operation === "run-command" ? "The command's outcome is unknown." : "The command didn't run."}`,
|
|
792
|
-
next: "Retry; if it keeps failing, check the Vercel Sandbox status and the project's Sandbox access."
|
|
793
|
-
};
|
|
794
|
-
case "checkout-failed":
|
|
795
|
-
return {
|
|
796
|
-
message: `git or tar failed on this machine: ${failure.message}. The command didn't run.`,
|
|
797
|
-
next: "Fix the checkout, then retry."
|
|
798
|
-
};
|
|
799
|
-
case "network-policy-failed": {
|
|
800
|
-
const detail = failure.status === null ? failure.message : `HTTP ${failure.status}: ${failure.message}`;
|
|
801
|
-
const next = "Retry; if it keeps failing, check the Vercel Sandbox status and the project's Sandbox access.";
|
|
802
|
-
if (failure.around === "command")
|
|
803
|
-
return {
|
|
804
|
-
message: `Couldn't give the command the credentials its resources give it, beside the recipe's: writing the runner sandbox's network policy failed (${detail}). The command didn't run.`,
|
|
805
|
-
next
|
|
806
|
-
};
|
|
807
|
-
if (failure.operation === "remove")
|
|
808
|
-
return {
|
|
809
|
-
message: `Couldn't remove the recipe's credentials from the sandbox's network policy before saving the runner snapshot (${detail}). storm stops and deletes the sandbox, and keeps neither it nor a runner snapshot of it. The command didn't run.`,
|
|
810
|
-
next
|
|
811
|
-
};
|
|
812
|
-
const steps = failure.around === "snapshot-steps" ? "the snapshot build's toolchain and prebuild steps" : "the install and build steps";
|
|
813
|
-
return {
|
|
814
|
-
message: `Couldn't give ${steps} the recipe's credentials: writing the sandbox's network policy failed (${detail}). None of those steps ran, and the command didn't run.`,
|
|
815
|
-
next
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
case "credential-claims-missing":
|
|
819
|
-
return {
|
|
820
|
-
message: `The credential minted for project ${failure.project} on team ${failure.team} names no team and project ids (its owner_id and project_id claims), so the runner sandbox can't use it. The command didn't run.`,
|
|
821
|
-
next: "Mint for a Vercel project whose development OIDC tokens carry owner_id and project_id, then retry."
|
|
822
|
-
};
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
var ranSchema = z6.object({
|
|
826
|
-
/** storm's version. */
|
|
827
|
-
version: z6.string(),
|
|
828
|
-
/** The git commit storm was built from, as its version line shows it (`3f2a9c1b7d4e`, `-dirty` appended when built from a tree with uncommitted changes); null when unknown. */
|
|
829
|
-
commit: z6.string().nullable(),
|
|
830
|
-
/** The config file the run's settings came from (its absolute path); null when none applied. */
|
|
831
|
-
configFile: z6.string().nullable(),
|
|
832
|
-
/**
|
|
833
|
-
* What each acquired resource instance that reports something says of itself, keyed by resource key: its
|
|
834
|
-
* definition's name (`definition`), its facts (`facts`, what its acquire answered, unknown to the schema, or null
|
|
835
|
-
* when it answered none) and the warnings its acquire reported (`warnings`).
|
|
836
|
-
*/
|
|
837
|
-
resources: DEFINITION_SET.reports.ranSchema,
|
|
838
|
-
/**
|
|
839
|
-
* What the run's cleanup left: the runner sandbox it kept running and the runner's sandboxes it couldn't stop or
|
|
840
|
-
* delete (`runner`, null without a runner sandbox), and what releasing each of its resource instances couldn't do,
|
|
841
|
-
* its warnings, keyed by resource key, each with its definition's name (`resources`, `{}` when it took none).
|
|
842
|
-
*/
|
|
843
|
-
cleanup: RUN_CLEANUP.schema,
|
|
844
|
-
/**
|
|
845
|
-
* How the command ended: its exit code, or the signal that ended it; both null for a command in the runner sandbox
|
|
846
|
-
* that ended without an exit code.
|
|
847
|
-
*/
|
|
848
|
-
command: z6.object({ exitCode: z6.number().nullable(), signal: z6.string().nullable() }),
|
|
849
|
-
/** The runner sandbox the command ran in; null without one. */
|
|
850
|
-
runner: z6.object({
|
|
851
|
-
/** The runner snapshot it started from. */
|
|
852
|
-
snapshotId: z6.string(),
|
|
853
|
-
/** The runner snapshot's base, a full SHA: the commit it was built at. */
|
|
854
|
-
base: z6.string(),
|
|
855
|
-
/** How many commits HEAD has that the snapshot's base lacks, 0 for a snapshot built at HEAD's commit. */
|
|
856
|
-
builtBehind: z6.number(),
|
|
857
|
-
/** How many bytes of changes the run uploaded on top of the snapshot's base. */
|
|
858
|
-
uploadBytes: z6.number(),
|
|
859
|
-
/** Whether this run built the runner snapshot. */
|
|
860
|
-
built: z6.boolean(),
|
|
861
|
-
vcpus: z6.number(),
|
|
862
|
-
region: z6.string(),
|
|
863
|
-
runtime: z6.string(),
|
|
864
|
-
/** How long the build step took, in milliseconds. */
|
|
865
|
-
buildMs: z6.number()
|
|
866
|
-
}).nullable(),
|
|
867
|
-
/** The run's waterfall, as the run directory's timeline.json holds it: each lane's label, span and steps in milliseconds since the run started, how they ended, idle time, and the critical path. */
|
|
868
|
-
timeline: timelineSchema,
|
|
869
|
-
/** The run's run directory's run id, which `storm runs show` takes; null when the run couldn't make one. */
|
|
870
|
-
runId: z6.string().nullable()
|
|
871
|
-
});
|
|
872
|
-
var RAN_DESCRIPTION = "The command ran and ended. storm exits with its code, or 128 + n when signal n ended it, whatever this result's exit code.";
|
|
873
|
-
function renderRan(ran, noFinal) {
|
|
874
|
-
const noFinalContent = noFinal === void 0 ? { warnings: [], next: [] } : noFinalResultsContent(noFinal.noFinalTestResults, noFinal.hints);
|
|
875
|
-
const warnings = [
|
|
876
|
-
...DEFINITION_SET.reports.ranWarnings(ran.resources),
|
|
877
|
-
...ran.runner !== null && ran.command.exitCode === null && ran.command.signal === null ? [
|
|
878
|
-
{
|
|
879
|
-
reason: "sandboxed_no_exit_code",
|
|
880
|
-
message: "The command ended in the runner sandbox without an exit code, so storm exits 1."
|
|
881
|
-
}
|
|
882
|
-
] : [],
|
|
883
|
-
...runnerCleanupWarnings(ran.cleanup.runner),
|
|
884
|
-
...DEFINITION_SET.reports.cleanupWarnings(ran.cleanup.resources),
|
|
885
|
-
...noFinalContent.warnings
|
|
886
|
-
];
|
|
887
|
-
const kept = ran.cleanup.runner?.kept ?? null;
|
|
888
|
-
return renderOutcome({
|
|
889
|
-
...kept === null ? {} : { message: keptText(kept) },
|
|
890
|
-
...warnings.length === 0 ? {} : { warnings },
|
|
891
|
-
...noFinalContent.next.length === 0 ? {} : { next: [...noFinalContent.next] }
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
var runErrors = defineErrors({
|
|
895
|
-
conflictingOptions: {
|
|
896
|
-
exitCode: 2,
|
|
897
|
-
description: "A run flag doesn't fit the effective runner: --show-output and --keep-sandbox fit the Vercel Sandbox runner, and --credential github-actions fits the launch machine runner.",
|
|
898
|
-
schema: z6.object({
|
|
899
|
-
/** Each conflicting flag, as typed, and why it doesn't fit. */
|
|
900
|
-
conflicts: z6.array(z6.object({ flag: z6.string(), message: z6.string() })),
|
|
901
|
-
/** The effective runner kind for the run: `launch-machine` or `vercel-sandbox`. */
|
|
902
|
-
runner: z6.enum(["launch-machine", "vercel-sandbox"]),
|
|
903
|
-
/** The selected suite's name, or null when no suite was selected. */
|
|
904
|
-
suite: z6.string().nullable(),
|
|
905
|
-
/** The config file that applied; null when none did. */
|
|
906
|
-
configFile: z6.string().nullable()
|
|
907
|
-
}),
|
|
908
|
-
render: ({ conflicts, runner, suite }) => ({
|
|
909
|
-
message: conflicts.map(({ message }) => message).join(" "),
|
|
910
|
-
rows: [
|
|
911
|
-
["Conflicts", conflicts.map(({ flag }) => flag)],
|
|
912
|
-
["Runner", runner],
|
|
913
|
-
...suite === null ? [] : [["Suite", suite]]
|
|
914
|
-
],
|
|
915
|
-
next: [
|
|
916
|
-
{
|
|
917
|
-
type: "text",
|
|
918
|
-
text: runner === "launch-machine" ? `Drop ${listed(conflicts.map(({ flag }) => flag))}, or run with a vercelSandbox({ \u2026 }) runner.` : `Drop ${listed(conflicts.map(({ flag }) => flag))}, or run on the launch machine with launchMachine() (or --runner launch-machine for storm exec).`
|
|
919
|
-
}
|
|
920
|
-
]
|
|
921
|
-
})
|
|
922
|
-
},
|
|
923
|
-
credentialUnused: {
|
|
924
|
-
exitCode: 2,
|
|
925
|
-
description: "--credential was given to a run with no resource that takes a credential.",
|
|
926
|
-
schema: z6.object({
|
|
927
|
-
/** The flags given that none of the run's resources takes, as typed, such as --credential. */
|
|
928
|
-
flags: z6.array(z6.string()),
|
|
929
|
-
/** The config file that applied; null when none did. */
|
|
930
|
-
configFile: z6.string().nullable()
|
|
931
|
-
}),
|
|
932
|
-
render: ({ flags }) => ({
|
|
933
|
-
message: `${flags.join(", ")} ${flags.length === 1 ? "applies" : "apply"} only to a run with a resource that takes a credential, and this run has none.`,
|
|
934
|
-
next: [
|
|
935
|
-
{
|
|
936
|
-
type: "text",
|
|
937
|
-
text: `Drop ${flags.join(" and ")}, or give the run a resource that takes a credential, in storm.config.ts or on the command line.`
|
|
938
|
-
}
|
|
939
|
-
]
|
|
940
|
-
})
|
|
941
|
-
},
|
|
942
|
-
resourceNeedsRunnerSandbox: {
|
|
943
|
-
exitCode: 2,
|
|
944
|
-
description: "A run on the launch machine uses a resource that needs a runner sandbox, such as one that gives the command a sandbox credential the runner sandbox's firewall adds, so the run didn't start: it minted, acquired, and started nothing.",
|
|
945
|
-
schema: z6.object({
|
|
946
|
-
/** The keys of the resources that need a runner sandbox, as storm.config.ts names them, in the run's order. */
|
|
947
|
-
resources: z6.array(z6.string()),
|
|
948
|
-
/** The config file that applied; null when none did. */
|
|
949
|
-
configFile: z6.string().nullable()
|
|
950
|
-
}),
|
|
951
|
-
render: ({ resources }) => ({
|
|
952
|
-
message: `${listed(resources.map((key) => `resources.${key}`))} ${resources.length === 1 ? "needs" : "need"} a runner sandbox, and this run uses the launch machine runner, with no firewall to add the sandbox credentials ${resources.length === 1 ? "it gives" : "they give"} the command. The run didn't start.`,
|
|
953
|
-
next: [
|
|
954
|
-
{
|
|
955
|
-
type: "text",
|
|
956
|
-
text: "Use runner: vercelSandbox({ \u2026 }) in storm.config.ts (without --runner launch-machine), or run without the resource."
|
|
957
|
-
}
|
|
958
|
-
]
|
|
959
|
-
})
|
|
960
|
-
},
|
|
961
|
-
missingRunner: {
|
|
962
|
-
exitCode: 2,
|
|
963
|
-
description: "No runner is declared: neither storm.config.ts (nor the selected suite) declares runner with vercelSandbox({ \u2026 }) or launchMachine(), and --runner launch-machine wasn't passed.",
|
|
964
|
-
schema: z6.object({
|
|
965
|
-
/** The config file that applied; null when none did. */
|
|
966
|
-
configFile: z6.string().nullable()
|
|
967
|
-
}),
|
|
968
|
-
render: ({ configFile }) => ({
|
|
969
|
-
message: configFile === null ? `No runner is declared, and no ${CONFIG_FILE_NAMES_TEXT} applies.` : `No runner is declared in ${configFile}.`,
|
|
970
|
-
next: [
|
|
971
|
-
{
|
|
972
|
-
type: "text",
|
|
973
|
-
text: "Add runner: vercelSandbox({ \u2026 }) or runner: launchMachine() to storm.config.ts (or to a suite under suites)."
|
|
974
|
-
},
|
|
975
|
-
{
|
|
976
|
-
type: "text",
|
|
977
|
-
text: "Or, for storm exec, pass --runner launch-machine to run on the launch machine."
|
|
978
|
-
}
|
|
979
|
-
]
|
|
980
|
-
})
|
|
981
|
-
},
|
|
982
|
-
credentialsInvalid: {
|
|
983
|
-
exitCode: 2,
|
|
984
|
-
description: `With the Vercel Sandbox runner, launcher environment variables named by the runner recipe's credentials key (source: { kind: "env", name }) can't be used, so the run didn't start: it minted, acquired, and created nothing. Each variable has one problem, the first of: missing, unset or empty; multiline, its value holds a carriage return or a line feed, which line-by-line output would split past storm's redaction; short, its value holds fewer than 8 characters, and storm shows each value as <token> wherever it appears in what it prints and writes, so a value that short would hide ordinary output.`,
|
|
985
|
-
schema: z6.object({
|
|
986
|
-
/** Each variable storm can't use and why, once, in the order the recipe first names it. */
|
|
987
|
-
variables: z6.array(z6.object({ name: z6.string(), problem: z6.enum(["missing", "multiline", "short"]) })),
|
|
988
|
-
/** The fewest characters a credential's value may have. */
|
|
989
|
-
minLength: z6.number(),
|
|
990
|
-
/** The config file that gave the runner recipe. */
|
|
991
|
-
configFile: z6.string().nullable()
|
|
992
|
-
}),
|
|
993
|
-
render: ({ variables, minLength, configFile }) => renderInvalidSecretVariables("runner.credentials", "Credentials", variables, minLength, configFile)
|
|
994
|
-
},
|
|
995
|
-
keepSandboxUnsafeSecretEnvVars: {
|
|
996
|
-
exitCode: 2,
|
|
997
|
-
description: "With the Vercel Sandbox runner, --keep-sandbox asked to keep the runner sandbox for a recipe whose unsafeSecretEnvVars passes secrets into the command's environment, so the run didn't start: it minted, acquired, and created nothing. Anyone who can update the Vercel project can connect to a kept runner sandbox and read what the command wrote.",
|
|
998
|
-
schema: z6.object({
|
|
999
|
-
/** The environment variable names the recipe's unsafeSecretEnvVars exposes to the command, in the recipe's order. */
|
|
1000
|
-
variables: z6.array(z6.string()),
|
|
1001
|
-
/** The config file that gave the runner recipe. */
|
|
1002
|
-
configFile: z6.string().nullable()
|
|
1003
|
-
}),
|
|
1004
|
-
render: ({ variables, configFile }) => ({
|
|
1005
|
-
message: `Can't keep the runner sandbox when runner.unsafeSecretEnvVars${configFile === null ? "" : ` in ${configFile}`} is set (${listed(variables)}). Anyone who can update the Vercel project can connect to a kept runner sandbox and read what the command wrote. The run didn't start.`,
|
|
1006
|
-
next: [
|
|
1007
|
-
{
|
|
1008
|
-
type: "text",
|
|
1009
|
-
text: "Drop --keep-sandbox, or pass --keep-sandbox 0, so the runner sandbox stops and deletes."
|
|
1010
|
-
},
|
|
1011
|
-
{
|
|
1012
|
-
type: "text",
|
|
1013
|
-
text: "Or, when the secret travels as an HTTPS header, declare it under runner.credentials (a sandbox credential) instead of runner.unsafeSecretEnvVars."
|
|
1014
|
-
}
|
|
1015
|
-
]
|
|
1016
|
-
})
|
|
1017
|
-
},
|
|
1018
|
-
unsafeSecretEnvVarsInvalid: {
|
|
1019
|
-
exitCode: 2,
|
|
1020
|
-
description: `With the Vercel Sandbox runner, launcher environment variables named by the runner recipe's unsafeSecretEnvVars key (source: { kind: "env", name }) can't be used, so the run didn't start: it minted, acquired, and created nothing. Each variable has one problem, the first of: missing, unset or empty; multiline, its value holds a carriage return or a line feed, which line-by-line output would split past storm's redaction; short, its value holds fewer than 8 characters, and storm shows each value as <token> wherever it appears in what it prints and writes, so a value that short would hide ordinary output.`,
|
|
1021
|
-
schema: z6.object({
|
|
1022
|
-
/** Each variable storm can't use and why, once, in the order the recipe first names it. */
|
|
1023
|
-
variables: z6.array(z6.object({ name: z6.string(), problem: z6.enum(["missing", "multiline", "short"]) })),
|
|
1024
|
-
/** The fewest characters an unsafe secret environment variable's value may have. */
|
|
1025
|
-
minLength: z6.number(),
|
|
1026
|
-
/** The config file that gave the runner recipe. */
|
|
1027
|
-
configFile: z6.string().nullable()
|
|
1028
|
-
}),
|
|
1029
|
-
render: ({ variables, minLength, configFile }) => renderInvalidSecretVariables(
|
|
1030
|
-
"runner.unsafeSecretEnvVars",
|
|
1031
|
-
"Unsafe secret environment variables",
|
|
1032
|
-
variables,
|
|
1033
|
-
minLength,
|
|
1034
|
-
configFile
|
|
1035
|
-
)
|
|
1036
|
-
},
|
|
1037
|
-
noBaseRef: {
|
|
1038
|
-
exitCode: 1,
|
|
1039
|
-
description: "With the Vercel Sandbox runner, none of the runner recipe's baseRefs exists locally and shares history with HEAD, so there is no base. storm never fetches.",
|
|
1040
|
-
schema: z6.object({
|
|
1041
|
-
/** Each ref in baseRefs, and why it gave no base. */
|
|
1042
|
-
refs: z6.array(z6.object({ ref: z6.string(), reason: z6.enum(["missing", "unrelated"]) }))
|
|
1043
|
-
}),
|
|
1044
|
-
render: ({ refs }) => ({
|
|
1045
|
-
message: `No base for the runner: none of ${refs.map(({ ref }) => ref).join(", ")} exists locally and shares history with HEAD. The command didn't run.`,
|
|
1046
|
-
rows: [
|
|
1047
|
-
[
|
|
1048
|
-
"Base refs",
|
|
1049
|
-
refs.map(
|
|
1050
|
-
({ ref, reason }) => reason === "missing" ? `${ref}: no such local ref` : `${ref}: shares no history with HEAD`
|
|
1051
|
-
)
|
|
1052
|
-
]
|
|
1053
|
-
],
|
|
1054
|
-
next: [
|
|
1055
|
-
{
|
|
1056
|
-
type: "text",
|
|
1057
|
-
text: refs.some(({ ref }) => ref === "main" || ref === "origin/main") ? "Run git fetch origin main, then retry." : `Fetch or create one of ${refs.map(({ ref }) => ref).join(", ")}, then retry.`
|
|
1058
|
-
}
|
|
1059
|
-
]
|
|
1060
|
-
})
|
|
1061
|
-
},
|
|
1062
|
-
submodulesRefused: {
|
|
1063
|
-
exitCode: 1,
|
|
1064
|
-
description: "With the Vercel Sandbox runner, the checkout has Git submodules, which neither the upload nor the base's files carry.",
|
|
1065
|
-
schema: z6.object({ paths: z6.array(z6.string()) }),
|
|
1066
|
-
render: ({ paths }) => ({
|
|
1067
|
-
message: `The checkout has Git submodules, which the runner can't carry: ${paths.join(", ")}. The command didn't run.`,
|
|
1068
|
-
next: [
|
|
1069
|
-
{
|
|
1070
|
-
type: "text",
|
|
1071
|
-
text: "Run on the launch machine with runner: launchMachine() (or --runner launch-machine for storm exec)."
|
|
1072
|
-
}
|
|
1073
|
-
]
|
|
1074
|
-
})
|
|
1075
|
-
},
|
|
1076
|
-
snapshotGone: {
|
|
1077
|
-
exitCode: 1,
|
|
1078
|
-
description: "With the Vercel Sandbox runner, the cached runner snapshot the run picked was gone (the Sandbox API answered 410), so its cache entry was removed and the command didn't run. The next run picks another runner snapshot or builds one.",
|
|
1079
|
-
schema: z6.object({
|
|
1080
|
-
snapshotId: z6.string(),
|
|
1081
|
-
/** The runner snapshot's base, a full SHA. */
|
|
1082
|
-
base: z6.string(),
|
|
1083
|
-
/** Why its cache entry couldn't be removed; null when it was. */
|
|
1084
|
-
removal: z6.object({ path: z6.string(), message: z6.string() }).nullable(),
|
|
1085
|
-
/** What the run couldn't clean up. */
|
|
1086
|
-
cleanup: RUN_CLEANUP.schema
|
|
1087
|
-
}),
|
|
1088
|
-
render: ({ snapshotId, removal, cleanup }) => {
|
|
1089
|
-
const rows = RUN_CLEANUP.rows(cleanup);
|
|
1090
|
-
return {
|
|
1091
|
-
message: `Runner snapshot ${snapshotId} is gone, before its cache entry said it expires. ${removal === null ? "Removed its cache entry." : `Couldn't remove its cache entry at ${removal.path}: ${removal.message}.`} The command didn't run.`,
|
|
1092
|
-
...rows.length === 0 ? {} : { rows },
|
|
1093
|
-
next: [
|
|
1094
|
-
{
|
|
1095
|
-
type: "text",
|
|
1096
|
-
text: removal === null ? "Run again: the next run picks another runner snapshot or builds one." : `Remove ${removal.path}, then run again.`
|
|
1097
|
-
}
|
|
1098
|
-
]
|
|
1099
|
-
};
|
|
1100
|
-
}
|
|
1101
|
-
},
|
|
1102
|
-
runnerFailed: {
|
|
1103
|
-
exitCode: 1,
|
|
1104
|
-
description: "With the Vercel Sandbox runner, the runner couldn't run the command: a snapshot build step, applying the changes, the install, or the build failed (with the step's last 40 output lines), a Vercel Sandbox call failed, a network policy write that puts the recipe steps' credentials in place or removes them failed, git or tar failed on this machine, or the credential names no team and project ids.",
|
|
1105
|
-
schema: z6.object({
|
|
1106
|
-
failure: runnerFailureSchema,
|
|
1107
|
-
/** What the run couldn't clean up; its `runner` is null when the run failed before it started a sandbox. */
|
|
1108
|
-
cleanup: RUN_CLEANUP.schema
|
|
1109
|
-
}),
|
|
1110
|
-
render: ({ failure, cleanup }) => {
|
|
1111
|
-
const { message, next } = runnerFailureText(failure);
|
|
1112
|
-
const rows = [
|
|
1113
|
-
..."tail" in failure && failure.tail.length > 0 ? [["Last output", failure.tail]] : [],
|
|
1114
|
-
...failure.kind === "checkout-failed" && failure.command !== null ? [["Command", failure.command]] : [],
|
|
1115
|
-
...RUN_CLEANUP.rows(cleanup)
|
|
1116
|
-
];
|
|
1117
|
-
return { message, ...rows.length === 0 ? {} : { rows }, next: [{ type: "text", text: next }] };
|
|
1118
|
-
}
|
|
1119
|
-
},
|
|
1120
|
-
spawnFailed: {
|
|
1121
|
-
exitCode: 1,
|
|
1122
|
-
description: "The command couldn't start.",
|
|
1123
|
-
schema: z6.object({
|
|
1124
|
-
/** The command's first argument: what storm tried to run. */
|
|
1125
|
-
executable: z6.string(),
|
|
1126
|
-
/** What the OS said. */
|
|
1127
|
-
message: z6.string(),
|
|
1128
|
-
/**
|
|
1129
|
-
* What the run couldn't clean up; its `runner` is null, since only a run without a runner sandbox spawns its
|
|
1130
|
-
* command here.
|
|
1131
|
-
*/
|
|
1132
|
-
cleanup: RUN_CLEANUP.schema
|
|
1133
|
-
}),
|
|
1134
|
-
render: ({ executable, message, cleanup }) => {
|
|
1135
|
-
const rows = RUN_CLEANUP.rows(cleanup);
|
|
1136
|
-
return {
|
|
1137
|
-
message: `Couldn't start the command ${executable}: ${message}`,
|
|
1138
|
-
...rows.length === 0 ? {} : { rows },
|
|
1139
|
-
next: [
|
|
1140
|
-
{ type: "text", text: "Check the command after --; it runs with no shell, as the argument list given." }
|
|
1141
|
-
]
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
});
|
|
1146
|
-
var RUN_ERRORS = {
|
|
1147
|
-
...configErrors,
|
|
1148
|
-
...credentialErrors,
|
|
1149
|
-
// A resource's refusal, before the run starts or while it acquires.
|
|
1150
|
-
...resourceRefusalErrors,
|
|
1151
|
-
...mintFailedErrors,
|
|
1152
|
-
...runErrors
|
|
1153
|
-
};
|
|
1154
|
-
var outcomes = defineOutcomes({
|
|
1155
|
-
results: {
|
|
1156
|
-
ran: { schema: ranSchema, description: RAN_DESCRIPTION, render: (ran) => renderRan(ran) },
|
|
1157
|
-
sandboxesRan: {
|
|
1158
|
-
schema: sandboxesRanSchema,
|
|
1159
|
-
description: SANDBOXES_RAN_DESCRIPTION,
|
|
1160
|
-
render: (ran) => renderSandboxesRan(ran)
|
|
1161
|
-
},
|
|
1162
|
-
planned: { schema: plannedSchema, description: PLANNED_DESCRIPTION, render: renderPlanned }
|
|
1163
|
-
},
|
|
1164
|
-
errors: { ...RUN_ERRORS, ...sandboxesErrors }
|
|
1165
|
-
});
|
|
1166
|
-
|
|
1167
|
-
// src/commands/exec/progress.ts
|
|
1168
|
-
function lineProgress(write, options = { github: false }) {
|
|
1169
|
-
let failed = false;
|
|
1170
|
-
const render = plainRenderer(options);
|
|
1171
|
-
return {
|
|
1172
|
-
observe: async (timed) => {
|
|
1173
|
-
for (const line of render(timed)) {
|
|
1174
|
-
if (failed) return;
|
|
1175
|
-
try {
|
|
1176
|
-
await write(line);
|
|
1177
|
-
} catch {
|
|
1178
|
-
failed = true;
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
};
|
|
1183
|
-
}
|
|
1184
|
-
function plainRenderer(options) {
|
|
1185
|
-
const state = {
|
|
1186
|
-
origin: void 0,
|
|
1187
|
-
resourceLanes: [],
|
|
1188
|
-
instances: [],
|
|
1189
|
-
mintStartedAt: void 0,
|
|
1190
|
-
lanesStartedAt: void 0,
|
|
1191
|
-
readyAt: { runner: void 0, resources: {} },
|
|
1192
|
-
cleanupStartedAt: void 0,
|
|
1193
|
-
mergeBase: void 0,
|
|
1194
|
-
folded: false
|
|
1195
|
-
};
|
|
1196
|
-
const resources = DEFINITION_SET.presentations.plain({ verbose: options.verbose === true });
|
|
1197
|
-
return ({ event, at }) => {
|
|
1198
|
-
const now = at.getTime();
|
|
1199
|
-
state.origin ??= now;
|
|
1200
|
-
const origin = state.origin;
|
|
1201
|
-
const line = (lane, text) => progressLine(now - origin, lane, text);
|
|
1202
|
-
if (event.kind === "resource") return resources(event, now).map(({ lane, text }) => line(lane, text));
|
|
1203
|
-
return eventLines(event, now, state, line, options);
|
|
1204
|
-
};
|
|
1205
|
-
}
|
|
1206
|
-
function progressLine(elapsedMs, lane, text) {
|
|
1207
|
-
return `[+${secondsText(secondsOf(elapsedMs))}] ${lane.padEnd(LANE_WIDTH)} ${text}`;
|
|
1208
|
-
}
|
|
1209
|
-
var LANE_WIDTH = Math.max(
|
|
1210
|
-
...[
|
|
1211
|
-
"run",
|
|
1212
|
-
"mint",
|
|
1213
|
-
"runner",
|
|
1214
|
-
"command",
|
|
1215
|
-
"cleanup",
|
|
1216
|
-
...DEFINITION_SET.presentations.laneKinds.map(({ lane }) => lane)
|
|
1217
|
-
].map((lane) => lane.length)
|
|
1218
|
-
);
|
|
1219
|
-
function eventLines(event, now, state, line, options) {
|
|
1220
|
-
const since = (start) => seconds(now - (start ?? now));
|
|
1221
|
-
switch (event.kind) {
|
|
1222
|
-
case "started":
|
|
1223
|
-
state.resourceLanes = event.resources.flatMap(
|
|
1224
|
-
({ resource, lane }) => lane === null ? [] : [{ lane, resource }]
|
|
1225
|
-
);
|
|
1226
|
-
state.instances = event.resources;
|
|
1227
|
-
return [
|
|
1228
|
-
line("run", `storm ${versionText(event.version, event.commit)}`),
|
|
1229
|
-
...event.configFile === null ? [] : [line("run", `config ${event.configFile}`)]
|
|
1230
|
-
];
|
|
1231
|
-
case "resource-skipped":
|
|
1232
|
-
return [line("run", skippedText(event))];
|
|
1233
|
-
// An acquired resource says what it holds in its acquire's `announce`, the progress event that follows.
|
|
1234
|
-
case "resource-acquired":
|
|
1235
|
-
return [];
|
|
1236
|
-
// A line a resource instance reported, in the run's lane or the cleanup's, and a warning, marked as one.
|
|
1237
|
-
case "resource-notice":
|
|
1238
|
-
return [line(event.lane, event.text)];
|
|
1239
|
-
case "resource-warning":
|
|
1240
|
-
return [line(event.lane, resourceWarningText(event))];
|
|
1241
|
-
case "minting":
|
|
1242
|
-
state.mintStartedAt = now;
|
|
1243
|
-
return [line("mint", `credential for ${mintTargetText(event.target)}\u2026`)];
|
|
1244
|
-
case "minted":
|
|
1245
|
-
return [
|
|
1246
|
-
line(
|
|
1247
|
-
"mint",
|
|
1248
|
-
`${event.ok ? "credential" : "no credential"} for ${mintTargetText(event.target)} (${since(state.mintStartedAt)})`
|
|
1249
|
-
)
|
|
1250
|
-
];
|
|
1251
|
-
case "requesting-token":
|
|
1252
|
-
return [line("mint", "requesting a GitHub Actions OIDC token\u2026")];
|
|
1253
|
-
case "lanes-started":
|
|
1254
|
-
state.lanesStartedAt = now;
|
|
1255
|
-
return state.resourceLanes.length === 0 ? [] : [line("run", `${[...state.resourceLanes.map(({ lane }) => lane), "runner"].join(" \u2016 ")} start together`)];
|
|
1256
|
-
case "lane-ended": {
|
|
1257
|
-
const ran = since(state.lanesStartedAt ?? state.origin);
|
|
1258
|
-
if (event.outcome !== "ready") return [line(event.lane, `${event.outcome} (${ran})`)];
|
|
1259
|
-
if (state.lanesStartedAt === void 0) return [];
|
|
1260
|
-
if (event.resource === null) state.readyAt.runner = now;
|
|
1261
|
-
else state.readyAt.resources[event.resource] = now;
|
|
1262
|
-
const ready = `ready (${ran})`;
|
|
1263
|
-
if (state.resourceLanes.length === 0) return [line(event.lane, ready)];
|
|
1264
|
-
const others = event.resource === null ? state.resourceLanes : [{ lane: "runner", resource: null }];
|
|
1265
|
-
const readyAt = (lane) => lane.resource === null ? state.readyAt.runner : state.readyAt.resources[lane.resource];
|
|
1266
|
-
const waiting = others.filter((other) => readyAt(other) === void 0).map(({ lane }) => lane);
|
|
1267
|
-
if (waiting.length > 0) return [line(event.lane, `${ready}; waiting for ${waiting.join(", ")}`)];
|
|
1268
|
-
const waited = others.map((other) => `${other.lane} waited ${seconds(now - (readyAt(other) ?? now))}`);
|
|
1269
|
-
return [line(event.lane, `${ready}; ${waited.join(", ")}`)];
|
|
1270
|
-
}
|
|
1271
|
-
// A resource lane's start shows in its first line of its own.
|
|
1272
|
-
case "lane-started":
|
|
1273
|
-
return [];
|
|
1274
|
-
case "command-started":
|
|
1275
|
-
return [line("command", `running ${event.argv.join(" ")}`)];
|
|
1276
|
-
case "command-ended":
|
|
1277
|
-
return [line("command", `${event.command} ${commandEnd(event.outcome)} after ${seconds(event.ms)}`)];
|
|
1278
|
-
case "cleanup-started":
|
|
1279
|
-
state.cleanupStartedAt = now;
|
|
1280
|
-
return [line("cleanup", cleanupText(event.keepMs, releaseText(event.resources, false)))];
|
|
1281
|
-
case "cleanup-finished": {
|
|
1282
|
-
const problems = [
|
|
1283
|
-
...event.notStopped === 0 ? [] : [`${event.notStopped} not stopped`],
|
|
1284
|
-
...event.notDeleted === 0 ? [] : [`${event.notDeleted} not deleted`],
|
|
1285
|
-
...event.resourceWarnings === 0 ? [] : [warningTally(event.resourceWarnings)]
|
|
1286
|
-
];
|
|
1287
|
-
return [
|
|
1288
|
-
line(
|
|
1289
|
-
"cleanup",
|
|
1290
|
-
`${problems.length === 0 ? "done" : `done: ${problems.join(", ")}`} (${since(state.cleanupStartedAt)})`
|
|
1291
|
-
)
|
|
1292
|
-
];
|
|
1293
|
-
}
|
|
1294
|
-
case "runner-prepared":
|
|
1295
|
-
state.mergeBase = event.base;
|
|
1296
|
-
return [
|
|
1297
|
-
line("runner", `merge-base ${short(event.base)}, of HEAD and ${event.baseRef}`),
|
|
1298
|
-
...preparedNoteTexts(event).map((text) => line("runner", text))
|
|
1299
|
-
];
|
|
1300
|
-
// The command's own output carries its tests' results; the summary counts them.
|
|
1301
|
-
// The summary says when the test results may be incomplete.
|
|
1302
|
-
case "test":
|
|
1303
|
-
case "test-event-unreadable":
|
|
1304
|
-
case "test-events-incomplete":
|
|
1305
|
-
case "sandboxes-started":
|
|
1306
|
-
case "sandbox":
|
|
1307
|
-
case "sandbox-ended":
|
|
1308
|
-
return [];
|
|
1309
|
-
case "runner":
|
|
1310
|
-
return runnerLines(event.event, state, line, options);
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
function runnerLines(event, state, line, options) {
|
|
1314
|
-
switch (event.kind) {
|
|
1315
|
-
case "snapshot-reused":
|
|
1316
|
-
return [line("runner", snapshotReusedText(event, state.mergeBase))];
|
|
1317
|
-
case "snapshot-build-started":
|
|
1318
|
-
return snapshotBuildTexts(event).map((text) => line("runner", text));
|
|
1319
|
-
case "runner-sandbox-starting":
|
|
1320
|
-
return [];
|
|
1321
|
-
case "sandbox-started":
|
|
1322
|
-
return [
|
|
1323
|
-
line(
|
|
1324
|
-
"runner",
|
|
1325
|
-
`started the ${event.role === "runner" ? "runner" : "build"} sandbox ${event.name} in ${event.region}, ${event.vcpus} vCPUs (${seconds(event.ms)})`
|
|
1326
|
-
)
|
|
1327
|
-
];
|
|
1328
|
-
case "output-started":
|
|
1329
|
-
return [];
|
|
1330
|
-
case "output-ended":
|
|
1331
|
-
return event.outcome === "finished" ? [] : [...closeFold(state), line("runner", `${event.section} ${event.outcome}`)];
|
|
1332
|
-
case "step-started": {
|
|
1333
|
-
const text = `${event.phase}: ${event.label}`;
|
|
1334
|
-
if (!options.github) return [line("runner", text)];
|
|
1335
|
-
state.folded = true;
|
|
1336
|
-
return [`::group::${line("runner", text)}`];
|
|
1337
|
-
}
|
|
1338
|
-
case "step-output":
|
|
1339
|
-
return [event.line];
|
|
1340
|
-
case "step-finished":
|
|
1341
|
-
return [...closeFold(state), line("runner", `${event.phase}: ${event.label}, done in ${seconds(event.ms)}`)];
|
|
1342
|
-
case "snapshot-saving":
|
|
1343
|
-
return [line("runner", "saving the build sandbox as a runner snapshot\u2026")];
|
|
1344
|
-
case "snapshot-built":
|
|
1345
|
-
return [
|
|
1346
|
-
line(
|
|
1347
|
-
"runner",
|
|
1348
|
-
`built base snapshot ${event.snapshotId} at ${short(event.base)} in ${seconds(event.ms)} (${megabytesText(event.sizeBytes)})`
|
|
1349
|
-
)
|
|
1350
|
-
];
|
|
1351
|
-
case "snapshot-entry-not-written":
|
|
1352
|
-
return [line("runner", cacheWriteFailureText(event.failure))];
|
|
1353
|
-
case "uploading":
|
|
1354
|
-
return [];
|
|
1355
|
-
case "uploaded":
|
|
1356
|
-
return [line("runner", `uploaded your changes, ${megabytesText(event.bytes)} (${seconds(event.ms)})`)];
|
|
1357
|
-
case "command-output-started":
|
|
1358
|
-
return [line("command", `in the runner sandbox ${event.sandbox} (${event.region})`)];
|
|
1359
|
-
case "command-stopped":
|
|
1360
|
-
return [line("command", `${event.command} stopped`)];
|
|
1361
|
-
case "stopping":
|
|
1362
|
-
return [
|
|
1363
|
-
line(
|
|
1364
|
-
"cleanup",
|
|
1365
|
-
`stopping: ${orderText([
|
|
1366
|
-
...event.commandRunning ? ["killing the command"] : [],
|
|
1367
|
-
...sandboxSteps(event.keepMs, stoppingReleaseText(state.instances))
|
|
1368
|
-
])}\u2026`
|
|
1369
|
-
)
|
|
1370
|
-
];
|
|
1371
|
-
case "waiting-for-snapshot":
|
|
1372
|
-
return [
|
|
1373
|
-
line(
|
|
1374
|
-
"cleanup",
|
|
1375
|
-
`waiting up to ${Math.round(event.settleMs / 6e4)} minutes for the runner snapshot still saving\u2026`
|
|
1376
|
-
)
|
|
1377
|
-
];
|
|
1378
|
-
case "sandbox-kept":
|
|
1379
|
-
return [
|
|
1380
|
-
line(
|
|
1381
|
-
"cleanup",
|
|
1382
|
-
`kept the runner sandbox ${event.name} running until ${isoSecondsText(event.stopsAt)}, with no network access`
|
|
1383
|
-
)
|
|
1384
|
-
];
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
function snapshotReusedText(event, mergeBase) {
|
|
1388
|
-
return `snapshot ${event.snapshotId}, ${builtAtText({ base: event.base, builtBehind: event.builtBehind, mergeBase })}`;
|
|
1389
|
-
}
|
|
1390
|
-
function snapshotBuildTexts(event) {
|
|
1391
|
-
const building = `building a base snapshot at ${short(event.base)}`;
|
|
1392
|
-
const tail = `this takes a few minutes: ${event.summary}`;
|
|
1393
|
-
const { why } = event;
|
|
1394
|
-
switch (why.kind) {
|
|
1395
|
-
case "no-snapshot":
|
|
1396
|
-
return [`${building} (${SNAPSHOT_BUILD_REASON_TEXT[why.kind]}); ${tail}`, ...rejectionLines(why.rejected)];
|
|
1397
|
-
case "full":
|
|
1398
|
-
case "base":
|
|
1399
|
-
return [`${building} (${SNAPSHOT_BUILD_REASON_TEXT[why.kind]}); ${tail}`];
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
var SNAPSHOT_BUILD_REASON_TEXT = {
|
|
1403
|
-
"no-snapshot": "no cached snapshot fits",
|
|
1404
|
-
full: "--full",
|
|
1405
|
-
base: "the cache has no base snapshot at that commit"
|
|
1406
|
-
};
|
|
1407
|
-
function stoppingReleaseText(instances) {
|
|
1408
|
-
return releaseText(
|
|
1409
|
-
instances.map(({ resource }) => resource),
|
|
1410
|
-
false
|
|
1411
|
-
);
|
|
1412
|
-
}
|
|
1413
|
-
function closeFold(state) {
|
|
1414
|
-
if (!state.folded) return [];
|
|
1415
|
-
state.folded = false;
|
|
1416
|
-
return ["::endgroup::"];
|
|
1417
|
-
}
|
|
1418
|
-
function cleanupText(keepMs, release) {
|
|
1419
|
-
if (keepMs === null) return release === void 0 ? "nothing to release" : `${release}\u2026`;
|
|
1420
|
-
return `${orderText(sandboxSteps(keepMs, release))}\u2026`;
|
|
1421
|
-
}
|
|
1422
|
-
function sandboxSteps(keepMs, release) {
|
|
1423
|
-
const released = release === void 0 ? [] : [release];
|
|
1424
|
-
if (keepMs > 0)
|
|
1425
|
-
return ["giving the runner sandbox no network access", ...released, `keeping it running ${keepTimeText(keepMs)}`];
|
|
1426
|
-
return release === void 0 ? ["stopping and deleting the runner's sandboxes"] : ["stopping the runner's sandboxes", release, "deleting the sandboxes"];
|
|
1427
|
-
}
|
|
1428
|
-
function commandEnd(outcome) {
|
|
1429
|
-
switch (outcome.kind) {
|
|
1430
|
-
case "exited":
|
|
1431
|
-
return `exited ${outcome.code}`;
|
|
1432
|
-
case "signaled":
|
|
1433
|
-
return `ended on ${outcome.signal}`;
|
|
1434
|
-
case "no-exit-code":
|
|
1435
|
-
return "ended without an exit code";
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
function resourceWarningText(warning) {
|
|
1439
|
-
return `warning: ${warning.message}`;
|
|
1440
|
-
}
|
|
1441
|
-
function skippedText(skipped) {
|
|
1442
|
-
return `no ${skipped.resource}: ${skipped.notice}`;
|
|
1443
|
-
}
|
|
1444
|
-
function preparedNoteTexts(prepared) {
|
|
1445
|
-
return [
|
|
1446
|
-
...prepared.nestedRepositories.length === 0 ? [] : [`leaving out untracked nested Git repositories: ${prepared.nestedRepositories.join(", ")}`],
|
|
1447
|
-
...prepared.notes.map(snapshotCacheNoteText)
|
|
1448
|
-
];
|
|
1449
|
-
}
|
|
1450
|
-
function cacheWriteFailureText(failure) {
|
|
1451
|
-
return `couldn't record the runner snapshot in the cache at ${failure.path}: ${failure.message}; later runs won't reuse it`;
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
// src/commands/exec/run-command.ts
|
|
1455
|
-
import { z as z7 } from "zod";
|
|
1456
|
-
|
|
1457
|
-
// src/forward-sigterm.ts
|
|
1458
|
-
function forwardSigterm(signal) {
|
|
1459
|
-
const terminate = new AbortController();
|
|
1460
|
-
const forward = () => {
|
|
1461
|
-
const reason = signal.reason;
|
|
1462
|
-
if (reason instanceof NodeSignalCancellation && reason.signal === "SIGTERM") terminate.abort(reason);
|
|
1463
|
-
};
|
|
1464
|
-
if (signal.aborted) forward();
|
|
1465
|
-
else signal.addEventListener("abort", forward, { once: true });
|
|
1466
|
-
return { terminate: terminate.signal, release: () => signal.removeEventListener("abort", forward) };
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
// src/shared/job-summary.ts
|
|
1470
|
-
function jobSummaryMarkdown(timeline, extras) {
|
|
1471
|
-
const lines = [`### storm ${extras.command}`, ""];
|
|
1472
|
-
if (timeline.rows.length > 0) {
|
|
1473
|
-
lines.push("| Lane | Start | Duration | Idle | Steps |", "| --- | ---: | ---: | ---: | --- |");
|
|
1474
|
-
for (const row of timeline.rows) lines.push(tableRow(row));
|
|
1475
|
-
lines.push("");
|
|
1476
|
-
}
|
|
1477
|
-
if (timeline.criticalPath.length > 0) {
|
|
1478
|
-
const path = timeline.criticalPath.map((step) => criticalPathStep(step, timeline));
|
|
1479
|
-
lines.push(`Critical path: ${path.join(" \u2192 ")}`, "");
|
|
1480
|
-
}
|
|
1481
|
-
for (const detail of extras.details ?? []) lines.push(`${detail.trim()} `);
|
|
1482
|
-
if ((extras.details ?? []).length > 0) lines.push("");
|
|
1483
|
-
if (extras.logs !== void 0) lines.push(`Run directory: \`${extras.logs}\``, "");
|
|
1484
|
-
return lines.join("\n");
|
|
1485
|
-
}
|
|
1486
|
-
function tableRow(row) {
|
|
1487
|
-
const outcome = row.outcome === "done" ? "" : ` (${row.outcome})`;
|
|
1488
|
-
const steps = row.steps.map((step) => `${step.name} ${seconds(step.endMs - step.startMs)}`).join(" \xB7 ");
|
|
1489
|
-
const idle = row.idleMs > 0 ? seconds(row.idleMs) : "";
|
|
1490
|
-
return `| ${row.label}${outcome} | +${seconds(row.startMs)} | ${seconds(row.endMs - row.startMs)} | ${idle} | ${steps} |`;
|
|
1491
|
-
}
|
|
1492
|
-
function acrossSandboxesJobSummaryMarkdown(records, extras) {
|
|
1493
|
-
const lines = [`### storm ${extras.command}`, ""];
|
|
1494
|
-
const rows = sandboxTableRows(records);
|
|
1495
|
-
lines.push(
|
|
1496
|
-
`| ${SANDBOX_TABLE_HEADER.join(" | ")} |`,
|
|
1497
|
-
`| ${SANDBOX_TABLE_HEADER.map((_, column) => column >= 2 && column <= 4 ? "---:" : "---").join(" | ")} |`,
|
|
1498
|
-
...rows.map((row) => `| ${row.map((cell) => cell.replaceAll("|", "\\|")).join(" | ")} |`),
|
|
1499
|
-
"",
|
|
1500
|
-
sandboxTotalsLine(records),
|
|
1501
|
-
""
|
|
1502
|
-
);
|
|
1503
|
-
for (const detail of extras.details ?? []) lines.push(`${detail.trim()} `);
|
|
1504
|
-
if ((extras.details ?? []).length > 0) lines.push("");
|
|
1505
|
-
if (extras.logs !== void 0) lines.push(`Run directory: \`${extras.logs}\``, "");
|
|
1506
|
-
return lines.join("\n");
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
// src/planning/run-kind-flags.ts
|
|
1510
|
-
function unfitRunFlags(runner, flags) {
|
|
1511
|
-
if (runner === "vercel-sandbox") return flags.credential === "github-actions" ? ["credential"] : [];
|
|
1512
|
-
return [
|
|
1513
|
-
...flags.showOutput ? ["showOutput"] : [],
|
|
1514
|
-
...flags.keepSandbox === void 0 ? [] : ["keepSandbox"],
|
|
1515
|
-
...flags.sandboxes === void 0 ? [] : ["sandboxes"],
|
|
1516
|
-
...flags.fileLists === void 0 ? [] : ["fileLists"]
|
|
1517
|
-
];
|
|
1518
|
-
}
|
|
1519
|
-
function runKindFlagName(flag) {
|
|
1520
|
-
switch (flag) {
|
|
1521
|
-
case "credential":
|
|
1522
|
-
return "--credential github-actions";
|
|
1523
|
-
case "showOutput":
|
|
1524
|
-
return "--show-output";
|
|
1525
|
-
case "keepSandbox":
|
|
1526
|
-
return "--keep-sandbox";
|
|
1527
|
-
case "sandboxes":
|
|
1528
|
-
return "--sandboxes";
|
|
1529
|
-
case "fileLists":
|
|
1530
|
-
return "--file-lists";
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
function runKindFlagMessage(flag) {
|
|
1534
|
-
switch (flag) {
|
|
1535
|
-
case "credential":
|
|
1536
|
-
return "The Vercel Sandbox runner needs a minted Vercel credential, so it can't use --credential github-actions.";
|
|
1537
|
-
case "showOutput":
|
|
1538
|
-
return "--show-output prints the Vercel Sandbox runner's step output, and this run uses the launch machine runner.";
|
|
1539
|
-
case "keepSandbox":
|
|
1540
|
-
return "--keep-sandbox keeps a Vercel Sandbox runner's sandbox, and this run uses the launch machine runner.";
|
|
1541
|
-
case "sandboxes":
|
|
1542
|
-
return "--sandboxes runs the command in several Vercel Sandbox runner sandboxes, and this run uses the launch machine runner.";
|
|
1543
|
-
case "fileLists":
|
|
1544
|
-
return "--file-lists runs each file list in its own Vercel Sandbox runner sandbox, and this run uses the launch machine runner.";
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
// src/commands/exec/plan-run.ts
|
|
1549
|
-
async function planRun(app, lifecycles, request, planCommand, signal) {
|
|
1550
|
-
const file = request.settingsFile;
|
|
1551
|
-
const configFile = file.path;
|
|
1552
|
-
const settings = fileSettings(file, request);
|
|
1553
|
-
const runner = request.runner === "launch-machine" ? { kind: "launch-machine" } : settings.runner?.value;
|
|
1554
|
-
if (runner === void 0) return refused(runErrors.missingRunner({ configFile }));
|
|
1555
|
-
const unfit = unfitRunFlags(runner.kind, request);
|
|
1556
|
-
if (unfit.length > 0) {
|
|
1557
|
-
return refused(
|
|
1558
|
-
runErrors.conflictingOptions({
|
|
1559
|
-
conflicts: unfit.map((flag) => ({ flag: runKindFlagName(flag), message: runKindFlagMessage(flag) })),
|
|
1560
|
-
runner: runner.kind,
|
|
1561
|
-
suite: request.suite,
|
|
1562
|
-
configFile
|
|
1563
|
-
})
|
|
1564
|
-
);
|
|
1565
|
-
}
|
|
1566
|
-
let where;
|
|
1567
|
-
if (runner.kind === "launch-machine") where = { kind: "unsandboxed" };
|
|
1568
|
-
else {
|
|
1569
|
-
if (configFile === null) throw new Error("planRun: the Vercel Sandbox runner comes from a config file");
|
|
1570
|
-
const required = requireTarget(settings.scope, settings.project);
|
|
1571
|
-
if (!required.ok) return required;
|
|
1572
|
-
const { recipe } = runner;
|
|
1573
|
-
const credentials = readCredentials(recipe, app.env);
|
|
1574
|
-
if (!credentials.ok)
|
|
1575
|
-
return refused(
|
|
1576
|
-
runErrors.credentialsInvalid({
|
|
1577
|
-
variables: credentials.variables.map(({ name, problem }) => ({ name, problem })),
|
|
1578
|
-
minLength: SECRET_MIN_LENGTH,
|
|
1579
|
-
configFile
|
|
1580
|
-
})
|
|
1581
|
-
);
|
|
1582
|
-
const keepFlagMinutes = request.keepSandbox === void 0 ? 0 : parseKeepTime(request.keepSandbox) ?? 0;
|
|
1583
|
-
if (recipe.unsafeSecretEnvVars.length > 0 && keepFlagMinutes > 0)
|
|
1584
|
-
return refused(
|
|
1585
|
-
runErrors.keepSandboxUnsafeSecretEnvVars({
|
|
1586
|
-
variables: recipe.unsafeSecretEnvVars.map(({ name }) => name),
|
|
1587
|
-
configFile
|
|
1588
|
-
})
|
|
1589
|
-
);
|
|
1590
|
-
const unsafeSecretEnvVars = readUnsafeSecretEnvVars(recipe, app.env);
|
|
1591
|
-
if (!unsafeSecretEnvVars.ok)
|
|
1592
|
-
return refused(
|
|
1593
|
-
runErrors.unsafeSecretEnvVarsInvalid({
|
|
1594
|
-
variables: unsafeSecretEnvVars.variables.map(({ name, problem }) => ({ name, problem })),
|
|
1595
|
-
minLength: SECRET_MIN_LENGTH,
|
|
1596
|
-
configFile
|
|
1597
|
-
})
|
|
1598
|
-
);
|
|
1599
|
-
where = {
|
|
1600
|
-
kind: "runner",
|
|
1601
|
-
configFile,
|
|
1602
|
-
recipe,
|
|
1603
|
-
target: required.target,
|
|
1604
|
-
credentials: credentials.credentials,
|
|
1605
|
-
unsafeSecretEnvVars: unsafeSecretEnvVars.values,
|
|
1606
|
-
secrets: [...credentials.credentials.map(({ value }) => value), ...Object.values(unsafeSecretEnvVars.values)]
|
|
1607
|
-
};
|
|
1608
|
-
}
|
|
1609
|
-
const merged = settleRunResources(file, request.given);
|
|
1610
|
-
if (!merged.ok) return merged;
|
|
1611
|
-
const command = await planCommand(where, signal, { testPlan: settings.testPlan?.value === true, configFile });
|
|
1612
|
-
if (signal.aborted) return refused(canceledBeforeStart());
|
|
1613
|
-
if (!command.ok) {
|
|
1614
|
-
const secrets = [...where.kind === "runner" ? where.secrets : [], ...lifecycles.secrets(merged.options)];
|
|
1615
|
-
return refused(secrets.length === 0 ? command.refusal : redactStrings(command.refusal, redactor(secrets)));
|
|
1616
|
-
}
|
|
1617
|
-
const run = Object.freeze({
|
|
1618
|
-
testPlan: command.testPlan,
|
|
1619
|
-
sandboxes: command.sandboxes?.sandboxes.length ?? 1
|
|
1620
|
-
});
|
|
1621
|
-
const resolved = merged.plan(run);
|
|
1622
|
-
if (!resolved.ok) return resolved;
|
|
1623
|
-
return {
|
|
1624
|
-
ok: true,
|
|
1625
|
-
configFile,
|
|
1626
|
-
settings,
|
|
1627
|
-
where,
|
|
1628
|
-
argv: command.argv,
|
|
1629
|
-
testPlan: command.testPlan,
|
|
1630
|
-
testFiles: command.testFiles,
|
|
1631
|
-
sandboxes: command.sandboxes,
|
|
1632
|
-
resources: resolved.resources,
|
|
1633
|
-
planOptions: resolved.planned.map(planOption)
|
|
1634
|
-
};
|
|
1635
|
-
}
|
|
1636
|
-
function planOption({ path, value, source }) {
|
|
1637
|
-
return { path, value, from: source };
|
|
1638
|
-
}
|
|
1639
|
-
async function resourcesBeforeRun(lifecycles, plan, request) {
|
|
1640
|
-
const { configFile, resources, settings } = plan;
|
|
1641
|
-
const used = await lifecycles.beforeRun(resources);
|
|
1642
|
-
if (!used.ok) return refused(resourceRefusedBeforeRun(used.resource, used.refusal, configFile));
|
|
1643
|
-
if (request.credential !== void 0 && !used.needsVercelCredential)
|
|
1644
|
-
return refused(runErrors.credentialUnused({ flags: ["--credential"], configFile }));
|
|
1645
|
-
if (plan.where.kind !== "runner" && used.needRunnerSandbox.length > 0)
|
|
1646
|
-
return refused(runErrors.resourceNeedsRunnerSandbox({ resources: [...used.needRunnerSandbox], configFile }));
|
|
1647
|
-
let where;
|
|
1648
|
-
if (plan.where.kind === "runner") where = plan.where;
|
|
1649
|
-
else if (used.needsVercelCredential) {
|
|
1650
|
-
const chosen = settleCredential(request.credential ?? "mint", settings.scope, settings.project);
|
|
1651
|
-
if (!chosen.ok) return chosen;
|
|
1652
|
-
where = { kind: "unsandboxed", credential: chosen.credential };
|
|
1653
|
-
} else where = { kind: "unsandboxed", credential: void 0 };
|
|
1654
|
-
return { ok: true, where, used };
|
|
1655
|
-
}
|
|
1656
|
-
function canceledBeforeStart() {
|
|
1657
|
-
return outcomes.canceled({ changed: "The command didn't run.\nNothing was minted, acquired or started." });
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
// src/commands/exec/live-view.ts
|
|
1661
|
-
var SPINNER = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1662
|
-
var INDENT = " ".repeat(LANE_WIDTH + 5);
|
|
1663
|
-
function laneHead(glyph, lane) {
|
|
1664
|
-
return ` ${glyph} ${lane.padEnd(LANE_WIDTH)} `;
|
|
1665
|
-
}
|
|
1666
|
-
function activePhase(state) {
|
|
1667
|
-
if (state.cleanup !== void 0) return "cleanup";
|
|
1668
|
-
if (state.command !== void 0) return "command";
|
|
1669
|
-
if (state.lanesStartedAt !== void 0 && state.runner !== void 0) return "lanes";
|
|
1670
|
-
if (Object.keys(state.resources).length > 0 && state.runner === void 0) return "resources";
|
|
1671
|
-
if (state.mint !== void 0) return "credential";
|
|
1672
|
-
return void 0;
|
|
1673
|
-
}
|
|
1674
|
-
function instanceLanes(state) {
|
|
1675
|
-
return DEFINITION_SET.presentations.lanes(state.instances ?? []);
|
|
1676
|
-
}
|
|
1677
|
-
function startedLanes(state) {
|
|
1678
|
-
return DEFINITION_SET.presentations.lanes(
|
|
1679
|
-
Object.entries(state.resources).map(([resource, { definition }]) => ({ resource, definition }))
|
|
1680
|
-
);
|
|
1681
|
-
}
|
|
1682
|
-
function headerLine(state, paint2) {
|
|
1683
|
-
const version = state.version === void 0 ? "" : versionText(state.version.version, state.version.commit);
|
|
1684
|
-
const header = [
|
|
1685
|
-
`storm ${version}`.trimEnd(),
|
|
1686
|
-
...state.base === void 0 ? [] : [`merge-base ${short(state.base.sha)} (with ${state.base.ref})`]
|
|
1687
|
-
].join(" \xB7 ");
|
|
1688
|
-
return paint2.strong(header);
|
|
1689
|
-
}
|
|
1690
|
-
function phaseFrame(state, phase, now, width, paint2) {
|
|
1691
|
-
const view = {
|
|
1692
|
-
now,
|
|
1693
|
-
width,
|
|
1694
|
-
paint: paint2,
|
|
1695
|
-
glyph: (status) => statusGlyph(status, now, paint2),
|
|
1696
|
-
// A live row is cut to the width: one that wrapped would take a row the next redraw doesn't erase.
|
|
1697
|
-
row: (left, right) => spread(left, right, width),
|
|
1698
|
-
line: (text) => truncate(text, width)
|
|
1699
|
-
};
|
|
1700
|
-
switch (phase) {
|
|
1701
|
-
case "credential":
|
|
1702
|
-
return state.mint === void 0 ? [] : [credentialLine(state.mint, view)];
|
|
1703
|
-
case "lanes":
|
|
1704
|
-
return lanesFrame(state, view);
|
|
1705
|
-
case "resources":
|
|
1706
|
-
return unsandboxedResourcesFrame(state, view);
|
|
1707
|
-
case "command":
|
|
1708
|
-
return commandFrame(state, view);
|
|
1709
|
-
case "cleanup":
|
|
1710
|
-
return state.cleanup === void 0 ? [] : [cleanupLine(state.cleanup, state.runner, view, false)];
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
function phaseRecord(state, phase, width, paint2) {
|
|
1714
|
-
const view = {
|
|
1715
|
-
now: void 0,
|
|
1716
|
-
width,
|
|
1717
|
-
paint: paint2,
|
|
1718
|
-
glyph: (status) => statusGlyph(status === "running" ? "stopped" : status, 0, paint2),
|
|
1719
|
-
row: (left, right) => visibleLength(left) + visibleLength(right) + 1 <= width ? spread(left, right, width) : `${left}${right === "" ? "" : ` ${right}`}`,
|
|
1720
|
-
line: (text) => text
|
|
1721
|
-
};
|
|
1722
|
-
switch (phase) {
|
|
1723
|
-
case "credential":
|
|
1724
|
-
return state.mint === void 0 ? [] : [credentialLine(state.mint, view)];
|
|
1725
|
-
case "lanes":
|
|
1726
|
-
return lanesRecord(state, view);
|
|
1727
|
-
case "resources":
|
|
1728
|
-
return unsandboxedResourcesRecord(state, view);
|
|
1729
|
-
case "command":
|
|
1730
|
-
return state.command === void 0 ? [] : [commandLine(state, state.command, view, false)];
|
|
1731
|
-
case "cleanup":
|
|
1732
|
-
return state.cleanup === void 0 ? [] : [cleanupLine(state.cleanup, state.runner, view, true)];
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
function laneDraw(view) {
|
|
1736
|
-
return {
|
|
1737
|
-
now: view.now,
|
|
1738
|
-
paint: view.paint,
|
|
1739
|
-
glyph: view.glyph,
|
|
1740
|
-
line: view.line,
|
|
1741
|
-
elapsed: (from, to) => elapsed(view, from, to),
|
|
1742
|
-
seconds
|
|
1743
|
-
};
|
|
1744
|
-
}
|
|
1745
|
-
function elapsed(view, from, to) {
|
|
1746
|
-
const end = to ?? view.now;
|
|
1747
|
-
return from === void 0 || end === void 0 ? "" : seconds(end - from);
|
|
1748
|
-
}
|
|
1749
|
-
function credentialLine(mint, view) {
|
|
1750
|
-
return view.row(
|
|
1751
|
-
` ${view.glyph(mint.status)} credential ${mintTargetText(mint.target)}`,
|
|
1752
|
-
elapsed(view, mint.startedAt, mint.endedAt)
|
|
1753
|
-
);
|
|
1754
|
-
}
|
|
1755
|
-
function lanesFrame(state, view) {
|
|
1756
|
-
const { runner } = state;
|
|
1757
|
-
if (runner === void 0) return [];
|
|
1758
|
-
const { paint: paint2 } = view;
|
|
1759
|
-
const stopping = (status) => state.stopping && status === "running";
|
|
1760
|
-
const draw = laneDraw(view);
|
|
1761
|
-
const resourceRows = instanceLanes(state).map((lane) => {
|
|
1762
|
-
const live = lane.live(state.resources, draw);
|
|
1763
|
-
if (live === void 0) return view.row(laneHead(view.glyph("running"), lane.lane), "");
|
|
1764
|
-
const { span } = live;
|
|
1765
|
-
const text = stopping(span.status) ? "stopping" : live.detail ?? live.text;
|
|
1766
|
-
const waiting = span.status === "done" && runner.status === "running" && span.endedAt !== void 0 && view.now !== void 0 ? `${paint2.faint(`waiting for runner +${seconds(view.now - span.endedAt)}`)} ` : "";
|
|
1767
|
-
return view.row(
|
|
1768
|
-
`${laneHead(view.glyph(span.status), lane.lane)}${text}`,
|
|
1769
|
-
`${waiting}${elapsed(view, span.startedAt, span.endedAt)}`
|
|
1770
|
-
);
|
|
1771
|
-
});
|
|
1772
|
-
const current = runner.steps.find(({ status }) => status === "running") ?? [...runner.steps].filter((step) => step.status !== "pending" && step.endedAt !== void 0).toSorted((a, b) => (a.endedAt ?? 0) - (b.endedAt ?? 0)).at(-1);
|
|
1773
|
-
const currentText = current === void 0 ? "" : [
|
|
1774
|
-
`${current.name}${stepLabel(current, runner) === "" ? "" : ` \xB7 ${stepLabel(current, runner)}`}`,
|
|
1775
|
-
current.startedAt === current.endedAt ? "" : elapsed(view, current.startedAt, current.endedAt),
|
|
1776
|
-
current.status === "failed" || current.status === "stopped" ? view.glyph(current.status) : ""
|
|
1777
|
-
].filter((part) => part !== "").join(" ");
|
|
1778
|
-
const crumbs = stepsText(
|
|
1779
|
-
runner.steps.filter((step) => step !== current),
|
|
1780
|
-
view,
|
|
1781
|
-
void 0
|
|
1782
|
-
);
|
|
1783
|
-
const runnerText = stopping(runner.status) ? `stopping \xB7 ${currentText}` : currentText;
|
|
1784
|
-
const runnerRow = view.row(
|
|
1785
|
-
`${laneHead(runnerGlyph(runner, view), "runner")}${runnerText}${crumbs === "" ? "" : ` ${paint2.faint(crumbs)}`}`,
|
|
1786
|
-
elapsed(view, runner.startedAt, runner.endedAt)
|
|
1787
|
-
);
|
|
1788
|
-
const running = runner.steps.find(({ status }) => status === "running");
|
|
1789
|
-
const latest = running === void 0 ? void 0 : latestLine(running, runner);
|
|
1790
|
-
const output = activityText(runner) ?? (latest === "" ? void 0 : latest);
|
|
1791
|
-
return [...resourceRows, runnerRow, output === void 0 ? "" : view.line(`${INDENT}${paint2.faint(output)}`)];
|
|
1792
|
-
}
|
|
1793
|
-
function lanesRecord(state, view) {
|
|
1794
|
-
const { runner } = state;
|
|
1795
|
-
const lines = [];
|
|
1796
|
-
const draw = laneDraw(view);
|
|
1797
|
-
for (const lane of startedLanes(state)) {
|
|
1798
|
-
const record = lane.record(state.resources, draw);
|
|
1799
|
-
if (record === void 0) continue;
|
|
1800
|
-
const { span } = record;
|
|
1801
|
-
const waited = span.status === "done" && span.endedAt !== void 0 && runner?.endedAt !== void 0 && runner.endedAt > span.endedAt ? ` \xB7 waited ${seconds(runner.endedAt - span.endedAt)}` : "";
|
|
1802
|
-
lines.push(
|
|
1803
|
-
view.row(
|
|
1804
|
-
`${laneHead(view.glyph(span.status), lane.lane)}${record.text}`,
|
|
1805
|
-
`${elapsed(view, span.startedAt, span.endedAt)}${waited}`
|
|
1806
|
-
),
|
|
1807
|
-
...record.lines
|
|
1808
|
-
);
|
|
1809
|
-
}
|
|
1810
|
-
if (runner !== void 0) {
|
|
1811
|
-
const snapshot = runner.steps.find(({ name }) => name === "snapshot");
|
|
1812
|
-
const parts = [
|
|
1813
|
-
...runner.sandbox === void 0 ? [] : [`${runner.sandbox.name} \xB7 ${runner.sandbox.region} \xB7 ${runner.sandbox.vcpus} vCPU`],
|
|
1814
|
-
...snapshot === void 0 || snapshot.status === "pending" ? [] : [snapshotText(snapshot, runner, state.base?.sha)],
|
|
1815
|
-
...runner.status === "failed" || runner.status === "stopped" ? [runner.status] : []
|
|
1816
|
-
];
|
|
1817
|
-
lines.push(
|
|
1818
|
-
view.row(
|
|
1819
|
-
`${laneHead(runnerGlyph(runner, view), "runner")}${parts.join(" \xB7 ")}`,
|
|
1820
|
-
elapsed(view, runner.startedAt, runner.endedAt)
|
|
1821
|
-
)
|
|
1822
|
-
);
|
|
1823
|
-
const steps = stepsText(runner.steps, view, runner.uploadBytes);
|
|
1824
|
-
if (steps !== "") lines.push(view.line(`${INDENT}${steps}`));
|
|
1825
|
-
}
|
|
1826
|
-
return lines;
|
|
1827
|
-
}
|
|
1828
|
-
function runnerGlyph(runner, view) {
|
|
1829
|
-
return view.glyph(runner.steps.some(({ status }) => status === "failed") ? "failed" : runner.status);
|
|
1830
|
-
}
|
|
1831
|
-
function snapshotText(step, runner, mergeBase) {
|
|
1832
|
-
if (runner.snapshot?.kind === "built") return "snapshot built";
|
|
1833
|
-
if (runner.snapshot?.kind === "reused") {
|
|
1834
|
-
const { base, builtBehind } = runner.snapshot;
|
|
1835
|
-
return `snapshot ${builtAtText({ base, builtBehind, mergeBase })}`;
|
|
1836
|
-
}
|
|
1837
|
-
return `snapshot build ${step.status === "running" ? "stopped" : step.status}`;
|
|
1838
|
-
}
|
|
1839
|
-
function stepLabel(step, runner) {
|
|
1840
|
-
if (step.name === "snapshot") {
|
|
1841
|
-
const { snapshot } = runner;
|
|
1842
|
-
if (snapshot === void 0) return step.label;
|
|
1843
|
-
if (snapshot.kind !== "building") return `${snapshot.id} ${snapshot.kind}`;
|
|
1844
|
-
return step.label === "" ? `building: ${snapshot.summary}` : step.label;
|
|
1845
|
-
}
|
|
1846
|
-
if (step.name === "upload" && runner.uploadBytes !== void 0) return megabytesText(runner.uploadBytes);
|
|
1847
|
-
return step.label;
|
|
1848
|
-
}
|
|
1849
|
-
function latestLine(step, runner) {
|
|
1850
|
-
if (step.latest !== void 0) return step.latest.trim();
|
|
1851
|
-
if (step.name === "snapshot" && step.label === "" && runner.buildSandbox !== void 0)
|
|
1852
|
-
return `build sandbox ${runner.buildSandbox} started`;
|
|
1853
|
-
return void 0;
|
|
1854
|
-
}
|
|
1855
|
-
function activityText(runner) {
|
|
1856
|
-
switch (runner.activity) {
|
|
1857
|
-
case "saving-snapshot":
|
|
1858
|
-
return "saving the build sandbox as a runner snapshot";
|
|
1859
|
-
case "waiting-for-snapshot":
|
|
1860
|
-
return WAITING_FOR_SNAPSHOT;
|
|
1861
|
-
case void 0:
|
|
1862
|
-
return void 0;
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
var WAITING_FOR_SNAPSHOT = "waiting for the runner snapshot still saving";
|
|
1866
|
-
function stepsText(steps, view, uploadBytes) {
|
|
1867
|
-
return steps.filter(
|
|
1868
|
-
(step) => step.status !== "pending" && step.status !== "running" && step.startedAt !== void 0 && step.endedAt !== void 0 && (step.endedAt > step.startedAt || step.status !== "done")
|
|
1869
|
-
).map((step) => {
|
|
1870
|
-
const mark = step.status === "done" ? "" : ` ${view.glyph(step.status)}`;
|
|
1871
|
-
const size = step.name === "upload" && uploadBytes !== void 0 ? ` (${megabytesText(uploadBytes)})` : "";
|
|
1872
|
-
return `${step.name} ${seconds((step.endedAt ?? 0) - (step.startedAt ?? 0))}${size}${mark}`;
|
|
1873
|
-
}).join(" \xB7 ");
|
|
1874
|
-
}
|
|
1875
|
-
function unsandboxedResourcesFrame(state, view) {
|
|
1876
|
-
const { mint } = state;
|
|
1877
|
-
const draw = laneDraw(view);
|
|
1878
|
-
const mintRow = mint !== void 0 && mint.status === "running" ? view.row(
|
|
1879
|
-
` ${view.glyph("running")} minting a credential for ${mintTargetText(mint.target)}`,
|
|
1880
|
-
elapsed(view, mint.startedAt, mint.endedAt)
|
|
1881
|
-
) : void 0;
|
|
1882
|
-
const rows = startedLanes(state).flatMap((lane) => {
|
|
1883
|
-
const row = lane.live(state.resources, draw);
|
|
1884
|
-
return row === void 0 ? [] : [{ lane: lane.lane, ...row }];
|
|
1885
|
-
});
|
|
1886
|
-
return rows.flatMap(({ lane, span, text, detail }, index) => [
|
|
1887
|
-
view.row(`${laneHead(view.glyph(span.status), lane)}${text}`, elapsed(view, span.startedAt, span.endedAt)),
|
|
1888
|
-
index === 0 && mintRow !== void 0 ? mintRow : detail !== void 0 ? view.line(` ${view.glyph("running")} ${detail}`) : ""
|
|
1889
|
-
]);
|
|
1890
|
-
}
|
|
1891
|
-
function unsandboxedResourcesRecord(state, view) {
|
|
1892
|
-
const { mint } = state;
|
|
1893
|
-
const draw = laneDraw(view);
|
|
1894
|
-
const lanes = startedLanes(state).flatMap((lane) => {
|
|
1895
|
-
const record = lane.record(state.resources, draw);
|
|
1896
|
-
if (record === void 0) return [];
|
|
1897
|
-
const { span } = record;
|
|
1898
|
-
return [
|
|
1899
|
-
view.row(
|
|
1900
|
-
`${laneHead(view.glyph(span.status), lane.lane)}${record.text}`,
|
|
1901
|
-
elapsed(view, span.startedAt, span.endedAt)
|
|
1902
|
-
),
|
|
1903
|
-
...record.lines
|
|
1904
|
-
];
|
|
1905
|
-
});
|
|
1906
|
-
if (lanes.length === 0) return [];
|
|
1907
|
-
return [...mint === void 0 ? [] : [credentialLine(mint, view)], ...lanes];
|
|
1908
|
-
}
|
|
1909
|
-
function commandFrame(state, view) {
|
|
1910
|
-
return state.command === void 0 ? [] : [commandLine(state, state.command, view, true)];
|
|
1911
|
-
}
|
|
1912
|
-
var LONG_FILE_MS = 1e4;
|
|
1913
|
-
function commandLine(state, command, view, live) {
|
|
1914
|
-
const { tests } = state;
|
|
1915
|
-
const end = command.outcome === void 0 ? void 0 : endText(command.outcome);
|
|
1916
|
-
const parts = [command.argv.join(" ")];
|
|
1917
|
-
if (end !== void 0) parts.push(end);
|
|
1918
|
-
else if (live && state.stopping) parts.push("stopping");
|
|
1919
|
-
const head = laneHead(view.glyph(command.status), "command");
|
|
1920
|
-
const time = elapsed(view, command.startedAt, command.endedAt);
|
|
1921
|
-
const text = live && end === void 0 && !state.stopping && tests !== void 0 ? testsProgress(tests, view, view.width - visibleLength(head) - visibleLength(time) - 1) : parts.join(" ");
|
|
1922
|
-
return view.row(`${head}${text}`, time);
|
|
1923
|
-
}
|
|
1924
|
-
function testsProgress(tests, view, room) {
|
|
1925
|
-
const { paint: paint2, now } = view;
|
|
1926
|
-
const running = tests.workers.filter((worker) => worker.file !== void 0 || worker.settingUp.length > 0);
|
|
1927
|
-
const waiting = waitingText(tests.workers.map(({ settingUp }) => settingUp));
|
|
1928
|
-
const longest = [...running].toSorted((a, b) => (a.fileStartedAt ?? 0) - (b.fileStartedAt ?? 0))[0];
|
|
1929
|
-
const longestMs = longest?.fileStartedAt === void 0 || now === void 0 ? void 0 : now - longest.fileStartedAt;
|
|
1930
|
-
const text = (showWaiting) => [
|
|
1931
|
-
`${tests.passed} passed`,
|
|
1932
|
-
...tests.failed === 0 ? [] : [paint2.failed(`${tests.failed} failed`)],
|
|
1933
|
-
`${tests.filesDone} ${tests.filesDone === 1 ? "file" : "files"} done`,
|
|
1934
|
-
`${running.length} running${waiting === void 0 || !showWaiting ? "" : ` (${waiting})`}`,
|
|
1935
|
-
...longest?.file === void 0 || longestMs === void 0 || longestMs < LONG_FILE_MS ? [] : [`longest: ${shortFile(longest.file)} ${seconds(longestMs)}`]
|
|
1936
|
-
].join(" \xB7 ");
|
|
1937
|
-
const full = text(true);
|
|
1938
|
-
return visibleLength(full) <= room ? full : text(false);
|
|
1939
|
-
}
|
|
1940
|
-
function waitingText(waiting) {
|
|
1941
|
-
const words = setupPhaseWords(waiting.flat());
|
|
1942
|
-
const counts = /* @__PURE__ */ new Map();
|
|
1943
|
-
for (const phases of waiting)
|
|
1944
|
-
for (const phase of phases) {
|
|
1945
|
-
const key = setupPhaseKey(phase);
|
|
1946
|
-
const group = counts.get(key) ?? { text: words(phase), count: 0 };
|
|
1947
|
-
counts.set(key, group);
|
|
1948
|
-
group.count += 1;
|
|
1949
|
-
}
|
|
1950
|
-
if (counts.size === 0) return void 0;
|
|
1951
|
-
return [...counts.values()].map(({ text, count }) => `${count} waiting on ${withArticle(text)}`).join(", ");
|
|
1952
|
-
}
|
|
1953
|
-
function cleanupLine(cleanup, runner, view, record) {
|
|
1954
|
-
const done = record || cleanup.status !== "running";
|
|
1955
|
-
const { keepMs, resources } = cleanup;
|
|
1956
|
-
const text = !done && cleanup.waiting ? `${WAITING_FOR_SNAPSHOT}\u2026` : keepMs === null ? releaseText(resources, done) ?? "nothing to release" : orderText(runnerSandboxSteps(keepMs, resources, runner, done));
|
|
1957
|
-
const leftBehind = cleanupProblems(cleanup);
|
|
1958
|
-
const ending = done ? leftBehind === 0 ? "" : `: ${leftBehind} left behind` : "\u2026";
|
|
1959
|
-
return view.row(
|
|
1960
|
-
` ${view.glyph(cleanup.status)} cleanup ${text}${!done && cleanup.waiting ? "" : ending}`,
|
|
1961
|
-
elapsed(view, cleanup.startedAt, cleanup.endedAt)
|
|
1962
|
-
);
|
|
1963
|
-
}
|
|
1964
|
-
function runnerSandboxSteps(keepMs, resources, runner, done) {
|
|
1965
|
-
const kept = runner?.kept;
|
|
1966
|
-
const release = releaseText(resources, done || kept !== void 0);
|
|
1967
|
-
const released = release === void 0 ? [] : [release];
|
|
1968
|
-
if (kept !== void 0)
|
|
1969
|
-
return [...released, `kept the runner sandbox until ${isoSecondsText(kept.stopsAt)}, with no network access`];
|
|
1970
|
-
if (!done && keepMs > 0)
|
|
1971
|
-
return ["giving the runner sandbox no network access", ...released, `keeping it running ${keepTimeText(keepMs)}`];
|
|
1972
|
-
if (release === void 0) return [`${done ? "stopped and deleted" : "stopping and deleting"} the runner sandbox`];
|
|
1973
|
-
return done ? ["stopped the runner sandbox", release, "deleted it"] : ["stopping the runner sandbox", release, "deleting it"];
|
|
1974
|
-
}
|
|
1975
|
-
function statusGlyph(status, now, paint2) {
|
|
1976
|
-
switch (status) {
|
|
1977
|
-
case "pending":
|
|
1978
|
-
return paint2.faint("\xB7");
|
|
1979
|
-
case "running":
|
|
1980
|
-
return paint2.active(SPINNER[Math.floor(now / 90) % SPINNER.length] ?? "\xB7");
|
|
1981
|
-
case "done":
|
|
1982
|
-
return paint2.done("\u2713");
|
|
1983
|
-
case "failed":
|
|
1984
|
-
return paint2.failed("\u2717");
|
|
1985
|
-
case "stopped":
|
|
1986
|
-
return paint2.stopped("\u25A0");
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
function endText(outcome) {
|
|
1990
|
-
return outcome === "stopped" ? "stopped" : commandEnd(outcome);
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
// src/commands/exec/view.ts
|
|
1994
|
-
var PLAIN_WIDTH = 80;
|
|
1995
|
-
function runView(options) {
|
|
1996
|
-
const { presentation, progress, context } = options;
|
|
1997
|
-
if (progress === void 0)
|
|
1998
|
-
return {
|
|
1999
|
-
observer: { observe: async () => {
|
|
2000
|
-
} },
|
|
2001
|
-
runnerTerminal: context.runnerTerminal,
|
|
2002
|
-
width: PLAIN_WIDTH,
|
|
2003
|
-
colorDepth: "none",
|
|
2004
|
-
finish: async () => {
|
|
2005
|
-
}
|
|
2006
|
-
};
|
|
2007
|
-
if (presentation.kind === "plain") {
|
|
2008
|
-
const writer = droppingWriter(progress);
|
|
2009
|
-
return {
|
|
2010
|
-
observer: lineProgress(writer, { github: presentation.github, verbose: options.verbose }),
|
|
2011
|
-
runnerTerminal: context.runnerTerminal,
|
|
2012
|
-
width: Math.min(Math.max(presentation.columns ?? PLAIN_WIDTH, 60), 120),
|
|
2013
|
-
colorDepth: presentation.colorDepth,
|
|
2014
|
-
finish: async (summary) => {
|
|
2015
|
-
for (const line of summary) await writer(line);
|
|
2016
|
-
}
|
|
2017
|
-
};
|
|
2018
|
-
}
|
|
2019
|
-
return liveView(context, presentation.colorDepth, {
|
|
2020
|
-
showOutput: options.showOutput || options.verbose,
|
|
2021
|
-
verbose: options.verbose
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
2024
|
-
function droppingWriter(write) {
|
|
2025
|
-
let failed = false;
|
|
2026
|
-
return async (line) => {
|
|
2027
|
-
if (failed) return;
|
|
2028
|
-
try {
|
|
2029
|
-
await write(line);
|
|
2030
|
-
} catch {
|
|
2031
|
-
failed = true;
|
|
2032
|
-
}
|
|
2033
|
-
};
|
|
2034
|
-
}
|
|
2035
|
-
function liveView(context, colorDepth, options) {
|
|
2036
|
-
const { showOutput } = options;
|
|
2037
|
-
const colors = paint(colorDepth !== "none");
|
|
2038
|
-
const terminal = context.progressTerminal;
|
|
2039
|
-
let state = EMPTY_RUN_STATE;
|
|
2040
|
-
let phase;
|
|
2041
|
-
let headerPrinted = false;
|
|
2042
|
-
let live = false;
|
|
2043
|
-
let finished = false;
|
|
2044
|
-
const width = () => terminal.columns() - 1;
|
|
2045
|
-
const frame = () => phase === void 0 || finished ? [] : phaseFrame(state, phase, context.clock.now().getTime(), width(), colors);
|
|
2046
|
-
const print = (lines) => {
|
|
2047
|
-
if (lines.length > 0) terminal.print("stderr", lines.map((line) => `${line}
|
|
2048
|
-
`).join(""));
|
|
2049
|
-
};
|
|
2050
|
-
const header = () => {
|
|
2051
|
-
if (headerPrinted) return [];
|
|
2052
|
-
headerPrinted = true;
|
|
2053
|
-
return [headerLine(state, colors)];
|
|
2054
|
-
};
|
|
2055
|
-
return {
|
|
2056
|
-
observer: {
|
|
2057
|
-
observe: async (timed) => {
|
|
2058
|
-
if (finished) return;
|
|
2059
|
-
state = DEFINITION_SET.applyEvent(state, timed);
|
|
2060
|
-
const next = activePhase(state);
|
|
2061
|
-
if (next !== phase) {
|
|
2062
|
-
print([
|
|
2063
|
-
...next === void 0 ? [] : header(),
|
|
2064
|
-
...phase === void 0 ? [] : phaseRecord(state, phase, width(), colors)
|
|
2065
|
-
]);
|
|
2066
|
-
phase = next;
|
|
2067
|
-
}
|
|
2068
|
-
print(noticeLines(timed, state.origin ?? timed.at.getTime(), options.verbose));
|
|
2069
|
-
const { event } = timed;
|
|
2070
|
-
if (showOutput && event.kind === "runner" && event.event.kind === "step-output") print([event.event.line]);
|
|
2071
|
-
if (!live) {
|
|
2072
|
-
terminal.show(frame);
|
|
2073
|
-
live = true;
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
},
|
|
2077
|
-
runnerTerminal: {
|
|
2078
|
-
color: context.runnerTerminal.color,
|
|
2079
|
-
writeStdout: (text) => terminal.print("stdout", text),
|
|
2080
|
-
writeStderr: (text) => terminal.print("stderr", text)
|
|
2081
|
-
},
|
|
2082
|
-
// The terminal may have been resized by the time the summary prints.
|
|
2083
|
-
get width() {
|
|
2084
|
-
return terminal.columns();
|
|
2085
|
-
},
|
|
2086
|
-
colorDepth,
|
|
2087
|
-
finish: async (summary) => {
|
|
2088
|
-
if (finished) return;
|
|
2089
|
-
finished = true;
|
|
2090
|
-
print([...header(), ...phase === void 0 ? [] : phaseRecord(state, phase, width(), colors), ...summary]);
|
|
2091
|
-
terminal.settle();
|
|
2092
|
-
}
|
|
2093
|
-
};
|
|
2094
|
-
}
|
|
2095
|
-
function noticeLines(timed, origin, verbose) {
|
|
2096
|
-
const line = (lane, text) => progressLine(timed.at.getTime() - origin, lane, text);
|
|
2097
|
-
const { event } = timed;
|
|
2098
|
-
switch (event.kind) {
|
|
2099
|
-
case "runner-prepared":
|
|
2100
|
-
return preparedNoteTexts(event).map((text) => line("runner", text));
|
|
2101
|
-
case "runner":
|
|
2102
|
-
return runnerNoticeLines(event.event, line);
|
|
2103
|
-
case "resource":
|
|
2104
|
-
return DEFINITION_SET.presentations.notices(event, { verbose }).map(({ lane, text }) => line(lane, text));
|
|
2105
|
-
// A line a resource instance reported prints as it is, in its lane, and a warning marked as one.
|
|
2106
|
-
case "resource-notice":
|
|
2107
|
-
return [line(event.lane, event.text)];
|
|
2108
|
-
case "resource-warning":
|
|
2109
|
-
return [line(event.lane, resourceWarningText(event))];
|
|
2110
|
-
case "resource-skipped":
|
|
2111
|
-
return [line("run", skippedText(event))];
|
|
2112
|
-
// The live view draws what an acquired resource holds from its lane's state.
|
|
2113
|
-
case "resource-acquired":
|
|
2114
|
-
case "started":
|
|
2115
|
-
case "requesting-token":
|
|
2116
|
-
case "minting":
|
|
2117
|
-
case "minted":
|
|
2118
|
-
case "cleanup-started":
|
|
2119
|
-
case "cleanup-finished":
|
|
2120
|
-
case "command-started":
|
|
2121
|
-
case "command-ended":
|
|
2122
|
-
case "lanes-started":
|
|
2123
|
-
case "lane-started":
|
|
2124
|
-
case "lane-ended":
|
|
2125
|
-
case "test":
|
|
2126
|
-
case "test-event-unreadable":
|
|
2127
|
-
case "test-events-incomplete":
|
|
2128
|
-
case "sandboxes-started":
|
|
2129
|
-
case "sandbox":
|
|
2130
|
-
case "sandbox-ended":
|
|
2131
|
-
return [];
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
function runnerNoticeLines(event, line) {
|
|
2135
|
-
switch (event.kind) {
|
|
2136
|
-
case "snapshot-entry-not-written":
|
|
2137
|
-
return [line("runner", cacheWriteFailureText(event.failure))];
|
|
2138
|
-
// The runner row shows the build; its reasons, when a cached snapshot didn't fit, are lines of their own.
|
|
2139
|
-
case "snapshot-build-started":
|
|
2140
|
-
return event.why.kind === "no-snapshot" && event.why.rejected.length > 0 ? snapshotBuildTexts(event).map((text) => line("runner", text)) : [];
|
|
2141
|
-
// The live view's phases show the rest.
|
|
2142
|
-
case "snapshot-reused":
|
|
2143
|
-
case "runner-sandbox-starting":
|
|
2144
|
-
case "sandbox-started":
|
|
2145
|
-
case "output-started":
|
|
2146
|
-
case "output-ended":
|
|
2147
|
-
case "step-started":
|
|
2148
|
-
case "step-output":
|
|
2149
|
-
case "step-finished":
|
|
2150
|
-
case "snapshot-saving":
|
|
2151
|
-
case "snapshot-built":
|
|
2152
|
-
case "uploading":
|
|
2153
|
-
case "uploaded":
|
|
2154
|
-
case "command-output-started":
|
|
2155
|
-
case "command-stopped":
|
|
2156
|
-
case "stopping":
|
|
2157
|
-
case "waiting-for-snapshot":
|
|
2158
|
-
case "sandbox-kept":
|
|
2159
|
-
return [];
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
|
|
2163
|
-
// src/commands/exec/run-command.ts
|
|
2164
|
-
var OWN_RUN_FIELDS = {
|
|
2165
|
-
scope: z7.string().min(1).optional(),
|
|
2166
|
-
project: z7.string().min(1).optional(),
|
|
2167
|
-
credential: z7.enum(["mint", "github-actions"]).optional(),
|
|
2168
|
-
showOutput: z7.boolean().default(false),
|
|
2169
|
-
keepSandbox: z7.string().optional(),
|
|
2170
|
-
verbose: z7.boolean().default(false),
|
|
2171
|
-
planOnly: z7.boolean().default(false)
|
|
2172
|
-
};
|
|
2173
|
-
var RUN_REQUEST_FIELDS = { ...OWN_RUN_FIELDS, ...resourceFlagFields(Object.keys(OWN_RUN_FIELDS)) };
|
|
2174
|
-
var RUN_CLI_OPTIONS = { project: { short: "p" } };
|
|
2175
|
-
var runRequestSchema = z7.object(RUN_REQUEST_FIELDS);
|
|
2176
|
-
async function beforeRunStarts({ ui, signal }, lifecycles, planned, request, plan) {
|
|
2177
|
-
const before = await resourcesBeforeRun(lifecycles, planned, request);
|
|
2178
|
-
if (!before.ok) return before;
|
|
2179
|
-
if (signal.aborted) return { ok: false, refusal: canceledBeforeStart() };
|
|
2180
|
-
if (plan !== void 0) await ui.progress?.(testPlanLine(plan));
|
|
2181
|
-
return before;
|
|
2182
|
-
}
|
|
2183
|
-
async function prepareRunSession(context, lifecycles, planned, request) {
|
|
2184
|
-
const { app } = context;
|
|
2185
|
-
const { configFile, argv, testPlan, planOptions } = planned;
|
|
2186
|
-
const plan = recordedPlan(testPlan, planOptions);
|
|
2187
|
-
const before = await beforeRunStarts(context, lifecycles, planned, request, plan);
|
|
2188
|
-
if (!before.ok) return before;
|
|
2189
|
-
const { where, used } = before;
|
|
2190
|
-
const base = {
|
|
2191
|
-
argv,
|
|
2192
|
-
env: Object.fromEntries(Object.entries(app.env).filter(([name]) => !used.hiddenVariables.includes(name))),
|
|
2193
|
-
version: app.version,
|
|
2194
|
-
commit: app.commit,
|
|
2195
|
-
configFile,
|
|
2196
|
-
verbose: request.verbose,
|
|
2197
|
-
resources: used.requests,
|
|
2198
|
-
skipped: used.skipped
|
|
2199
|
-
};
|
|
2200
|
-
let run;
|
|
2201
|
-
if (where.kind === "runner") {
|
|
2202
|
-
const keepMs = keepSandboxMinutes(request.keepSandbox, where.recipe) * 6e4;
|
|
2203
|
-
const requested = await runnerRequestFor(app, where, used, { configFile, sandboxes: 1, keepMs });
|
|
2204
|
-
if (!requested.ok) return requested;
|
|
2205
|
-
run = { ...base, runner: requested.runner };
|
|
2206
|
-
} else run = { ...base, ...where.credential === void 0 ? {} : { credential: where.credential } };
|
|
2207
|
-
const secrets = [...used.secrets, ...where.kind === "runner" ? where.secrets : []];
|
|
2208
|
-
const git = await checkoutGit(app.context.checkout, app.cwd);
|
|
2209
|
-
return { ok: true, plan, run, secrets, redact: redactor(secrets), git };
|
|
2210
|
-
}
|
|
2211
|
-
async function runLifecycle(options) {
|
|
2212
|
-
try {
|
|
2213
|
-
const ended = await options.execute();
|
|
2214
|
-
return options.hasSecrets ? redactStrings(ended, options.redact) : ended;
|
|
2215
|
-
} catch (error) {
|
|
2216
|
-
await options.finishView();
|
|
2217
|
-
await options.abandonRecording();
|
|
2218
|
-
throw error;
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
function mapStoppedOutcome(outcome, canceledOptions) {
|
|
2222
|
-
switch (outcome.kind) {
|
|
2223
|
-
case "resource_refused":
|
|
2224
|
-
return resourceRefused(outcome, RUN_CLEANUP.facts(outcome));
|
|
2225
|
-
case "mint_failed":
|
|
2226
|
-
return mintFailedErrors.mintFailed({
|
|
2227
|
-
...outcome.target,
|
|
2228
|
-
...describeMintFailure(outcome.failure, outcome.target),
|
|
2229
|
-
runner: outcome.runner,
|
|
2230
|
-
cleanup: RUN_CLEANUP.facts(outcome)
|
|
2231
|
-
});
|
|
2232
|
-
case "spawn_failed":
|
|
2233
|
-
return runErrors.spawnFailed({
|
|
2234
|
-
executable: outcome.executable,
|
|
2235
|
-
message: outcome.message,
|
|
2236
|
-
cleanup: RUN_CLEANUP.facts({ runnerCleanup: null, resourceCleanup: outcome.resourceCleanup })
|
|
2237
|
-
});
|
|
2238
|
-
case "canceled":
|
|
2239
|
-
return outcomes.canceled({ changed: canceledChanges(outcome, canceledOptions) });
|
|
2240
|
-
case "runner_failed":
|
|
2241
|
-
return runErrors.runnerFailed({
|
|
2242
|
-
failure: runnerFailureFacts(outcome.failure),
|
|
2243
|
-
cleanup: RUN_CLEANUP.facts(outcome)
|
|
2244
|
-
});
|
|
2245
|
-
case "snapshot_gone":
|
|
2246
|
-
return runErrors.snapshotGone({
|
|
2247
|
-
snapshotId: outcome.entry.snapshotId,
|
|
2248
|
-
base: outcome.entry.base,
|
|
2249
|
-
removal: outcome.removal === void 0 ? null : { ...outcome.removal },
|
|
2250
|
-
cleanup: RUN_CLEANUP.facts(outcome)
|
|
2251
|
-
});
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
async function planCommandRun(app, request, planCommand, signal) {
|
|
2255
|
-
const lifecycles = DEFINITION_SET.lifecycles(app.resourceContexts);
|
|
2256
|
-
const planned = await planRun(
|
|
2257
|
-
app,
|
|
2258
|
-
lifecycles,
|
|
2259
|
-
{ ...request, given: resourceFlagValues(request) },
|
|
2260
|
-
planCommand,
|
|
2261
|
-
signal
|
|
2262
|
-
);
|
|
2263
|
-
if (!planned.ok) return planned;
|
|
2264
|
-
return { ok: true, planned, lifecycles };
|
|
2265
|
-
}
|
|
2266
|
-
async function runPlannedCommand(context, request, spec, planned, lifecycles) {
|
|
2267
|
-
const { app, ui, signal } = context;
|
|
2268
|
-
const { configFile, argv, testPlan, planOptions } = planned;
|
|
2269
|
-
const session = await prepareRunSession(context, lifecycles, planned, request);
|
|
2270
|
-
if (!session.ok) return session.refusal;
|
|
2271
|
-
const { plan, run, secrets, redact, git } = session;
|
|
2272
|
-
const sigterm = forwardSigterm(signal);
|
|
2273
|
-
const view = runView({
|
|
2274
|
-
presentation: app.presentation,
|
|
2275
|
-
progress: ui.progress,
|
|
2276
|
-
context: app.context,
|
|
2277
|
-
showOutput: request.showOutput,
|
|
2278
|
-
verbose: request.verbose
|
|
2279
|
-
});
|
|
2280
|
-
const recording = await recordRun(app.context.runDirectories, {
|
|
2281
|
-
definitionSet: DEFINITION_SET,
|
|
2282
|
-
clock: app.context.clock,
|
|
2283
|
-
cwd: app.cwd,
|
|
2284
|
-
configFile,
|
|
2285
|
-
argv,
|
|
2286
|
-
...spec.test === void 0 ? {} : { test: spec.test },
|
|
2287
|
-
plan,
|
|
2288
|
-
run,
|
|
2289
|
-
git,
|
|
2290
|
-
redact: (value) => redactStrings(value, redact)
|
|
2291
|
-
});
|
|
2292
|
-
const observer = recording.observer(view.observer);
|
|
2293
|
-
const terminal = recording.terminal(view.runnerTerminal);
|
|
2294
|
-
const collected = run.runner !== void 0 || recording.testEvents !== void 0;
|
|
2295
|
-
const outcome = await runLifecycle({
|
|
2296
|
-
execute: async () => await executeRun(
|
|
2297
|
-
DEFINITION_SET,
|
|
2298
|
-
{ ...app.context, runnerTerminal: secrets.length === 0 ? terminal : redactingTerminal(terminal, redact) },
|
|
2299
|
-
app.resourceContexts,
|
|
2300
|
-
run.runner === void 0 && recording.testEvents !== void 0 ? { ...run, testEvents: recording.testEvents } : run,
|
|
2301
|
-
{ signal, terminate: sigterm.terminate },
|
|
2302
|
-
timedProgress(app.context.clock, secrets.length === 0 ? observer : redactingObserver(observer, redact))
|
|
2303
|
-
),
|
|
2304
|
-
redact,
|
|
2305
|
-
hasSecrets: secrets.length > 0,
|
|
2306
|
-
finishView: async () => await view.finish([]),
|
|
2307
|
-
abandonRecording: async () => await recording.abandon()
|
|
2308
|
-
});
|
|
2309
|
-
sigterm.release();
|
|
2310
|
-
const { timeline: ran, finalResults } = await summarize(app, {
|
|
2311
|
-
command: spec.name,
|
|
2312
|
-
hints: spec.hints,
|
|
2313
|
-
view,
|
|
2314
|
-
recording,
|
|
2315
|
-
outcome
|
|
2316
|
-
});
|
|
2317
|
-
if (outcome.kind !== "ran") return mapStoppedOutcome(outcome);
|
|
2318
|
-
const { command } = outcome;
|
|
2319
|
-
const runId = recording.opened.ok ? recording.opened.id : null;
|
|
2320
|
-
app.exit.status = commandExitStatus(outcome.command);
|
|
2321
|
-
return spec.ran(
|
|
2322
|
-
{
|
|
2323
|
-
version: app.version,
|
|
2324
|
-
commit: app.commit,
|
|
2325
|
-
configFile,
|
|
2326
|
-
resources: DEFINITION_SET.reports.ranFacts(outcome.resources),
|
|
2327
|
-
cleanup: RUN_CLEANUP.facts(outcome),
|
|
2328
|
-
command: command.kind === "exited" ? { exitCode: command.code, signal: null } : command.kind === "signaled" ? { exitCode: null, signal: command.signal } : { exitCode: null, signal: null },
|
|
2329
|
-
runner: outcome.runner === void 0 ? null : {
|
|
2330
|
-
snapshotId: outcome.runner.snapshotId,
|
|
2331
|
-
base: outcome.runner.base,
|
|
2332
|
-
builtBehind: outcome.runner.builtBehind,
|
|
2333
|
-
uploadBytes: outcome.runner.uploadBytes,
|
|
2334
|
-
built: outcome.runner.built,
|
|
2335
|
-
vcpus: outcome.runner.vcpus,
|
|
2336
|
-
region: outcome.runner.region,
|
|
2337
|
-
runtime: outcome.runner.runtime,
|
|
2338
|
-
buildMs: outcome.runner.buildMs
|
|
2339
|
-
},
|
|
2340
|
-
timeline: ran,
|
|
2341
|
-
runId
|
|
2342
|
-
},
|
|
2343
|
-
{ testPlan, options: planOptions },
|
|
2344
|
-
lacksFinalResults(command.kind === "exited" ? command.code : null, {
|
|
2345
|
-
...finalResults,
|
|
2346
|
-
collected
|
|
2347
|
-
})
|
|
2348
|
-
);
|
|
2349
|
-
}
|
|
2350
|
-
function sandboxesFlagProblems(request) {
|
|
2351
|
-
const flag = request.sandboxes !== void 0 ? "--sandboxes" : request.fileLists !== void 0 ? "--file-lists" : void 0;
|
|
2352
|
-
if (flag === void 0) return [];
|
|
2353
|
-
return request.showOutput ? [
|
|
2354
|
-
{
|
|
2355
|
-
field: "showOutput",
|
|
2356
|
-
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.`
|
|
2357
|
-
}
|
|
2358
|
-
] : [];
|
|
2359
|
-
}
|
|
2360
|
-
function runFlagProblems(request) {
|
|
2361
|
-
const { keepSandbox } = request;
|
|
2362
|
-
return [
|
|
2363
|
-
...resourceFlagProblems(request),
|
|
2364
|
-
...keepSandbox !== void 0 && parseKeepTime(keepSandbox) === void 0 ? [
|
|
2365
|
-
{
|
|
2366
|
-
field: "keepSandbox",
|
|
2367
|
-
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)}.`
|
|
2368
|
-
}
|
|
2369
|
-
] : []
|
|
2370
|
-
];
|
|
2371
|
-
}
|
|
2372
|
-
async function runnerRequestFor(app, where, used, options) {
|
|
2373
|
-
const prepared = await prepareRunner(app.context, {
|
|
2374
|
-
cwd: app.cwd,
|
|
2375
|
-
recipe: where.recipe,
|
|
2376
|
-
vcpuRun: { resources: recipeResources(used.requests), sandboxes: options.sandboxes }
|
|
2377
|
-
});
|
|
2378
|
-
if (prepared.kind !== "ok") {
|
|
2379
|
-
const refusal = prepareRefusal(prepared, options.configFile);
|
|
2380
|
-
const secrets = [...used.secrets, ...where.secrets];
|
|
2381
|
-
return {
|
|
2382
|
-
ok: false,
|
|
2383
|
-
refusal: secrets.length === 0 ? refusal : redactStrings(refusal, redactor(secrets))
|
|
2384
|
-
};
|
|
2385
|
-
}
|
|
2386
|
-
const runner = {
|
|
2387
|
-
prepared: prepared.prepared,
|
|
2388
|
-
target: where.target,
|
|
2389
|
-
user: app.user,
|
|
2390
|
-
credentials: where.credentials,
|
|
2391
|
-
...Object.keys(where.unsafeSecretEnvVars).length === 0 ? {} : { unsafeSecretEnvVars: where.unsafeSecretEnvVars },
|
|
2392
|
-
keepMs: options.keepMs
|
|
2393
|
-
};
|
|
2394
|
-
return { ok: true, runner };
|
|
2395
|
-
}
|
|
2396
|
-
function prepareRefusal(prepared, configFile) {
|
|
2397
|
-
switch (prepared.kind) {
|
|
2398
|
-
case "no-base-ref":
|
|
2399
|
-
return runErrors.noBaseRef({ refs: prepared.refs.map(({ ref, reason }) => ({ ref, reason })) });
|
|
2400
|
-
case "submodules":
|
|
2401
|
-
return runErrors.submodulesRefused({ paths: [...prepared.paths] });
|
|
2402
|
-
case "invalid-recipe":
|
|
2403
|
-
return invalidConfig(configFile ?? "", [
|
|
2404
|
-
{ key: ["runner", ...prepared.path].join("."), location: null, problem: prepared.problem }
|
|
2405
|
-
]);
|
|
2406
|
-
case "checkout-failed":
|
|
2407
|
-
return checkoutFailedRefusal(prepared.failure);
|
|
2408
|
-
}
|
|
2409
|
-
}
|
|
2410
|
-
function checkoutFailedRefusal(failure) {
|
|
2411
|
-
return runErrors.runnerFailed({
|
|
2412
|
-
failure: runnerFailureFacts({ kind: "checkout-failed", failure }),
|
|
2413
|
-
cleanup: RUN_CLEANUP.facts(NOTHING_RELEASED)
|
|
2414
|
-
});
|
|
2415
|
-
}
|
|
2416
|
-
async function summarize(app, run) {
|
|
2417
|
-
const { view, recording } = run;
|
|
2418
|
-
const recorded = await recording.end(run.outcome);
|
|
2419
|
-
const { timeline, tests } = recorded;
|
|
2420
|
-
const logs = recording.opened.ok ? recording.opened.path : void 0;
|
|
2421
|
-
const failed = tests.events.some((event) => event.kind === "test-result" && event.state === "fail");
|
|
2422
|
-
const testsLines = testsSummaryLines(tests.events, run.hints, tests.unreadable, tests.incomplete);
|
|
2423
|
-
const stepLogs = failedStepLogs(timeline, recording, app.env);
|
|
2424
|
-
const clock = workerClock(recorded);
|
|
2425
|
-
const charted = clock === void 0 ? void 0 : testsChart(tests.events, run.hints, tests.unreadable, clock, tests.incomplete);
|
|
2426
|
-
const workersHint = charted !== void 0 && hasPoorParallelism(charted.parallelism);
|
|
2427
|
-
const summarized = await app.context.jobSummary.appendJobSummary(
|
|
2428
|
-
jobSummaryMarkdown(timeline, {
|
|
2429
|
-
command: run.command,
|
|
2430
|
-
logs,
|
|
2431
|
-
details: [...testsLines, ...stepLogs]
|
|
2432
|
-
})
|
|
2433
|
-
);
|
|
2434
|
-
await view.finish(
|
|
2435
|
-
waterfallLines(timeline, {
|
|
2436
|
-
width: view.width,
|
|
2437
|
-
colorDepth: view.colorDepth,
|
|
2438
|
-
logs: logsText(recording, recorded.writeFailure, app.env, failed, workersHint),
|
|
2439
|
-
...charted === void 0 ? {} : { workers: charted.lanes },
|
|
2440
|
-
details: [
|
|
2441
|
-
...charted?.notes ?? testsLines,
|
|
2442
|
-
...stepLogs,
|
|
2443
|
-
...summarized.kind === "failed" ? [` couldn't append to the job summary at ${summarized.failure.path}: ${summarized.failure.message}`] : []
|
|
2444
|
-
]
|
|
2445
|
-
})
|
|
2446
|
-
);
|
|
2447
|
-
return {
|
|
2448
|
-
timeline,
|
|
2449
|
-
finalResults: {
|
|
2450
|
-
finalResults: tests.events.filter((event) => event.kind === "test-result").length,
|
|
2451
|
-
partial: tests.unreadable > 0 || tests.incomplete !== void 0
|
|
2452
|
-
}
|
|
2453
|
-
};
|
|
2454
|
-
}
|
|
2455
|
-
function workerClock({ timeline, workerOffsetMs }) {
|
|
2456
|
-
const tests = timeline.rows.find((row) => row.name === "command");
|
|
2457
|
-
if (tests === void 0) return void 0;
|
|
2458
|
-
return { runStartedAt: Date.parse(timeline.startedAt), offsetMs: workerOffsetMs, tests };
|
|
2459
|
-
}
|
|
2460
|
-
function displayPath(path, env) {
|
|
2461
|
-
const home = env["HOME"];
|
|
2462
|
-
if (home === void 0 || home === "" || !path.startsWith(`${home}/`)) return path;
|
|
2463
|
-
return `~${path.slice(home.length)}`;
|
|
2464
|
-
}
|
|
2465
|
-
function logsText({ opened }, writeFailure, env, failed, workersHint) {
|
|
2466
|
-
if (!opened.ok) return `none: couldn't make ${opened.failure.path}: ${opened.failure.message}`;
|
|
2467
|
-
const path = `${displayPath(opened.path, env)}/`;
|
|
2468
|
-
const problems = [
|
|
2469
|
-
...writeFailure === void 0 ? [] : [`couldn't write ${writeFailure.path}: ${writeFailure.message}`],
|
|
2470
|
-
...opened.pruneFailures.slice(0, 1).map((failure) => `couldn't remove ${failure.path}: ${failure.message}`)
|
|
2471
|
-
];
|
|
2472
|
-
const flags = `${failed ? " --failed" : ""}${workersHint ? " --workers" : ""}`;
|
|
2473
|
-
const show = `storm runs show ${opened.id}${flags}`;
|
|
2474
|
-
return `${problems.length === 0 ? path : `${path} (${problems.join("; ")})`} \xB7 ${show}`;
|
|
2475
|
-
}
|
|
2476
|
-
async function checkoutGit(checkout, cwd) {
|
|
2477
|
-
const root = await checkout.repositoryRoot({ cwd });
|
|
2478
|
-
if (!root.ok) return null;
|
|
2479
|
-
const head = await checkout.head({ repoRoot: root.value });
|
|
2480
|
-
return head.ok ? { ...head.value } : null;
|
|
2481
|
-
}
|
|
2482
|
-
function recipeResources(requests) {
|
|
2483
|
-
return Object.fromEntries(
|
|
2484
|
-
Object.entries(requests).map(([key, { options }]) => {
|
|
2485
|
-
if (typeof options !== "object" || options === null) throw new Error(`${key}'s options are not an object`);
|
|
2486
|
-
return [key, options];
|
|
2487
|
-
})
|
|
2488
|
-
);
|
|
2489
|
-
}
|
|
2490
|
-
function keepSandboxMinutes(flag, recipe) {
|
|
2491
|
-
const fromFlag = flag === void 0 ? void 0 : parseKeepTime(flag);
|
|
2492
|
-
return fromFlag ?? recipe.keepSandboxMinutes ?? 0;
|
|
2493
|
-
}
|
|
2494
|
-
function failedStepLogs(timeline, recording, env) {
|
|
2495
|
-
const runner = timeline.rows.find((row) => row.name === "runner");
|
|
2496
|
-
return (runner?.steps ?? []).filter((step) => step.outcome === "failed").flatMap((step) => {
|
|
2497
|
-
const log = recording.stepLog(step.name);
|
|
2498
|
-
return log === void 0 ? [] : [` failed ${step.name}, whole output: ${displayPath(log, env)}`];
|
|
2499
|
-
});
|
|
2500
|
-
}
|
|
2501
|
-
function runnerFailureFacts(failure) {
|
|
2502
|
-
switch (failure.kind) {
|
|
2503
|
-
case "snapshot-build-step-failed":
|
|
2504
|
-
case "apply-failed":
|
|
2505
|
-
case "install-failed":
|
|
2506
|
-
case "build-failed":
|
|
2507
|
-
return { kind: failure.kind, label: failure.label, exitCode: failure.exitCode, tail: [...failure.tail] };
|
|
2508
|
-
case "sandbox-api-failed":
|
|
2509
|
-
return { kind: failure.kind, operation: failure.operation, status: failure.status, message: failure.message };
|
|
2510
|
-
case "checkout-failed":
|
|
2511
|
-
return { kind: failure.kind, message: failure.failure.message, command: failure.failure.displayCommand ?? null };
|
|
2512
|
-
case "network-policy-failed":
|
|
2513
|
-
return {
|
|
2514
|
-
kind: failure.kind,
|
|
2515
|
-
operation: failure.operation,
|
|
2516
|
-
around: failure.around,
|
|
2517
|
-
reason: failure.reason,
|
|
2518
|
-
status: failure.status,
|
|
2519
|
-
message: failure.message
|
|
2520
|
-
};
|
|
2521
|
-
case "credential-claims-missing":
|
|
2522
|
-
return { kind: failure.kind, ...failure.target };
|
|
2523
|
-
}
|
|
2524
|
-
}
|
|
2525
|
-
var NOTHING_RELEASED = { runnerCleanup: null, resourceCleanup: {} };
|
|
2526
|
-
function canceledChanges(outcome, options = {}) {
|
|
2527
|
-
const { commandStopped } = outcome;
|
|
2528
|
-
const lines = [
|
|
2529
|
-
options.commandLine ?? (commandStopped === true ? "The command was stopped in the runner sandbox." : "The command didn't run.")
|
|
2530
|
-
];
|
|
2531
|
-
const cleanup = RUN_CLEANUP.facts(outcome).runner;
|
|
2532
|
-
if (cleanup !== null) lines.push(...runnerCleanupLines(cleanup, options.keptLines));
|
|
2533
|
-
else if (options.keptLines !== void 0) lines.push(...options.keptLines);
|
|
2534
|
-
lines.push(...DEFINITION_SET.reports.canceledLines(outcome.resourceCleanup));
|
|
2535
|
-
return lines.join("\n");
|
|
2536
|
-
}
|
|
2537
|
-
function runnerCleanupLines({ kept, notKept, notStopped, notDeleted }, keptLines) {
|
|
2538
|
-
const problems = [
|
|
2539
|
-
...notKept === null ? [] : [notKeptText(notKept)],
|
|
2540
|
-
...notStopped.map(notStoppedText),
|
|
2541
|
-
...notDeleted.map(notDeletedText)
|
|
2542
|
-
];
|
|
2543
|
-
const allKept = [...kept === null ? [] : [keptText(kept)], ...keptLines ?? []];
|
|
2544
|
-
if (allKept.length === 0)
|
|
2545
|
-
return problems.length === 0 ? ["Every sandbox the runner started is stopped and deleted."] : problems;
|
|
2546
|
-
return [
|
|
2547
|
-
...allKept,
|
|
2548
|
-
...problems.length === 0 ? ["Every other sandbox the runner started is stopped and deleted."] : problems
|
|
2549
|
-
];
|
|
2550
|
-
}
|
|
2551
|
-
|
|
2552
|
-
export {
|
|
2553
|
-
lacksFinalResults,
|
|
2554
|
-
notStoppedText,
|
|
2555
|
-
notDeletedText,
|
|
2556
|
-
RUN_CLEANUP,
|
|
2557
|
-
acrossSandboxesJobSummaryMarkdown,
|
|
2558
|
-
plannedSchema,
|
|
2559
|
-
plannedSecrets,
|
|
2560
|
-
buildPlannedFacts,
|
|
2561
|
-
PLANNED_DESCRIPTION,
|
|
2562
|
-
renderPlanned,
|
|
2563
|
-
readFileListsFile,
|
|
2564
|
-
resolveCallerFileLists,
|
|
2565
|
-
sandboxesRanSchema,
|
|
2566
|
-
SANDBOXES_RAN_DESCRIPTION,
|
|
2567
|
-
renderSandboxesRan,
|
|
2568
|
-
sandboxesErrors,
|
|
2569
|
-
sandboxesDefaultErrors,
|
|
2570
|
-
fileListErrors,
|
|
2571
|
-
ranSchema,
|
|
2572
|
-
RAN_DESCRIPTION,
|
|
2573
|
-
renderRan,
|
|
2574
|
-
runErrors,
|
|
2575
|
-
RUN_ERRORS,
|
|
2576
|
-
outcomes,
|
|
2577
|
-
canceledBeforeStart,
|
|
2578
|
-
lineProgress,
|
|
2579
|
-
plainRenderer,
|
|
2580
|
-
progressLine,
|
|
2581
|
-
commandEnd,
|
|
2582
|
-
RUN_REQUEST_FIELDS,
|
|
2583
|
-
RUN_CLI_OPTIONS,
|
|
2584
|
-
beforeRunStarts,
|
|
2585
|
-
runLifecycle,
|
|
2586
|
-
mapStoppedOutcome,
|
|
2587
|
-
planCommandRun,
|
|
2588
|
-
runPlannedCommand,
|
|
2589
|
-
sandboxesFlagProblems,
|
|
2590
|
-
runFlagProblems,
|
|
2591
|
-
runnerRequestFor,
|
|
2592
|
-
prepareRefusal,
|
|
2593
|
-
checkoutFailedRefusal,
|
|
2594
|
-
displayPath,
|
|
2595
|
-
logsText,
|
|
2596
|
-
checkoutGit,
|
|
2597
|
-
recipeResources,
|
|
2598
|
-
runnerFailureFacts
|
|
2599
|
-
};
|