@cnc-tools/storm 0.8.1 → 0.9.1
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/bin/storm.js +3 -14
- package/dist/application.d.ts +18 -10
- package/dist/application.js +10 -11
- package/dist/bin/storm.js +97 -41
- package/dist/build-info.js +1 -1
- package/dist/chunks/chunk-5CQCRX2L.js +5768 -0
- package/dist/chunks/chunk-5U5Q6VZR.js +556 -0
- package/dist/chunks/chunk-7O6UN63H.js +63 -0
- package/dist/chunks/chunk-I5GZLOLQ.js +38 -0
- package/dist/chunks/chunk-NX55IJ5S.js +1842 -0
- package/dist/chunks/chunk-OCZJE5XV.js +910 -0
- package/dist/chunks/chunk-RRQ2ZGSE.js +1512 -0
- package/dist/chunks/chunk-S5NAIZYS.js +13 -0
- package/dist/chunks/chunk-UHO5OCEX.js +360 -0
- package/dist/chunks/chunk-WBIHJM7D.js +188 -0
- package/dist/chunks/chunk-WV6WQFC6.js +436 -0
- package/dist/chunks/live-app-X3PW2W42.js +89 -0
- package/dist/chunks/version-X7RMSKZI.js +12 -0
- package/dist/commands/exec/command.d.ts +32 -0
- package/dist/commands/exec/command.js +35 -21
- package/dist/commands/exec/metadata.js +66 -58
- package/dist/commands/exec/outcomes.d.ts +67 -0
- package/dist/commands/exec/outcomes.js +50 -0
- package/dist/commands/exec/redaction.js +1 -1
- package/dist/commands/exec/run-collector.d.ts +1 -1
- package/dist/commands/exec/run-collector.js +1 -1
- package/dist/commands/exec/run-command.d.ts +17 -11
- package/dist/commands/exec/run-command.js +33 -16
- package/dist/commands/exec/run-record.d.ts +1 -1
- package/dist/commands/exec/tests-summary.d.ts +1 -1
- package/dist/commands/exec/worker-chart.d.ts +1 -1
- package/dist/commands/runs/list/command.js +136 -33
- package/dist/commands/runs/list/metadata.js +22 -18
- package/dist/commands/runs/logs/command.js +131 -48
- package/dist/commands/runs/logs/metadata.js +24 -20
- package/dist/commands/runs/metadata.js +6 -2
- package/dist/commands/runs/past-run.d.ts +1 -1
- package/dist/commands/runs/past-run.js +1 -1
- package/dist/commands/runs/show/command.js +396 -74
- package/dist/commands/runs/show/metadata.js +24 -20
- package/dist/commands/vitest/command.d.ts +32 -0
- package/dist/commands/vitest/command.js +195 -128
- package/dist/commands/vitest/metadata.js +45 -37
- package/dist/commands/vitest/outcomes.d.ts +16 -0
- package/dist/context.d.ts +1 -1
- package/dist/core/events.d.ts +1 -1
- package/dist/core/payload.d.ts +1 -1
- package/dist/core/payload.js +1 -1
- package/dist/core/provider.d.ts +12 -2
- package/dist/core/run.d.ts +6 -1
- package/dist/core/run.js +2 -2
- package/dist/live-app.d.ts +9 -0
- package/dist/live-app.js +21 -0
- package/dist/resource-commands.d.ts +13 -0
- package/dist/resource-commands.js +22 -0
- package/dist/resources/github/provider.d.ts +1 -1
- package/dist/resources/testserver/command-tree.d.ts +4 -0
- package/dist/resources/testserver/command-tree.js +12 -0
- package/dist/resources/testserver/commands/create/command.js +373 -194
- package/dist/resources/testserver/commands/create/metadata.js +52 -48
- package/dist/resources/testserver/commands/list/command.js +195 -50
- package/dist/resources/testserver/commands/list/metadata.js +12 -8
- package/dist/resources/testserver/provider.d.ts +1 -1
- package/dist/resources/testserver/resource-provider.js +2 -8
- package/dist/resources.d.ts +0 -3
- package/dist/resources.js +5 -10
- package/dist/runner/index.d.ts +2 -1
- package/dist/runner/index.js +1 -0
- package/dist/runner/prepare.d.ts +7 -6
- package/dist/runner/prepare.js +1 -1
- package/dist/runner/ready.d.ts +6 -0
- package/dist/runner/ready.js +33 -5
- package/dist/runner/recipe.d.ts +33 -6
- package/dist/runner/recipe.js +151 -23
- package/dist/runner/remote-command.js +1 -1
- package/dist/runner/secrets.d.ts +42 -0
- package/dist/runner/secrets.js +44 -0
- package/dist/runner/snapshot-build.d.ts +5 -2
- package/dist/runner/snapshot-build.js +12 -5
- package/dist/runner/snapshot-cache.d.ts +3 -3
- package/dist/runner/snapshot-cache.js +2 -2
- package/dist/runner/snapshot-key.d.ts +19 -12
- package/dist/runner/snapshot-key.js +25 -16
- package/dist/runner/snapshot-save.d.ts +5 -3
- package/dist/runner/snapshot-save.js +7 -5
- package/dist/runner/steps.d.ts +6 -1
- package/dist/runner/steps.js +5 -2
- package/dist/sdk/host.d.ts +2 -0
- package/dist/sdk/host.js +7 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +10 -11
- package/dist/vitest/config.d.ts +4 -8
- package/dist/vitest/config.js +5 -9
- package/dist/vitest/container-scope.d.ts +12 -5
- package/dist/vitest/container-scope.js +27 -4
- package/dist/vitest/diagnostics.d.ts +8 -2
- package/dist/vitest/diagnostics.js +7 -4
- package/dist/vitest/fixtures.d.ts +4 -1
- package/dist/vitest/fixtures.js +17 -6
- package/dist/vitest/plan.d.ts +1 -1
- package/dist/vitest/plan.js +2 -2
- package/dist/vitest/sandbox.d.ts +6 -0
- package/dist/vitest/sandbox.js +6 -0
- package/package.json +4 -3
- package/skills/overview.md +1 -0
- package/bin/node-version.js +0 -24
- package/dist/closed-terminal.d.ts +0 -7
- package/dist/closed-terminal.js +0 -18
|
@@ -1,138 +1,205 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTO_SANDBOXES_MAX,
|
|
3
|
+
WORKERS_PER_SANDBOX,
|
|
4
|
+
autoSandboxes,
|
|
5
|
+
describeVitestListFailure,
|
|
6
|
+
formatPlan,
|
|
7
|
+
planVitestRun,
|
|
8
|
+
vitestRunArgv
|
|
9
|
+
} from "../../chunks/chunk-WBIHJM7D.js";
|
|
10
|
+
import {
|
|
11
|
+
RUN_CLI_OPTIONS,
|
|
12
|
+
RUN_REQUEST_FIELDS,
|
|
13
|
+
canceledBeforeStart,
|
|
14
|
+
checkoutFailedRefusal,
|
|
15
|
+
runCommand,
|
|
16
|
+
runProblems,
|
|
17
|
+
testserverSandboxesSource
|
|
18
|
+
} from "../../chunks/chunk-RRQ2ZGSE.js";
|
|
19
|
+
import "../../chunks/chunk-I5GZLOLQ.js";
|
|
20
|
+
import "../../chunks/chunk-WV6WQFC6.js";
|
|
21
|
+
import {
|
|
22
|
+
RAN_DESCRIPTION,
|
|
23
|
+
RUN_ERRORS,
|
|
24
|
+
ranSchema,
|
|
25
|
+
renderRan
|
|
26
|
+
} from "../../chunks/chunk-5U5Q6VZR.js";
|
|
27
|
+
import "../../chunks/chunk-NX55IJ5S.js";
|
|
28
|
+
import "../../chunks/chunk-OCZJE5XV.js";
|
|
29
|
+
import "../../chunks/chunk-5CQCRX2L.js";
|
|
30
|
+
import "../../chunks/chunk-S5NAIZYS.js";
|
|
31
|
+
|
|
32
|
+
// src/commands/vitest/command.ts
|
|
1
33
|
import { refused } from "@vercel/clinkr";
|
|
2
34
|
import { join, parse } from "node:path";
|
|
35
|
+
import { z as z2 } from "zod";
|
|
36
|
+
|
|
37
|
+
// src/commands/vitest/outcomes.ts
|
|
38
|
+
import { defineOutcomes } from "@vercel/clinkr";
|
|
3
39
|
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* checks:
|
|
30
|
-
*
|
|
31
|
-
* 1. Where to count: a local run's working directory; a runner run's `<repository root>/<runner.cwd>`, the directory on
|
|
32
|
-
* this machine that vitest runs in, in the runner sandbox, under `/vercel/sandbox/<runner.cwd>`. A runner run whose
|
|
33
|
-
* repository root git can't say is `runner_failed`, as its local checks would end it.
|
|
34
|
-
* 2. Finds `vitest` in `node_modules/.bin` of that directory and each above it, up to the repository's root, or the
|
|
35
|
-
* filesystem's root outside a repository: `vitest_list_failed` (`start-failed`) naming each directory searched when
|
|
36
|
-
* none has it.
|
|
37
|
-
* 3. Counts the tests with `vitest list --json <args>` there, with this machine's environment:
|
|
38
|
-
* `vitest_list_failed` when it fails, `no_matching_tests` when it lists none. `signal` aborting stops it, and the
|
|
39
|
-
* run cancels (`canceledBeforeStart`).
|
|
40
|
-
* 4. With a Testserver side whose sandbox count came from neither `--testserver-sandboxes` nor the config file, asks
|
|
41
|
-
* for one Testserver sandbox per 4 test files, at most 8 (`autoSandboxes`), in both the resource's options, which a
|
|
42
|
-
* runner recipe's `vcpus` function reads, and its request.
|
|
43
|
-
* 5. Says the plan on stderr, unless under `--json`.
|
|
44
|
-
*
|
|
45
|
-
* The command a local run runs is the `vitest` found; a runner run's is plain `vitest`, which the runner's `PATH`
|
|
46
|
-
* finds in `node_modules/.bin` of `runner.cwd` and of the repository's root.
|
|
47
|
-
*/
|
|
48
|
-
async function planRun(app, progress, request, settled, signal) {
|
|
49
|
-
const { args } = request;
|
|
50
|
-
const { where } = settled;
|
|
51
|
-
const root = await app.context.checkout.repositoryRoot({ cwd: app.cwd });
|
|
52
|
-
let cwd;
|
|
53
|
-
let searchRoot;
|
|
54
|
-
if (where.kind === "local") {
|
|
55
|
-
cwd = app.cwd;
|
|
56
|
-
searchRoot = root.ok ? root.value : parse(app.cwd).root;
|
|
40
|
+
var planSchema = z.object({
|
|
41
|
+
/** How many tests `vitest list --json <args>` counted. */
|
|
42
|
+
tests: z.number(),
|
|
43
|
+
/** How many distinct test files they are in. */
|
|
44
|
+
files: z.number(),
|
|
45
|
+
/** How many Testserver sandboxes the run asked for; null without a Testserver side. */
|
|
46
|
+
sandboxes: z.number().nullable(),
|
|
47
|
+
/** Where that count came from: `--testserver-sandboxes` (`flag`), `resources.testserverPool.sandboxes` in storm.config.ts (`file`), or one per 4 test files, at most 8 (`auto`); null without a Testserver side. */
|
|
48
|
+
sandboxesFrom: z.enum(["flag", "file", "auto"]).nullable()
|
|
49
|
+
});
|
|
50
|
+
var listedShape = {
|
|
51
|
+
/** The arguments given to `vitest run`, which `vitest list --json` was given too. */
|
|
52
|
+
args: z.array(z.string()),
|
|
53
|
+
/** The directory `vitest list` ran in, on this machine. */
|
|
54
|
+
cwd: z.string()
|
|
55
|
+
};
|
|
56
|
+
var outcomes = defineOutcomes({
|
|
57
|
+
results: {
|
|
58
|
+
ran: {
|
|
59
|
+
schema: ranSchema.extend({
|
|
60
|
+
/** The test plan: what `vitest list` counted before the run, and how many Testserver sandboxes the run asked for and why. */
|
|
61
|
+
plan: planSchema
|
|
62
|
+
}),
|
|
63
|
+
description: RAN_DESCRIPTION,
|
|
64
|
+
render: renderRan
|
|
57
65
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
},
|
|
67
|
+
errors: {
|
|
68
|
+
...RUN_ERRORS,
|
|
69
|
+
noMatchingTests: {
|
|
70
|
+
exitCode: 1,
|
|
71
|
+
description: "vitest list found no test for the arguments given to vitest run, so nothing was minted, leased or started.",
|
|
72
|
+
schema: z.object(listedShape),
|
|
73
|
+
render: ({ args, cwd }) => ({
|
|
74
|
+
message: `vitest list found no test for vitest run ${argsText(args)} in ${cwd}. The command didn't run.`,
|
|
75
|
+
next: [
|
|
76
|
+
{
|
|
77
|
+
type: "text",
|
|
78
|
+
text: `Change the arguments given to vitest run (${argsText(args)}), then retry. Put vitest's own dash options after --.`
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
vitestListFailed: {
|
|
84
|
+
exitCode: 1,
|
|
85
|
+
description: "storm couldn't count the tests before the run: vitest wasn't found or failed to start, didn't finish within 60s, exited other than 0, or printed something other than a list of tests. Nothing was minted, leased or started.",
|
|
86
|
+
schema: z.object({
|
|
87
|
+
/** How listing failed: vitest wasn't found or couldn't start (`start-failed`), didn't finish (`timed-out`), exited other than 0 (`exited`), or printed something other than a list of tests (`unreadable-output`). */
|
|
88
|
+
kind: z.enum(["start-failed", "timed-out", "exited", "unreadable-output"]),
|
|
89
|
+
/** What went wrong, such as the directories searched for vitest, or the last line of vitest's stderr. */
|
|
90
|
+
message: z.string(),
|
|
91
|
+
...listedShape
|
|
92
|
+
}),
|
|
93
|
+
render: ({ kind, message, cwd }) => ({
|
|
94
|
+
message: `Couldn't count the tests in ${cwd}: ${/[.!?]$/.test(message) ? message : `${message}.`} The command didn't run.`,
|
|
95
|
+
next: [{ type: "text", text: LIST_FAILED_NEXT[kind] }]
|
|
96
|
+
})
|
|
63
97
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
function argsText(args) {
|
|
101
|
+
return args.length === 0 ? "(none)" : args.join(" ");
|
|
102
|
+
}
|
|
103
|
+
var LIST_FAILED_NEXT = {
|
|
104
|
+
"start-failed": "Install vitest in the package, or run the command with storm exec, which counts nothing.",
|
|
105
|
+
"timed-out": "Check why vitest list doesn't finish, such as a global setup that waits, then retry.",
|
|
106
|
+
exited: "Fix what vitest list reports, then retry. vitest list takes the arguments vitest run does, but refuses some run-only options.",
|
|
107
|
+
"unreadable-output": "Check that the package's vitest prints its list with --json, then retry."
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// src/commands/vitest/command.ts
|
|
111
|
+
function command(cmd) {
|
|
112
|
+
return cmd.define({
|
|
113
|
+
requestSchema: z2.object({ ...RUN_REQUEST_FIELDS, args: z2.array(z2.string()).default([]) }),
|
|
114
|
+
cli: { options: RUN_CLI_OPTIONS, positionals: ["args"] },
|
|
115
|
+
response: outcomes,
|
|
116
|
+
validate: runProblems,
|
|
117
|
+
handler: async (context, request) => await runCommand(context, request, {
|
|
118
|
+
name: "vitest",
|
|
119
|
+
prepare: async (settled, signal) => await planRun(context.app, context.ui.progress, request, settled, signal),
|
|
120
|
+
ran: (facts, plan) => outcomes.ran({ ...facts, plan })
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async function planRun(app, progress, request, settled, signal) {
|
|
125
|
+
const { args } = request;
|
|
126
|
+
const { where } = settled;
|
|
127
|
+
const root = await app.context.checkout.repositoryRoot({ cwd: app.cwd });
|
|
128
|
+
let cwd;
|
|
129
|
+
let searchRoot;
|
|
130
|
+
if (where.kind === "local") {
|
|
131
|
+
cwd = app.cwd;
|
|
132
|
+
searchRoot = root.ok ? root.value : parse(app.cwd).root;
|
|
133
|
+
} else {
|
|
134
|
+
if (!root.ok) return refused(checkoutFailedRefusal(root.failure));
|
|
135
|
+
cwd = join(root.value, where.recipe.cwd);
|
|
136
|
+
searchRoot = root.value;
|
|
137
|
+
}
|
|
138
|
+
const found = await app.context.vitestList.findVitest({ from: cwd, root: searchRoot });
|
|
139
|
+
if (!found.ok)
|
|
140
|
+
return refused(
|
|
141
|
+
outcomes.vitestListFailed({
|
|
142
|
+
kind: "start-failed",
|
|
143
|
+
message: `found no vitest in node_modules/.bin of ${found.searched.join(", ")}`,
|
|
144
|
+
args: [...args],
|
|
145
|
+
cwd
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
const planned = await planVitestRun({ args, cwd, executable: found.path, signal }, app.context.vitestList);
|
|
149
|
+
if (!planned.ok) {
|
|
150
|
+
const { failure } = planned;
|
|
151
|
+
if (failure.kind === "canceled") return refused(canceledBeforeStart());
|
|
152
|
+
return refused(
|
|
153
|
+
outcomes.vitestListFailed({
|
|
154
|
+
kind: failure.kind,
|
|
155
|
+
message: describeVitestListFailure(failure),
|
|
156
|
+
args: [...args],
|
|
157
|
+
cwd
|
|
158
|
+
})
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
const { tests, files } = planned.plan;
|
|
162
|
+
if (tests === 0) return refused(outcomes.noMatchingTests({ args: [...args], cwd }));
|
|
163
|
+
const sized = sizeRun(settled, request, { tests, files });
|
|
164
|
+
await progress?.(planLine(sized.plan));
|
|
165
|
+
const executable = where.kind === "local" ? found.path : "vitest";
|
|
166
|
+
return { ok: true, argv: vitestRunArgv(executable, args), settled: sized.settled, plan: sized.plan };
|
|
91
167
|
}
|
|
92
|
-
/**
|
|
93
|
-
* The run's test plan, and the settled run with the Testserver sandbox count it asks for: without a Testserver side,
|
|
94
|
-
* none; from `--testserver-sandboxes` or the config file, as settled; otherwise `autoSandboxes(files)`, in place of the
|
|
95
|
-
* option's default in both the resource's options and its request.
|
|
96
|
-
*/
|
|
97
168
|
function sizeRun(settled, request, { tests, files }) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
plan: { ...counted, sandboxes, sandboxesFrom: "auto" },
|
|
117
|
-
};
|
|
169
|
+
const pool = settled.options.testserverPool;
|
|
170
|
+
const requested = settled.settlement.requests.testserverPool;
|
|
171
|
+
const counted = { tests, files, sandboxes: null, sandboxesFrom: null };
|
|
172
|
+
if (pool === void 0 || requested === void 0) return { settled, plan: counted };
|
|
173
|
+
const source = testserverSandboxesSource(request, settled.file);
|
|
174
|
+
if (source !== "default") return { settled, plan: { ...counted, sandboxes: pool.sandboxes, sandboxesFrom: source } };
|
|
175
|
+
const sandboxes = autoSandboxes(files);
|
|
176
|
+
return {
|
|
177
|
+
settled: {
|
|
178
|
+
...settled,
|
|
179
|
+
options: { ...settled.options, testserverPool: { ...pool, sandboxes } },
|
|
180
|
+
settlement: {
|
|
181
|
+
...settled.settlement,
|
|
182
|
+
requests: { ...settled.settlement.requests, testserverPool: { ...requested, sandboxes } }
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
plan: { ...counted, sandboxes, sandboxesFrom: "auto" }
|
|
186
|
+
};
|
|
118
187
|
}
|
|
119
|
-
/**
|
|
120
|
-
* The plan as a person reads it before the run: `Running 65 tests in 19 files on 5 Testserver sandboxes (one per 4
|
|
121
|
-
* files, at most 8)`, naming where the count came from, or without a Testserver side `Running 65 tests in 19 files`.
|
|
122
|
-
*/
|
|
123
188
|
function planLine(plan) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
189
|
+
const counted = `Running ${formatPlan(plan)}`;
|
|
190
|
+
if (plan.sandboxes === null) return counted;
|
|
191
|
+
const on = `${counted} on ${plan.sandboxes} Testserver ${plan.sandboxes === 1 ? "sandbox" : "sandboxes"}`;
|
|
192
|
+
switch (plan.sandboxesFrom) {
|
|
193
|
+
case "auto":
|
|
194
|
+
return `${on} (one per ${WORKERS_PER_SANDBOX} files, at most ${AUTO_SANDBOXES_MAX})`;
|
|
195
|
+
case "flag":
|
|
196
|
+
return `${on} (--testserver-sandboxes)`;
|
|
197
|
+
case "file":
|
|
198
|
+
return `${on} (resources.testserverPool.sandboxes in storm.config.ts)`;
|
|
199
|
+
case null:
|
|
200
|
+
return on;
|
|
201
|
+
}
|
|
138
202
|
}
|
|
203
|
+
export {
|
|
204
|
+
command
|
|
205
|
+
};
|
|
@@ -1,39 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import {
|
|
2
|
+
RUN_FIELDS,
|
|
3
|
+
RUN_USAGE_FLAGS
|
|
4
|
+
} from "../../chunks/chunk-7O6UN63H.js";
|
|
5
|
+
|
|
6
|
+
// src/commands/vitest/metadata.ts
|
|
7
|
+
var metadata = {
|
|
8
|
+
description: "Run vitest run with the run payload in STORM_RUN, after counting its tests and sizing the run. storm's flags come first; every other argument goes to vitest run unchanged, in order. Put vitest's own dash options, such as -t or --project, after --. Before anything is minted, leased or started, it counts the tests with vitest list --json and the same arguments, on this machine, with this machine's environment: in the working directory for a local run (--local), and in <repository root>/<runner cwd> for a runner run, the directory where vitest runs in the runner sandbox. It refuses with no_matching_tests when vitest lists none, and with vitest_list_failed when listing fails; vitest list refuses some options only vitest run takes. A signal while it counts stops vitest list and cancels the run. A vitest config that resolves only inside the runner sandbox can't be counted here: run it with storm exec. With a Testserver side (resources.testserverPool in storm.config.ts, or any --testserver-* flag), the run gets --testserver-sandboxes if given, else resources.testserverPool.sandboxes in storm.config.ts, else one Testserver sandbox per 4 test files, at least 1 and at most 8; it says the count and where it came from on stderr before it leases. In a local run, vitest is the nearest node_modules/.bin/vitest from the working directory up to the repository's root, or the filesystem's root outside a repository; in a runner run, vitest from the runner's PATH, which starts with node_modules/.bin of the runner cwd and of the repository's root. Otherwise it runs as storm exec does: in a runner sandbox by default or on this machine with --local, with a live view or plain lines on stderr, a waterfall, a run directory that storm runs show reads back, and the exit code of vitest. The run's result and its run directory's run.json carry the test plan: the tests and files counted, and the Testserver sandbox count and where it came from.",
|
|
9
|
+
summary: "Count the tests, size the run, and run vitest.",
|
|
10
|
+
usages: [`${RUN_USAGE_FLAGS} [<vitest run args>...] [-- <vitest dash options>...]`],
|
|
11
|
+
fields: {
|
|
12
|
+
...RUN_FIELDS,
|
|
13
|
+
testserverSandboxes: {
|
|
14
|
+
valueLabel: "N",
|
|
15
|
+
description: "How many Testserver sandboxes the command gets, 1 to 32, overriding resources.testserverPool.sandboxes in storm.config.ts; without either, one per 4 test files vitest list counted, at least 1 and at most 8. Gives the run a Testserver side."
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
args: {
|
|
18
|
+
valueLabel: "args",
|
|
19
|
+
description: "What vitest run gets, unchanged and in order: every argument that isn't one of storm's flags, such as file filters, then everything after --, such as -t or --project. vitest list --json gets the same arguments when it counts the tests."
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
examples: [
|
|
23
|
+
{
|
|
24
|
+
argv: "",
|
|
25
|
+
description: "Run every test in a runner sandbox, with the runner recipe, team and project from storm.config.ts, and its Testserver side sized from the test count."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
argv: "test/api -- -t creates",
|
|
29
|
+
description: "Run the tests named creates in the files under test/api."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
argv: "--testserver-build pr:104196",
|
|
33
|
+
description: "Run every test against the Testserver build of vercel/api pull request 104196's head commit."
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
argv: "--local --testserver-no-create",
|
|
37
|
+
description: "Run on this machine, on Testserver sandboxes already in the pool, never minting."
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
argv: "--testserver-sandboxes 6 -- --project testserver",
|
|
41
|
+
description: "Run vitest's testserver project against 6 Testserver sandboxes, whatever the test count."
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
metadata
|
|
39
47
|
};
|
|
@@ -301,6 +301,14 @@ export declare const outcomes: import("@vercel/clinkr").Outcomes<{
|
|
|
301
301
|
};
|
|
302
302
|
cleanup: import("../exec/cleanup.ts").StormCleanupFacts;
|
|
303
303
|
}]>;
|
|
304
|
+
runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
|
|
305
|
+
variables: {
|
|
306
|
+
name: string;
|
|
307
|
+
problem: "missing" | "multiline" | "short";
|
|
308
|
+
}[];
|
|
309
|
+
minLength: number;
|
|
310
|
+
configFile: string | null;
|
|
311
|
+
}]>;
|
|
304
312
|
snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
|
|
305
313
|
snapshotId: string;
|
|
306
314
|
base: string;
|
|
@@ -557,6 +565,14 @@ export declare const outcomes: import("@vercel/clinkr").Outcomes<{
|
|
|
557
565
|
};
|
|
558
566
|
cleanup: import("../exec/cleanup.ts").StormCleanupFacts;
|
|
559
567
|
}]>;
|
|
568
|
+
readonly runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
|
|
569
|
+
variables: {
|
|
570
|
+
name: string;
|
|
571
|
+
problem: "missing" | "multiline" | "short";
|
|
572
|
+
}[];
|
|
573
|
+
minLength: number;
|
|
574
|
+
configFile: string | null;
|
|
575
|
+
}]>;
|
|
560
576
|
readonly snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
|
|
561
577
|
snapshotId: string;
|
|
562
578
|
base: string;
|
package/dist/context.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface StormExit {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* The Clinkr application context (`app`) every command receives, the resources' own commands among them, which the
|
|
53
|
-
*
|
|
53
|
+
* resource command trees are checked against (`RESOURCE_COMMAND_TREES`, `src/resource-commands.ts`).
|
|
54
54
|
*/
|
|
55
55
|
export interface StormApp {
|
|
56
56
|
readonly context: StormContext;
|
package/dist/core/events.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MintTarget } from "../credential/index.ts";
|
|
2
2
|
import type { RunnerEvent, RunnerSandboxPlan, SnapshotCacheNote } from "../runner/index.ts";
|
|
3
3
|
import type { Clock } from "../time/index.ts";
|
|
4
|
-
import type { TestEvent } from "../sdk/
|
|
4
|
+
import type { TestEvent } from "../sdk/host.ts";
|
|
5
5
|
import type { AnyResources, ResourceEvent, ResourceFailures, ResourceHoldings, RunLane } from "./resource.ts";
|
|
6
6
|
import type { RanCommand } from "./timing.ts";
|
|
7
7
|
/** How a lane ended: ready for the command, failed, or stopped short of ready. */
|
package/dist/core/payload.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RunPayload } from "../sdk/
|
|
1
|
+
import { type RunPayload } from "../sdk/host.ts";
|
|
2
2
|
/**
|
|
3
3
|
* The run payload for a run holding `resources`, each resource's entry under its name (the resource providers'
|
|
4
4
|
* `payload`); `{}` for a run that holds none. It names `testEvents` as the file the command appends test events to,
|
package/dist/core/payload.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RUN_PAYLOAD_VARIABLE } from "../sdk/
|
|
1
|
+
import { RUN_PAYLOAD_VARIABLE } from "../sdk/host.js";
|
|
2
2
|
/**
|
|
3
3
|
* The run payload for a run holding `resources`, each resource's entry under its name (the resource providers'
|
|
4
4
|
* `payload`); `{}` for a run that holds none. It names `testEvents` as the file the command appends test events to,
|
package/dist/core/provider.d.ts
CHANGED
|
@@ -17,10 +17,20 @@ export type FittingConfig<Name extends string, Kind extends ResourceKind> = AnyR
|
|
|
17
17
|
/**
|
|
18
18
|
* A command tree a resource adds to the host's CLI, whose commands take app `App` (`CommandBuilder<App>`): Clinkr
|
|
19
19
|
* mounts the tree's directory at `mount.path` and hands each command the host's app. A tree that takes `App` is a tree
|
|
20
|
-
* of every app that is one, so the
|
|
20
|
+
* of every app that is one, so the host checks its app by typing the trees with it.
|
|
21
21
|
*/
|
|
22
22
|
export interface ResourceCommandTree<App> {
|
|
23
|
-
|
|
23
|
+
/** The tree's mount, but for its source's directory, which `directory` names. */
|
|
24
|
+
readonly mount: Omit<CommandMount, "source"> & {
|
|
25
|
+
readonly source: {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The tree's directory, relative to storm's code root, the directory `application.ts` sits in: `src/` from source,
|
|
31
|
+
* `dist/` built. Relative, not from `import.meta`, since a bundled build moves the module's code to another file.
|
|
32
|
+
*/
|
|
33
|
+
readonly directory: string;
|
|
24
34
|
/** For its type only: what the tree's commands take, as a parameter, so the tree is a tree of any app that is one. */
|
|
25
35
|
readonly takes?: (app: App) => void;
|
|
26
36
|
}
|
package/dist/core/run.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CredentialGateway, type CredentialSourceChoice, type GitHubActionsTokenGateway, type MintFailure, type MintTarget } from "../credential/index.ts";
|
|
2
|
-
import { type PreparedRunner, type RunnerContext, type RunnerFailure, type RunnerSandboxPlan, type RunnerSave, type RunnerScopeReport, type RunnerSnapshotCacheFailure, type RunnerSnapshotEntry } from "../runner/index.ts";
|
|
2
|
+
import { type PreparedRunner, type RunnerContext, type RunnerFailure, type RunnerSandboxPlan, type RunnerSave, type RunnerScopeReport, type RunnerSecrets, type RunnerSnapshotCacheFailure, type RunnerSnapshotEntry } from "../runner/index.ts";
|
|
3
3
|
import type { RunProgress } from "./events.ts";
|
|
4
4
|
import type { CommandGateway } from "./gateways.ts";
|
|
5
5
|
import type { CoreContext, RunProviders, ResourceCanceledFacts, ResourceCleanup, ResourceFacts, ResourceRefusal, ResourceRequests, ResourceUnprepared } from "./resource.ts";
|
|
@@ -23,6 +23,11 @@ export interface RunRunnerRequest {
|
|
|
23
23
|
readonly target: MintTarget;
|
|
24
24
|
/** The local user name, for each sandbox's `user` tag. */
|
|
25
25
|
readonly user: string;
|
|
26
|
+
/**
|
|
27
|
+
* The runner secrets' values, read from this machine's environment as the run started: each recipe step gets the
|
|
28
|
+
* ones it names, the command gets none, and storm writes none to the run directory, the snapshot cache or `run.json`.
|
|
29
|
+
*/
|
|
30
|
+
readonly secrets: RunnerSecrets;
|
|
26
31
|
/**
|
|
27
32
|
* What the run does with the runner sandbox once it ends, decided before it starts: keep it running for the keep time
|
|
28
33
|
* (0 stops and deletes it), or, under `--save-snapshot` on a branch, save it as a branch snapshot once the command
|
package/dist/core/run.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
2
|
import { credentialSourceFor, mintSource, } from "../credential/index.js";
|
|
3
3
|
import { readyRunner, runnerSandboxScope, REMOTE_TEST_EVENTS_PATH, keptMs, lineSplitter, runRemote, saveBranchSnapshot, } from "../runner/index.js";
|
|
4
|
-
import { parseTestEvent } from "../sdk/
|
|
4
|
+
import { parseTestEvent } from "../sdk/host.js";
|
|
5
5
|
import { mintReported, mintSourceReported } from "./mint.js";
|
|
6
6
|
import { colorEnvironment, commandEnvironment, runPayload } from "./payload.js";
|
|
7
7
|
import { acquireResources, canceledHolding, heldLanes, heldResources, prepareResources, readyResources, releaseResources, resourceFailures, resourceHoldings, resourceSlots, resourcesFacts, resourcesPayload, } from "./resources.js";
|
|
@@ -349,7 +349,7 @@ async function readyBoth(context, request, control, progress, runnerProgress) {
|
|
|
349
349
|
progress,
|
|
350
350
|
beside: {
|
|
351
351
|
lane: "runner",
|
|
352
|
-
start: (signal) => readyRunner(context, { prepared: runner.prepared, access: request.access, user: runner.user }, { scope: control.scope, signal }, runnerProgress),
|
|
352
|
+
start: (signal) => readyRunner(context, { prepared: runner.prepared, access: request.access, user: runner.user, secrets: runner.secrets }, { scope: control.scope, signal }, runnerProgress),
|
|
353
353
|
outcomeOf: runnerLaneOutcome,
|
|
354
354
|
stopped: runnerStopped,
|
|
355
355
|
},
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NodeHost } from "@vercel/clinkr/node";
|
|
2
|
+
import { type StormApp, type StormExit } from "./context.ts";
|
|
3
|
+
/** What the executable knows about its own build: the package's version, and the commit as the version line shows it. */
|
|
4
|
+
export interface StormBuild {
|
|
5
|
+
readonly version: string;
|
|
6
|
+
readonly commit: string | null;
|
|
7
|
+
}
|
|
8
|
+
/** The live app over the resolved host, whose commands record their status in `exit`, which the executable reads. */
|
|
9
|
+
export declare function liveStormApp(host: NodeHost, build: StormBuild, exit: StormExit): StormApp;
|
package/dist/live-app.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The app storm's executable hands every command: the live Context and what a run needs from the host. Only
|
|
2
|
+
// `bin/storm.ts` loads this module, inside its `app` factory, which Clinkr calls only when a command runs; so help,
|
|
3
|
+
// listings, `--version`, and invocation errors never load the resource registry, the runner, or the SDK.
|
|
4
|
+
import { liveContext } from "./context.js";
|
|
5
|
+
import { resolvePresentation } from "./presentation.js";
|
|
6
|
+
import { RESOURCE_CONFIGS } from "./resources.js";
|
|
7
|
+
import { localUserName } from "./runner/index.js";
|
|
8
|
+
/** The live app over the resolved host, whose commands record their status in `exit`, which the executable reads. */
|
|
9
|
+
export function liveStormApp(host, build, exit) {
|
|
10
|
+
return {
|
|
11
|
+
context: liveContext({ env: host.env }),
|
|
12
|
+
resourceConfigs: RESOURCE_CONFIGS,
|
|
13
|
+
env: host.env,
|
|
14
|
+
cwd: host.cwd,
|
|
15
|
+
version: build.version,
|
|
16
|
+
commit: build.commit,
|
|
17
|
+
user: localUserName(),
|
|
18
|
+
presentation: resolvePresentation(host),
|
|
19
|
+
exit,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CommandMount } from "@vercel/clinkr";
|
|
2
|
+
import type { StormApp } from "./context.ts";
|
|
3
|
+
import type { ResourceCommandTree } from "./core/index.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Every resource's command tree, in provider order, checked against the app Clinkr hands their commands: a tree whose
|
|
6
|
+
* commands take something `StormApp` lacks, or holds in another type, fails here.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RESOURCE_COMMAND_TREES: readonly ResourceCommandTree<StormApp>[];
|
|
9
|
+
/**
|
|
10
|
+
* Every resource's command tree's mount, which `application.ts` mounts beside the host's own commands, with each tree's
|
|
11
|
+
* directory under `root`, storm's code root (`src/` or `dist/`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function resourceMounts(root: string): readonly CommandMount[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The resources' own command trees, which `application.ts` mounts beside storm's commands. It is the one file besides
|
|
2
|
+
// the registry (`src/resources.ts`) that names a resource, and it imports only each resource's `command-tree.ts`,
|
|
3
|
+
// which loads no run code: help lists `pool` without loading the registry, the resources, the runner, or the SDK.
|
|
4
|
+
// `.oxlintrc.json` holds this file to `command-tree.ts`; `test/unit/resource-commands.test.ts` holds its list to the
|
|
5
|
+
// providers' `commands`. `scripts/bundle.js` reads the list from tsc's build to bundle each tree's commands.
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { testserverPoolCommandTree } from "./resources/testserver/command-tree.js";
|
|
8
|
+
/**
|
|
9
|
+
* Every resource's command tree, in provider order, checked against the app Clinkr hands their commands: a tree whose
|
|
10
|
+
* commands take something `StormApp` lacks, or holds in another type, fails here.
|
|
11
|
+
*/
|
|
12
|
+
export const RESOURCE_COMMAND_TREES = [testserverPoolCommandTree];
|
|
13
|
+
/**
|
|
14
|
+
* Every resource's command tree's mount, which `application.ts` mounts beside the host's own commands, with each tree's
|
|
15
|
+
* directory under `root`, storm's code root (`src/` or `dist/`).
|
|
16
|
+
*/
|
|
17
|
+
export function resourceMounts(root) {
|
|
18
|
+
return RESOURCE_COMMAND_TREES.map(({ mount, directory }) => ({
|
|
19
|
+
...mount,
|
|
20
|
+
source: { ...mount.source, directory: join(root, directory) },
|
|
21
|
+
}));
|
|
22
|
+
}
|