@cnc-tools/storm 0.9.0 → 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.js +35 -21
- package/dist/commands/exec/metadata.js +66 -58
- 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-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.js +195 -128
- package/dist/commands/vitest/metadata.js +45 -37
- 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.js +1 -1
- 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/recipe.js +1 -1
- package/dist/runner/remote-command.js +1 -1
- 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/bin/node-version.js +0 -24
- package/dist/closed-terminal.d.ts +0 -7
- package/dist/closed-terminal.js +0 -18
|
@@ -1,49 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
// src/resources/testserver/commands/create/metadata.ts
|
|
2
|
+
var metadata = {
|
|
3
|
+
description: "Get a credential (mint one, or with --credential github-actions request a GitHub Actions OIDC token), create one Testserver sandbox with the TTL --ttl gives, and add it to the pool, unleased. Prints its Testserver URL, log viewer URL, and the build it resolved to; for a vercel/api pull request, also the head commit. A flag overrides storm.config.ts, found in the working directory or a parent up to the git worktree's root and checked whole, which overrides the built-in default.",
|
|
4
|
+
usages: ["[--build <BUILD>] [--ttl <DURATION>] [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>]"],
|
|
5
|
+
summary: "Create a Testserver sandbox and add it to the pool.",
|
|
6
|
+
fields: {
|
|
7
|
+
scope: {
|
|
8
|
+
valueLabel: "TEAM",
|
|
9
|
+
description: "The control plane team: the Vercel team whose project's development OIDC tokens the Testserver control plane trusts. Required with the mint, from this flag or scope in storm.config.ts; unused with --credential github-actions."
|
|
10
|
+
},
|
|
11
|
+
project: {
|
|
12
|
+
valueLabel: "PROJECT",
|
|
13
|
+
description: "The control plane project: the Vercel project, within the team, to mint the credential for. Required with the mint, from this flag or project in storm.config.ts; unused with --credential github-actions."
|
|
14
|
+
},
|
|
15
|
+
build: {
|
|
16
|
+
valueLabel: "BUILD",
|
|
17
|
+
description: "The build to create the Testserver sandbox on: a build name, the build channel stable or latest_main, or a vercel/api pull request as pr:<N> or its URL. A pull request creates on the newest build made from its head commit, which storm reads from GitHub with GITHUB_TOKEN, GH_TOKEN or gh auth token, or refuses. Default stable, or resources.testserverPool.build in storm.config.ts."
|
|
18
|
+
},
|
|
19
|
+
ttl: {
|
|
20
|
+
valueLabel: "DURATION",
|
|
21
|
+
description: "How long the Testserver sandbox lives, in whole minutes or hours from 10m to 5h. Default 5h, or resources.testserverPool.ttl in storm.config.ts."
|
|
22
|
+
},
|
|
23
|
+
credential: {
|
|
24
|
+
valueLabel: "SOURCE",
|
|
25
|
+
description: "The credential source: mint, the default, mints one with the vercel CLI for --scope and --project; github-actions requests a GitHub Actions OIDC token, in a GitHub Actions job with permissions id-token: write, and needs no --scope or --project. No config key."
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
examples: [
|
|
29
|
+
{
|
|
30
|
+
argv: "--scope vercel --project vercel",
|
|
31
|
+
description: "Create a Testserver sandbox on the stable build channel and add it to the pool."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
argv: "--scope vercel --project vercel --ttl 30m",
|
|
35
|
+
description: "Create one that lives 30 minutes."
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
argv: "--scope vercel --project vercel --build latest_main --json",
|
|
39
|
+
description: "Create one on the newest main build and print its details as JSON."
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
argv: "--scope vercel --project vercel --build pr:104196 --json",
|
|
43
|
+
description: "Create one on the Testserver build of vercel/api pull request 104196's head commit."
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
argv: "--credential github-actions --ttl 10m",
|
|
47
|
+
description: "In a GitHub Actions job, create one with a GitHub Actions OIDC token."
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
metadata
|
|
49
53
|
};
|
|
@@ -1,56 +1,201 @@
|
|
|
1
|
+
import {
|
|
2
|
+
inspectPool
|
|
3
|
+
} from "../../../../chunks/chunk-5CQCRX2L.js";
|
|
4
|
+
|
|
5
|
+
// src/resources/testserver/commands/list/command.ts
|
|
6
|
+
import { z as z2 } from "zod";
|
|
7
|
+
|
|
8
|
+
// src/resources/testserver/commands/list/outcomes.ts
|
|
9
|
+
import { defineOutcomes, renderOutcome } from "@vercel/clinkr";
|
|
1
10
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
11
|
+
var entrySchema = z.object({
|
|
12
|
+
/** The Testserver URL, with no trailing slash. */
|
|
13
|
+
testserverUrl: z.string(),
|
|
14
|
+
/** The log viewer URL, with no trailing slash. */
|
|
15
|
+
logViewerUrl: z.string(),
|
|
16
|
+
/** The build or build channel the Testserver sandbox was created with. */
|
|
17
|
+
requestedBuild: z.string(),
|
|
18
|
+
/** The build the Testserver sandbox runs. */
|
|
19
|
+
resolvedBuild: z.string(),
|
|
20
|
+
/** When its create started, by the client clock. */
|
|
21
|
+
createdAt: z.string(),
|
|
22
|
+
ttlMinutes: z.number(),
|
|
23
|
+
/** Whole minutes left by its TTL; negative once past it. */
|
|
24
|
+
minutesLeft: z.number(),
|
|
25
|
+
lease: z.object({
|
|
26
|
+
/** `free` with no lease; `stale` when its holder died or the lease outlived the TTL; otherwise `leased`. */
|
|
27
|
+
state: z.enum(["free", "leased", "stale"]),
|
|
28
|
+
/** The holder's pid and hostname; null when free or when the lease file can't be read. */
|
|
29
|
+
pid: z.number().nullable(),
|
|
30
|
+
hostname: z.string().nullable(),
|
|
31
|
+
/** When the lease was taken, or the lease file's modification time when it can't be read; null when free. */
|
|
32
|
+
startedAt: z.string().nullable(),
|
|
33
|
+
/** Whether the holder still runs; null when free, when it runs on another host, or when the lease file can't be read. */
|
|
34
|
+
holderAlive: z.boolean().nullable()
|
|
35
|
+
}),
|
|
36
|
+
/**
|
|
37
|
+
* Whether a lease guard directory is present beside its lease: held by a running storm run, or left behind
|
|
38
|
+
* by one that died. A guard left behind stops every run from releasing, reclaiming, or dropping that lease
|
|
39
|
+
* until it is removed by hand.
|
|
40
|
+
*/
|
|
41
|
+
leaseGuard: z.boolean(),
|
|
42
|
+
health: z.object({
|
|
43
|
+
/** `answers` with a 2xx, `expired` with a 410 or 502, `failed` otherwise. */
|
|
44
|
+
kind: z.enum(["answers", "expired", "failed"]),
|
|
45
|
+
/** The HTTP status it answered with; null when the health check failed. */
|
|
46
|
+
status: z.number().nullable(),
|
|
47
|
+
/** Why the health check failed; null otherwise. */
|
|
48
|
+
detail: z.string().nullable()
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
var listedSchema = z.object({
|
|
52
|
+
/** Where the pool lives. */
|
|
53
|
+
poolPath: z.string(),
|
|
54
|
+
/** Every pool entry, by host. */
|
|
55
|
+
entries: z.array(entrySchema),
|
|
56
|
+
/** The entry files storm can't read, which it leaves on disk. */
|
|
57
|
+
unreadable: z.array(z.object({ file: z.string(), reason: z.string() })),
|
|
58
|
+
/** What each build channel last resolved to. */
|
|
59
|
+
channels: z.array(
|
|
60
|
+
z.object({ channel: z.string(), build: z.string(), learnedAt: z.string(), ageMinutes: z.number() })
|
|
61
|
+
)
|
|
62
|
+
});
|
|
63
|
+
var outcomes = defineOutcomes({
|
|
64
|
+
results: {
|
|
65
|
+
listed: {
|
|
66
|
+
schema: listedSchema,
|
|
67
|
+
description: "The pool's entries, each health-checked; an empty pool has none.",
|
|
68
|
+
render: (listed) => renderOutcome({
|
|
69
|
+
rows: [["Pool", listed.poolPath]],
|
|
70
|
+
...listed.entries.length === 0 ? { message: "The pool is empty." } : {
|
|
71
|
+
table: {
|
|
72
|
+
columns: ["TESTSERVER URL", "LEASE", "HEALTH", "LEFT", "RESOLVED BUILD", "REQUESTED BUILD"],
|
|
73
|
+
rows: listed.entries.map((entry) => [
|
|
74
|
+
entry.testserverUrl,
|
|
75
|
+
leaseCell(entry),
|
|
76
|
+
healthCell(entry),
|
|
77
|
+
entry.minutesLeft > 0 ? `${entry.minutesLeft}m` : "none",
|
|
78
|
+
entry.resolvedBuild,
|
|
79
|
+
entry.requestedBuild
|
|
80
|
+
])
|
|
81
|
+
}
|
|
29
82
|
},
|
|
83
|
+
sections: [
|
|
84
|
+
...listed.channels.length === 0 ? [] : [
|
|
85
|
+
{
|
|
86
|
+
heading: "Channel resolutions",
|
|
87
|
+
rows: listed.channels.map(({ channel, build, ageMinutes }) => [
|
|
88
|
+
channel,
|
|
89
|
+
`${build}, learned ${ageMinutes}m ago`
|
|
90
|
+
])
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
...listed.unreadable.length === 0 ? [] : [
|
|
94
|
+
{
|
|
95
|
+
heading: "Unreadable entry files",
|
|
96
|
+
rows: listed.unreadable.map(({ file, reason }) => [file, reason])
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
],
|
|
100
|
+
warnings: warnings(listed.entries)
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
errors: {
|
|
105
|
+
poolUnreadable: {
|
|
106
|
+
exitCode: 1,
|
|
107
|
+
description: "storm couldn't read the pool.",
|
|
108
|
+
schema: z.object({
|
|
109
|
+
/** The pool file or directory the read failed on. */
|
|
110
|
+
path: z.string(),
|
|
111
|
+
/** What the OS said. */
|
|
112
|
+
message: z.string()
|
|
113
|
+
}),
|
|
114
|
+
render: ({ path, message }) => ({
|
|
115
|
+
message: `Couldn't read the pool: ${message}`,
|
|
116
|
+
rows: [["Pool path", path]]
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
function leaseCell(entry) {
|
|
122
|
+
const { lease } = entry;
|
|
123
|
+
if (lease.state === "free") return "free";
|
|
124
|
+
if (lease.pid === null) return `${lease.state}, holder unknown (unreadable lease file)`;
|
|
125
|
+
return `${lease.state}, pid ${lease.pid} on ${lease.hostname ?? ""}`;
|
|
126
|
+
}
|
|
127
|
+
function healthCell(entry) {
|
|
128
|
+
const { health } = entry;
|
|
129
|
+
switch (health.kind) {
|
|
130
|
+
case "answers":
|
|
131
|
+
return "answers";
|
|
132
|
+
case "expired":
|
|
133
|
+
return `expired (HTTP ${health.status ?? "?"})`;
|
|
134
|
+
case "failed":
|
|
135
|
+
return `failed (${health.detail ?? "unknown"})`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function warnings(entries) {
|
|
139
|
+
const found = [];
|
|
140
|
+
const expired = entries.filter((entry) => entry.health.kind === "expired").length;
|
|
141
|
+
if (expired > 0)
|
|
142
|
+
found.push({
|
|
143
|
+
reason: "expired_entries",
|
|
144
|
+
message: `${expired === 1 ? "1 Testserver sandbox has" : `${expired} Testserver sandboxes have`} expired. A later storm run drops ${expired === 1 ? "it" : "them"} from the pool.`
|
|
30
145
|
});
|
|
146
|
+
const guarded = entries.filter((entry) => entry.leaseGuard);
|
|
147
|
+
if (guarded.length > 0)
|
|
148
|
+
found.push({
|
|
149
|
+
reason: "lease_guard_present",
|
|
150
|
+
message: `A lease guard is present on the lease on ${guarded.map((entry) => entry.testserverUrl).join(", ")}. A storm run holds one while it releases, reclaims, or drops that lease; if no storm run is active, it was left behind, and no run will release, reclaim, or drop that lease until you remove its leases/<host>.guard directory in the pool by hand.`
|
|
151
|
+
});
|
|
152
|
+
return found;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/resources/testserver/commands/list/command.ts
|
|
156
|
+
function command(cmd) {
|
|
157
|
+
return cmd.define({
|
|
158
|
+
requestSchema: z2.object({}).strict(),
|
|
159
|
+
response: outcomes,
|
|
160
|
+
handler: async ({ app }) => {
|
|
161
|
+
const inspected = await inspectPool(app.context);
|
|
162
|
+
if (!inspected.ok) return outcomes.poolUnreadable({ ...inspected.failure });
|
|
163
|
+
const { directory, entries, unreadable, channels } = inspected.value;
|
|
164
|
+
return outcomes.listed({
|
|
165
|
+
poolPath: directory,
|
|
166
|
+
entries: entries.map(listedEntry),
|
|
167
|
+
unreadable: unreadable.map(({ file, reason }) => ({ file, reason })),
|
|
168
|
+
channels: channels.map(({ channel, build, learnedAt, ageMinutes }) => ({
|
|
169
|
+
channel,
|
|
170
|
+
build,
|
|
171
|
+
learnedAt,
|
|
172
|
+
ageMinutes
|
|
173
|
+
}))
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
31
177
|
}
|
|
32
178
|
function listedEntry(inspected) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
health: health.kind === "failed"
|
|
53
|
-
? { kind: health.kind, status: null, detail: health.detail }
|
|
54
|
-
: { kind: health.kind, status: health.status, detail: null },
|
|
55
|
-
};
|
|
179
|
+
const { entry, lease, health } = inspected;
|
|
180
|
+
return {
|
|
181
|
+
testserverUrl: entry.testserverUrl,
|
|
182
|
+
logViewerUrl: entry.logViewerUrl,
|
|
183
|
+
requestedBuild: entry.requestedBuild,
|
|
184
|
+
resolvedBuild: entry.resolvedBuild,
|
|
185
|
+
createdAt: entry.createdAt,
|
|
186
|
+
ttlMinutes: entry.ttlMinutes,
|
|
187
|
+
minutesLeft: inspected.minutesLeft,
|
|
188
|
+
lease: lease.state === "free" ? { state: lease.state, pid: null, hostname: null, startedAt: null, holderAlive: null } : {
|
|
189
|
+
state: lease.state,
|
|
190
|
+
pid: lease.holder?.pid ?? null,
|
|
191
|
+
hostname: lease.holder?.hostname ?? null,
|
|
192
|
+
startedAt: lease.startedAt,
|
|
193
|
+
holderAlive: lease.holder?.alive ?? null
|
|
194
|
+
},
|
|
195
|
+
leaseGuard: inspected.leaseGuard,
|
|
196
|
+
health: health.kind === "failed" ? { kind: health.kind, status: null, detail: health.detail } : { kind: health.kind, status: health.status, detail: null }
|
|
197
|
+
};
|
|
56
198
|
}
|
|
199
|
+
export {
|
|
200
|
+
command
|
|
201
|
+
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
// src/resources/testserver/commands/list/metadata.ts
|
|
2
|
+
var metadata = {
|
|
3
|
+
description: "List every pool entry with its lease, the time it has left, and a fresh health check, along with the channel resolutions and any entry files storm can't read. Changes nothing: expired entries stay until a later run drops them, and stale leases until a later run reclaims them.",
|
|
4
|
+
summary: "List the pool's Testserver sandboxes.",
|
|
5
|
+
aliases: ["ls"],
|
|
6
|
+
examples: [
|
|
7
|
+
{ argv: "", description: "List the pool." },
|
|
8
|
+
{ argv: "--json", description: "List the pool as JSON, with each lease's holder." }
|
|
9
|
+
]
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
metadata
|
|
9
13
|
};
|
|
@@ -4,7 +4,7 @@ import { type BuildMatch, type BuildResolution, type PoolStoreFailure, type Pool
|
|
|
4
4
|
import type { GitHubTokenGateway, PullRequestGateway, TestserverWorkflowGateway } from "./pull-request/index.ts";
|
|
5
5
|
import { type ControlPlaneGateway, type CreateFailure, type HealthCheckGateway } from "./sandbox/index.ts";
|
|
6
6
|
import type { Timer } from "../../time/index.ts";
|
|
7
|
-
import type { RunPayloadResources } from "../../sdk/
|
|
7
|
+
import type { RunPayloadResources } from "../../sdk/host.ts";
|
|
8
8
|
import type { TestserverPoolCleanupFacts } from "./cleanup.ts";
|
|
9
9
|
import type { TestserverPoolEvent } from "./events.ts";
|
|
10
10
|
import type { TestserverLaneState, TestserverLaneStep } from "./lane.ts";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// The Testserver pool resource's provider: the one value the folder hands the host, which only the registry
|
|
2
2
|
// (`src/resources.ts`) takes.
|
|
3
|
-
import { join } from "node:path";
|
|
4
3
|
import { testserverPoolCleanupReport } from "./cleanup.js";
|
|
5
4
|
import { testserverPoolCommand } from "./command.js";
|
|
5
|
+
import { testserverPoolCommandTree } from "./command-tree.js";
|
|
6
6
|
import { testserverPoolConfig } from "./config.js";
|
|
7
7
|
import { testserverPoolLane } from "./lane.js";
|
|
8
8
|
import { liveTestserverPoolGateways } from "./live/gateways.js";
|
|
@@ -28,11 +28,5 @@ export const testserverPoolProvider = {
|
|
|
28
28
|
liveGateways: liveTestserverPoolGateways,
|
|
29
29
|
hostVariablesToDrop: STALE_TESTSERVER_VARIABLES,
|
|
30
30
|
runnerResources: ({ sandboxes }) => ({ testserverPool: { sandboxes } }),
|
|
31
|
-
commands:
|
|
32
|
-
mount: {
|
|
33
|
-
source: { id: "testserver", directory: join(import.meta.dirname, "commands") },
|
|
34
|
-
path: ["pool"],
|
|
35
|
-
description: "Inspect and maintain your pool of Testserver sandboxes.",
|
|
36
|
-
},
|
|
37
|
-
},
|
|
31
|
+
commands: testserverPoolCommandTree,
|
|
38
32
|
};
|
package/dist/resources.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type StormCleanupFacts } from "./commands/exec/cleanup.ts";
|
|
2
|
-
import type { CommandMount } from "@vercel/clinkr";
|
|
3
2
|
import type { AnyResourceConfig, GivenResources, OptionsResolution, ResolvedResources } from "./config/index.ts";
|
|
4
3
|
import type { StormContext } from "./context.ts";
|
|
5
4
|
import { type KindAt, type KindsOf, type LocalRunRequest, type RemoteRunRequest, type ResourceCleanup, type ResourceFailures, type ResourceHoldings, type ResourceRanFacts, type ResourceHost, type ResourceRefusal, type RunEvent, type RunLane, type RunObserver, type RunOutcome, type RunProviders, type RunRequest, type RunState, type TimedRunEvent, type Timeline, type TimelineRow, type TimelineRowName } from "./core/index.ts";
|
|
@@ -671,8 +670,6 @@ export declare const RESOURCE_COMMANDS: {
|
|
|
671
670
|
canceledLines(resources: import("./core/resource.ts").ResourceCanceledFacts<Resources>, cleanup: ResourceCleanup<Resources>): readonly string[];
|
|
672
671
|
refusedError: (outcome: ResourceRefusal<Resources>, cleanup: StormCleanupFacts) => import("@vercel/clinkr").CommandError<"credential_rejected"> | import("@vercel/clinkr").CommandError<"github_fixture_repo_unavailable"> | import("@vercel/clinkr").CommandError<"no_sandboxes"> | import("@vercel/clinkr").CommandError<"no_usable_sandboxes"> | import("@vercel/clinkr").CommandError<"pool_unreadable"> | import("@vercel/clinkr").CommandError<"pr_build_expired"> | import("@vercel/clinkr").CommandError<"pr_build_not_ready"> | import("@vercel/clinkr").CommandError<"pr_builds_unlisted"> | import("@vercel/clinkr").CommandError<"pull_request_unreadable"> | import("@vercel/clinkr").CommandError<"token_request_failed">;
|
|
673
672
|
};
|
|
674
|
-
/** Every resource's command tree's mount, which `application.ts` mounts beside the host's own commands. */
|
|
675
|
-
export declare const RESOURCE_MOUNTS: readonly CommandMount[];
|
|
676
673
|
/** One record with every member of a union of records. */
|
|
677
674
|
type Intersection<U> = (U extends unknown ? (part: U) => void : never) extends (all: infer I) => void ? I : never;
|
|
678
675
|
/** Every resource's gateways, as one context: what `StormContext` holds beside the core's. */
|
package/dist/resources.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// The registry, in the composition layer: the one file that
|
|
1
|
+
// The registry, in the composition layer: the one file that takes every resource's provider value. It lists the resources' provider
|
|
2
2
|
// values in order (`PROVIDERS`), derives the kinds map `Resources` from that list, and builds everything else the host
|
|
3
3
|
// needs from it: the run halves, the resource lanes and configs, the resource reports, the run's cleanup, the command
|
|
4
|
-
// halves and their errors, and the resources' live gateways.
|
|
4
|
+
// halves and their errors, and the resources' live gateways. The resources' command trees, which help needs without
|
|
5
|
+
// the rest, are in `src/resource-commands.ts`. It fixes the core's generic types and functions for
|
|
5
6
|
// `Resources`, so commands never spell the generic. A resource folder is reached only through its provider value, and
|
|
6
|
-
// only this file takes one; `.oxlintrc.json`
|
|
7
|
+
// only this file takes one (`src/resource-commands.ts` takes only each resource's `command-tree.ts`); `.oxlintrc.json`
|
|
8
|
+
// enforces it.
|
|
7
9
|
import { combineErrors } from "./combine-errors.js";
|
|
8
10
|
import { runCleanupOf } from "./commands/exec/cleanup.js";
|
|
9
11
|
import { applyRunEvent, bindCommands, resourcePresentations, resourceReports, timeline, } from "./core/index.js";
|
|
@@ -60,13 +62,6 @@ export const RESOURCE_COMMANDS = {
|
|
|
60
62
|
...BOUND,
|
|
61
63
|
refusedError: (outcome, cleanup) => REFUSALS.build(BOUND.refusalFacts(outcome), cleanup),
|
|
62
64
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Every resource's command tree, checked against the app Clinkr hands their commands: a tree whose commands take
|
|
65
|
-
* something `StormApp` lacks, or holds in another type, fails here.
|
|
66
|
-
*/
|
|
67
|
-
const COMMAND_TREES = PROVIDERS.flatMap((provider) => "commands" in provider ? [provider.commands] : []);
|
|
68
|
-
/** Every resource's command tree's mount, which `application.ts` mounts beside the host's own commands. */
|
|
69
|
-
export const RESOURCE_MOUNTS = COMMAND_TREES.map(({ mount }) => mount);
|
|
70
65
|
/** Every resource's live gateways, built from `host`, as one context. */
|
|
71
66
|
export function liveResourceGateways(host) {
|
|
72
67
|
let gateways = {};
|
package/dist/runner/recipe.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// each run does on top of it. `checkRecipe` holds the recipe's static rules; `resolveSteps` and `resolveVcpus`
|
|
3
3
|
// evaluate the parts a recipe may give as functions, and check what they return.
|
|
4
4
|
import { parseKeepTime, parseTtl } from "../time/index.js";
|
|
5
|
-
import { RUN_PAYLOAD_VARIABLE } from "../sdk/
|
|
5
|
+
import { RUN_PAYLOAD_VARIABLE } from "../sdk/host.js";
|
|
6
6
|
import { STEP_ENV } from "./steps.js";
|
|
7
7
|
/** The defaults of a recipe's optional keys. */
|
|
8
8
|
export const RECIPE_DEFAULTS = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Running the command in a ready runner sandbox: its argument list with local paths pointed at the sandbox's, its
|
|
2
2
|
// environment, and its output streamed to the terminal a line at a time with the sandbox's paths pointed back here.
|
|
3
3
|
import { posix } from "node:path";
|
|
4
|
-
import { RUN_PAYLOAD_VARIABLE } from "../sdk/
|
|
4
|
+
import { RUN_PAYLOAD_VARIABLE } from "../sdk/host.js";
|
|
5
5
|
import { lineSplitter, rewritePaths, splitLines } from "./output.js";
|
|
6
6
|
import { REMOTE_ROOT } from "./snapshot-key.js";
|
|
7
7
|
import { sandboxApiFailure } from "./steps.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { parseTestEvent, RUN_PAYLOAD_VARIABLE, type RunPayload, type RunPayloadGitHubFixtureRepo, type RunPayloadResources, type TestEvent, testEventLine, type TestResultEvent, type WorkerTestEvent, } from "./payload/index.ts";
|
|
2
|
+
export { redactSecrets } from "./records/index.ts";
|
package/dist/sdk/host.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The SDK's narrow entry for storm's host: what storm's own modules and commands use of the SDK, from the run payload
|
|
2
|
+
// and the records, and nothing that starts containers, seeds data, or proxies requests. The full surface
|
|
3
|
+
// (`index.ts`) loads `node:http`, `node:https`, and the container, factory, seed, and proxy modules, which cost every
|
|
4
|
+
// storm command ~15ms though only a command running under a storm run uses them. It is not a published export:
|
|
5
|
+
// commands, the Vitest adapter, and the Vercel CLI driver import `index.ts`, `@vercel/storm/sdk`.
|
|
6
|
+
export { parseTestEvent, RUN_PAYLOAD_VARIABLE, testEventLine, } from "./payload/index.js";
|
|
7
|
+
export { redactSecrets } from "./records/index.js";
|
package/dist/version.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export declare function commitText(commit: GitCommit): string;
|
|
|
8
8
|
/** The version as root `--version` and a run print it: `0.0.1 (3f2a9c1b7d4e)`, or `0.0.1` with no commit. */
|
|
9
9
|
export declare function versionText(version: string, commit: string | null): string;
|
|
10
10
|
/**
|
|
11
|
-
* Reads the commit checked out in `directory` from git (`git rev-parse HEAD
|
|
12
|
-
* Any failure, git missing or `directory` outside a git worktree, gives `undefined`.
|
|
11
|
+
* Reads the commit checked out in `directory` from git (`git rev-parse HEAD` and `git status --porcelain`, at the
|
|
12
|
+
* same time). Any failure, git missing or `directory` outside a git worktree, gives `undefined`.
|
|
13
13
|
*/
|
|
14
14
|
export declare function readGitCommit(directory: string): Promise<GitCommit | undefined>;
|
|
15
15
|
/**
|
package/dist/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The version line: storm's version and the git commit it was built from. `scripts/write-build-info.js` stamps
|
|
2
2
|
// the commit into `dist/build-info.js` at build time; running from source in the cnc workspace, storm reads it
|
|
3
|
-
// from git
|
|
3
|
+
// from git, only when root `--version` prints it or a command builds the app.
|
|
4
4
|
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
5
5
|
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
6
6
|
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
@@ -21,20 +21,19 @@ export function versionText(version, commit) {
|
|
|
21
21
|
return commit === null ? version : `${version} (${commit})`;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Reads the commit checked out in `directory` from git (`git rev-parse HEAD
|
|
25
|
-
* Any failure, git missing or `directory` outside a git worktree, gives `undefined`.
|
|
24
|
+
* Reads the commit checked out in `directory` from git (`git rev-parse HEAD` and `git status --porcelain`, at the
|
|
25
|
+
* same time). Any failure, git missing or `directory` outside a git worktree, gives `undefined`.
|
|
26
26
|
*/
|
|
27
27
|
export async function readGitCommit(directory) {
|
|
28
28
|
const git = async (...args) => (await promisify(execFile)("git", args, { cwd: directory, encoding: "utf8" })).stdout;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return undefined;
|
|
33
|
-
return { sha, dirty: (await git("status", "--porcelain")).trim() !== "" };
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
29
|
+
// Both finish before this returns, even when one fails, so no git process outlives the call.
|
|
30
|
+
const [head, status] = await Promise.allSettled([git("rev-parse", "HEAD"), git("status", "--porcelain")]);
|
|
31
|
+
if (head.status === "rejected" || status.status === "rejected")
|
|
36
32
|
return undefined;
|
|
37
|
-
|
|
33
|
+
const sha = head.value.trim();
|
|
34
|
+
if (!/^[0-9a-f]{40,64}$/.test(sha))
|
|
35
|
+
return undefined;
|
|
36
|
+
return { sha, dirty: status.value.trim() !== "" };
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
40
39
|
* The commit storm was built from, as the version line shows it. `binUrl` is the `import.meta.url` of
|
package/dist/vitest/config.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { type StormReporter } from "./test-results.ts";
|
|
2
2
|
export type { ReportedConsoleLog, ReportedTestCase, ReportedTestError, ReportedTestModule, StormReporter, } from "./test-results.ts";
|
|
3
|
-
|
|
4
|
-
* The vitest workers per Testserver sandbox `testserverWorkers` sizes for by default: about the number of
|
|
5
|
-
* concurrent test ids a Testserver sandbox serves before its service boots slow down.
|
|
6
|
-
*/
|
|
7
|
-
export declare const WORKERS_PER_SANDBOX = 4;
|
|
3
|
+
export { WORKERS_PER_SANDBOX } from "./sandbox.ts";
|
|
8
4
|
/**
|
|
9
5
|
* A vitest `retry` for a testserver project: one more attempt for a test that failed because a Testserver call's
|
|
10
6
|
* connection failed (`TESTSERVER_CONNECTION_FAILURE`), such as a `read ECONNRESET` between the runner and the
|
|
11
|
-
* Testserver URL, and none for any other failure. The adapter ends a file's container
|
|
12
|
-
* runs on a new container, where a factory call that half-happened on the old one
|
|
13
|
-
* own output marks a test it rescued `(retry x1)`. Spread it to change the count:
|
|
7
|
+
* Testserver URL, and none for any other failure. The adapter ends a file's container after a test whose factory call
|
|
8
|
+
* or API request failed, so the retry runs on a new container, where a factory call that half-happened on the old one
|
|
9
|
+
* can't collide with it. vitest's own output marks a test it rescued `(retry x1)`. Spread it to change the count:
|
|
14
10
|
* `retry: { ...testserverConnectionRetry, count: 2 }`.
|
|
15
11
|
*/
|
|
16
12
|
export declare const testserverConnectionRetry: {
|
package/dist/vitest/config.js
CHANGED
|
@@ -2,19 +2,15 @@
|
|
|
2
2
|
// this, never `@vercel/storm/vitest`: loading the adapter's `test` extends vitest's, which throws inside a config
|
|
3
3
|
// file. So nothing here imports `./fixtures.ts` or vitest.
|
|
4
4
|
import { readRunPayload, RUN_PAYLOAD_VARIABLE, TESTSERVER_CONNECTION_FAILURE } from "../sdk/index.js";
|
|
5
|
-
import { sandboxCount } from "./sandbox.js";
|
|
5
|
+
import { sandboxCount, WORKERS_PER_SANDBOX } from "./sandbox.js";
|
|
6
6
|
import { testResultReporter } from "./test-results.js";
|
|
7
|
-
|
|
8
|
-
* The vitest workers per Testserver sandbox `testserverWorkers` sizes for by default: about the number of
|
|
9
|
-
* concurrent test ids a Testserver sandbox serves before its service boots slow down.
|
|
10
|
-
*/
|
|
11
|
-
export const WORKERS_PER_SANDBOX = 4;
|
|
7
|
+
export { WORKERS_PER_SANDBOX } from "./sandbox.js";
|
|
12
8
|
/**
|
|
13
9
|
* A vitest `retry` for a testserver project: one more attempt for a test that failed because a Testserver call's
|
|
14
10
|
* connection failed (`TESTSERVER_CONNECTION_FAILURE`), such as a `read ECONNRESET` between the runner and the
|
|
15
|
-
* Testserver URL, and none for any other failure. The adapter ends a file's container
|
|
16
|
-
* runs on a new container, where a factory call that half-happened on the old one
|
|
17
|
-
* own output marks a test it rescued `(retry x1)`. Spread it to change the count:
|
|
11
|
+
* Testserver URL, and none for any other failure. The adapter ends a file's container after a test whose factory call
|
|
12
|
+
* or API request failed, so the retry runs on a new container, where a factory call that half-happened on the old one
|
|
13
|
+
* can't collide with it. vitest's own output marks a test it rescued `(retry x1)`. Spread it to change the count:
|
|
18
14
|
* `retry: { ...testserverConnectionRetry, count: 2 }`.
|
|
19
15
|
*/
|
|
20
16
|
export const testserverConnectionRetry = {
|