@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,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/index.d.ts
CHANGED
|
@@ -10,8 +10,9 @@ export { liveRunnerSnapshotCacheGateway, type LiveRunnerSnapshotCacheOptions, un
|
|
|
10
10
|
export { lineSplitter, type LineSplitter, OUTPUT_TAIL_LINES, outputRule, outputTail, type OutputTail, rewritePaths, splitLines, } from "./output.ts";
|
|
11
11
|
export { type PreparedRunner, prepareRunner, type PrepareRunnerOutcome, type PrepareRunnerRequest, type RunnerPrepareContext, } from "./prepare.ts";
|
|
12
12
|
export { APPLY_LABEL, type ReadyRunner, readyRunner, type ReadyRunnerOutcome, type ReadyRunnerRequest, } from "./ready.ts";
|
|
13
|
-
export { type CheckedRecipe, checkRecipe, type RecipeCheck, type RecipeProblem, resolveSteps, resolveVcpus, type RunnerRecipe, type RunnerResources, type RunnerStep, type RunnerStepContext, type RunnerSteps, } from "./recipe.ts";
|
|
13
|
+
export { type CheckedRecipe, checkRecipe, type RecipeCheck, type RecipeProblem, resolveSteps, resolveVcpus, type RunnerRecipe, type RunnerResources, type ResolvedRunnerStep, type RunnerStep, type RunnerStepContext, type RunnerSteps, } from "./recipe.ts";
|
|
14
14
|
export { REMOTE_TEST_EVENTS_PATH, type RemoteCommandOutcome, remoteCommand, remoteEnvironment, type RemoteTestEvents, runRemote, } from "./remote-command.ts";
|
|
15
|
+
export { readRunnerSecrets, RUNNER_SECRET_MIN_LENGTH, stepSecrets, type RunnerSecretProblem, type RunnerSecrets, type RunnerSecretsRead, } from "./secrets.ts";
|
|
15
16
|
export { CREATE_SETTLE_MS, keptMs, type RunnerSandboxPlan, type RunnerSandboxScope, runnerSandboxScope, type RunnerScopeReport, SNAPSHOT_SETTLE_MS, } from "./scope.ts";
|
|
16
17
|
export { BASE_INDEX_LABEL, buildSnapshot, type BuildSnapshotRequest, type BuiltSnapshot } from "./snapshot-build.ts";
|
|
17
18
|
export { dropBranchSnapshots, type DroppedBranchSnapshots, findSnapshotCandidates, isBranchEntry, pickSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type RunnerSnapshotCandidate, SNAPSHOT_EXPIRATION_MS, type SnapshotCacheContext, type SnapshotCacheNote, snapshotEntryFileName, snapshotEntryIdentity, } from "./snapshot-cache.ts";
|
package/dist/runner/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { prepareRunner, } from "./prepare.js";
|
|
|
11
11
|
export { APPLY_LABEL, readyRunner, } from "./ready.js";
|
|
12
12
|
export { checkRecipe, resolveSteps, resolveVcpus, } from "./recipe.js";
|
|
13
13
|
export { REMOTE_TEST_EVENTS_PATH, remoteCommand, remoteEnvironment, runRemote, } from "./remote-command.js";
|
|
14
|
+
export { readRunnerSecrets, RUNNER_SECRET_MIN_LENGTH, stepSecrets, } from "./secrets.js";
|
|
14
15
|
export { CREATE_SETTLE_MS, keptMs, runnerSandboxScope, SNAPSHOT_SETTLE_MS, } from "./scope.js";
|
|
15
16
|
export { BASE_INDEX_LABEL, buildSnapshot } from "./snapshot-build.js";
|
|
16
17
|
export { dropBranchSnapshots, findSnapshotCandidates, isBranchEntry, pickSnapshot, RUNNER_SNAPSHOTS_SUBPATH, SNAPSHOT_EXPIRATION_MS, snapshotEntryFileName, snapshotEntryIdentity, } from "./snapshot-cache.js";
|
package/dist/runner/prepare.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RefusedBaseRef } from "./base.ts";
|
|
2
2
|
import type { CheckoutFailure, CheckoutHead, CheckoutUpload } from "./gateways.ts";
|
|
3
|
-
import { type CheckedRecipe, type
|
|
3
|
+
import { type CheckedRecipe, type ResolvedRunnerStep, type RunnerResources } from "./recipe.ts";
|
|
4
4
|
import { type RunnerSnapshotCandidate, type SnapshotCacheContext, type SnapshotCacheNote } from "./snapshot-cache.ts";
|
|
5
5
|
/** What `prepareRunner` needs: the checkout, the runner snapshot cache and the clock. */
|
|
6
6
|
export type RunnerPrepareContext = SnapshotCacheContext;
|
|
@@ -24,9 +24,9 @@ export interface PreparedRunner {
|
|
|
24
24
|
/** The run's base, a full SHA, and the ref it is HEAD's merge-base with. */
|
|
25
25
|
readonly base: string;
|
|
26
26
|
readonly baseRef: string;
|
|
27
|
-
/** The recipe's snapshot steps at the base, and their snapshot key. */
|
|
28
|
-
readonly toolchains: readonly
|
|
29
|
-
readonly
|
|
27
|
+
/** The recipe's snapshot steps at the base, each with the runner secret names it gets, and their snapshot key. */
|
|
28
|
+
readonly toolchains: readonly ResolvedRunnerStep[];
|
|
29
|
+
readonly prebuild: readonly ResolvedRunnerStep[];
|
|
30
30
|
readonly snapshotKey: string;
|
|
31
31
|
/** The runner sandbox's vCPUs for the run's resources. */
|
|
32
32
|
readonly vcpus: number;
|
|
@@ -57,8 +57,9 @@ export interface PreparedRunner {
|
|
|
57
57
|
* - `ok`: the run is ready for the remote side.
|
|
58
58
|
* - `no-base-ref`: no ref in `baseRefs` exists locally and shares history with HEAD; `refs` says why for each.
|
|
59
59
|
* - `submodules`: the checkout has Git submodules, at `paths`.
|
|
60
|
-
* - `invalid-recipe`: a step function or `vcpus` failed or returned something storm can't use,
|
|
61
|
-
* base or for its resources; `path` is the key
|
|
60
|
+
* - `invalid-recipe`: a step function or `vcpus` failed or returned something storm can't use, such as a step naming
|
|
61
|
+
* a runner secret the recipe's `secrets` doesn't declare, at the run's base or for its resources; `path` is the key
|
|
62
|
+
* inside the recipe.
|
|
62
63
|
* - `checkout-failed`: git or tar failed, such as outside a Git checkout.
|
|
63
64
|
*/
|
|
64
65
|
export type PrepareRunnerOutcome = {
|
package/dist/runner/prepare.js
CHANGED
package/dist/runner/ready.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { RunnerFailure, RunnerProgress } from "./events.ts";
|
|
|
3
3
|
import type { CheckoutUpload, RunnerSandbox, RunnerSnapshotCacheFailure, RunnerSnapshotEntry, SandboxAccess, StagedFile } from "./gateways.ts";
|
|
4
4
|
import type { PreparedRunner } from "./prepare.ts";
|
|
5
5
|
import type { RunnerSandboxScope } from "./scope.ts";
|
|
6
|
+
import { type RunnerSecrets } from "./secrets.ts";
|
|
6
7
|
/** The label of the step that applies and commits the run's changes in the runner sandbox. */
|
|
7
8
|
export declare const APPLY_LABEL = "Applying your changes";
|
|
8
9
|
/** A runner sandbox ready for the command. */
|
|
@@ -58,6 +59,11 @@ export interface ReadyRunnerRequest {
|
|
|
58
59
|
readonly access: SandboxAccess;
|
|
59
60
|
/** The local user, for each sandbox's `user` tag. */
|
|
60
61
|
readonly user: string;
|
|
62
|
+
/**
|
|
63
|
+
* Every runner secret's value, of which each recipe step, in a snapshot build or the install and build, gets the
|
|
64
|
+
* ones it names.
|
|
65
|
+
*/
|
|
66
|
+
readonly secrets: RunnerSecrets;
|
|
61
67
|
}
|
|
62
68
|
/**
|
|
63
69
|
* Readies the runner sandbox for a prepared run. Of the cached candidates for the access's team and project, it
|
package/dist/runner/ready.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// or build one, start the runner sandbox from it, upload and apply the run's changes, then install and build.
|
|
3
3
|
import { posix } from "node:path";
|
|
4
4
|
import { runnerTags } from "./context.js";
|
|
5
|
+
import { stepSecrets } from "./secrets.js";
|
|
5
6
|
import { buildSnapshot } from "./snapshot-build.js";
|
|
6
7
|
import { pickSnapshot } from "./snapshot-cache.js";
|
|
7
8
|
import { applyScript, REMOTE_ROOT, STAGED_FILES } from "./snapshot-key.js";
|
|
@@ -33,7 +34,13 @@ export async function readyRunner(context, request, control, progress) {
|
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
|
-
const built = await buildSnapshot(context, {
|
|
37
|
+
const built = await buildSnapshot(context, {
|
|
38
|
+
prepared,
|
|
39
|
+
access,
|
|
40
|
+
user: request.user,
|
|
41
|
+
secrets: request.secrets,
|
|
42
|
+
reason: prepared.rebuild ? "rebuild" : "no-snapshot",
|
|
43
|
+
}, control, progress);
|
|
37
44
|
if (built.kind !== "ok")
|
|
38
45
|
return built;
|
|
39
46
|
entry = built.value.entry;
|
|
@@ -79,10 +86,22 @@ export async function readyRunner(context, request, control, progress) {
|
|
|
79
86
|
const loginPath = await context.runnerSandboxes.loginPath(sandbox, signal);
|
|
80
87
|
if (!loginPath.ok)
|
|
81
88
|
return sandboxStop("login-path", loginPath.failure);
|
|
82
|
-
const installed = await stage(context, {
|
|
89
|
+
const installed = await stage(context, {
|
|
90
|
+
sandbox,
|
|
91
|
+
phase: "install",
|
|
92
|
+
step: recipe.run.install,
|
|
93
|
+
secrets: stepSecrets(request.secrets, recipe.run.install.secrets),
|
|
94
|
+
region: recipe.region,
|
|
95
|
+
}, signal, progress);
|
|
83
96
|
if (installed.kind !== "ok")
|
|
84
97
|
return installed;
|
|
85
|
-
const built = await stage(context, {
|
|
98
|
+
const built = await stage(context, {
|
|
99
|
+
sandbox,
|
|
100
|
+
phase: "build",
|
|
101
|
+
step: recipe.run.build,
|
|
102
|
+
secrets: stepSecrets(request.secrets, recipe.run.build.secrets),
|
|
103
|
+
region: recipe.region,
|
|
104
|
+
}, signal, progress);
|
|
86
105
|
if (built.kind !== "ok")
|
|
87
106
|
return built;
|
|
88
107
|
return {
|
|
@@ -139,7 +158,10 @@ export function stagedChanges(upload) {
|
|
|
139
158
|
: [{ name: STAGED_FILES.untrackedTarball, content: upload.untrackedTarball }]),
|
|
140
159
|
];
|
|
141
160
|
}
|
|
142
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Runs the apply, install or build step with `secrets`, the runner secrets the recipe's install or build step names
|
|
163
|
+
* (none for the apply, storm's own), answering how long it took; the install and build get rule lines.
|
|
164
|
+
*/
|
|
143
165
|
async function stage(context, request, signal, progress) {
|
|
144
166
|
if (signal.aborted)
|
|
145
167
|
return { kind: "aborted" };
|
|
@@ -147,7 +169,13 @@ async function stage(context, request, signal, progress) {
|
|
|
147
169
|
const section = phase === "apply" ? undefined : phase;
|
|
148
170
|
if (section !== undefined)
|
|
149
171
|
await progress.emit({ kind: "output-started", section, sandbox: sandbox.name, region: request.region });
|
|
150
|
-
const ran = await runStep(context, {
|
|
172
|
+
const ran = await runStep(context, {
|
|
173
|
+
sandbox,
|
|
174
|
+
phase,
|
|
175
|
+
label: step.label,
|
|
176
|
+
script: step.script,
|
|
177
|
+
...(request.secrets === undefined ? {} : { secrets: request.secrets }),
|
|
178
|
+
}, progress, signal);
|
|
151
179
|
if (ran.kind === "succeeded") {
|
|
152
180
|
if (section !== undefined)
|
|
153
181
|
await progress.emit({ kind: "output-ended", section, outcome: "finished" });
|