@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,208 +1,387 @@
|
|
|
1
|
+
import {
|
|
2
|
+
REQUESTING_TOKEN_LINE,
|
|
3
|
+
configErrors,
|
|
4
|
+
credentialOriginRows,
|
|
5
|
+
fileOptions,
|
|
6
|
+
fileSettings,
|
|
7
|
+
invalidResourceOptions,
|
|
8
|
+
loadSettingsFile,
|
|
9
|
+
mergeResourceOptions,
|
|
10
|
+
prBuildRefusalErrors,
|
|
11
|
+
prBuildRefusalFacts,
|
|
12
|
+
rejectedCredentialFacts,
|
|
13
|
+
rejectedCredentialShape,
|
|
14
|
+
rejectedCredentialText,
|
|
15
|
+
testserverPoolConfig,
|
|
16
|
+
tokenRequestFailureFacts,
|
|
17
|
+
tokenRequestFailureShape
|
|
18
|
+
} from "../../../../chunks/chunk-OCZJE5XV.js";
|
|
19
|
+
import {
|
|
20
|
+
CREATE_ATTEMPTS,
|
|
21
|
+
DEFAULT_TTL_MINUTES,
|
|
22
|
+
TESTSERVER_REPO,
|
|
23
|
+
createPooledSandbox,
|
|
24
|
+
credentialErrors,
|
|
25
|
+
credentialSourceFor,
|
|
26
|
+
describeMintFailure,
|
|
27
|
+
describeTtl,
|
|
28
|
+
invalidTtlMessage,
|
|
29
|
+
mayLeaveSandbox,
|
|
30
|
+
mintTargetText,
|
|
31
|
+
parseBuildReference,
|
|
32
|
+
parseTtl,
|
|
33
|
+
resolvePrBuild,
|
|
34
|
+
settleCredential,
|
|
35
|
+
shortSha
|
|
36
|
+
} from "../../../../chunks/chunk-5CQCRX2L.js";
|
|
37
|
+
|
|
38
|
+
// src/resources/testserver/commands/create/command.ts
|
|
39
|
+
import { z as z2 } from "zod";
|
|
40
|
+
|
|
41
|
+
// src/resources/testserver/commands/create/outcomes.ts
|
|
42
|
+
import { defineOutcomes, renderOutcome } from "@vercel/clinkr";
|
|
1
43
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
function sandboxMayExist(ttlMinutes) {
|
|
45
|
+
return `A Testserver sandbox may exist anyway. Nothing can delete it, and it expires within ${describeTtl(ttlMinutes)}.`;
|
|
46
|
+
}
|
|
47
|
+
var createFailedKinds = ["http-error", "stream-error", "stream-ended", "dropped", "timeout", "malformed"];
|
|
48
|
+
var sandboxSchema = z.object({
|
|
49
|
+
/** The Testserver URL, with no trailing slash. */
|
|
50
|
+
testserverUrl: z.string(),
|
|
51
|
+
/** The log viewer URL, with no trailing slash. */
|
|
52
|
+
logViewerUrl: z.string(),
|
|
53
|
+
/** The build, build channel or PR build reference (pr:<N>) given with --build. */
|
|
54
|
+
requestedBuild: z.string(),
|
|
55
|
+
/** The build the Testserver sandbox runs. */
|
|
56
|
+
resolvedBuild: z.string(),
|
|
57
|
+
/** For a PR build reference, the pull request and the head commit the resolved PR build was made from; null otherwise. */
|
|
58
|
+
pullRequest: z.object({
|
|
59
|
+
/** The repository, vercel/api. */
|
|
60
|
+
repo: z.string(),
|
|
61
|
+
number: z.number(),
|
|
62
|
+
/** The pull request's head commit, 40 hex characters. */
|
|
63
|
+
headSha: z.string()
|
|
64
|
+
}).nullable(),
|
|
65
|
+
/** Its TTL, in minutes. */
|
|
66
|
+
ttlMinutes: z.number(),
|
|
67
|
+
/** The config file the settings came from (its absolute path); null when none applied. */
|
|
68
|
+
configFile: z.string().nullable()
|
|
69
|
+
});
|
|
70
|
+
var outcomes = defineOutcomes({
|
|
71
|
+
results: {
|
|
72
|
+
created: {
|
|
73
|
+
schema: sandboxSchema,
|
|
74
|
+
description: "Created one Testserver sandbox with the TTL --ttl gives and added it to the pool, unleased.",
|
|
75
|
+
render: (sandbox) => renderOutcome({
|
|
76
|
+
done: ["Created", sandbox.testserverUrl],
|
|
77
|
+
rows: [
|
|
78
|
+
["Log viewer URL", sandbox.logViewerUrl],
|
|
79
|
+
["Requested build", sandbox.requestedBuild],
|
|
80
|
+
["Resolved build", sandbox.resolvedBuild],
|
|
81
|
+
...sandbox.pullRequest === null ? [] : [["Head commit", sandbox.pullRequest.headSha]],
|
|
82
|
+
["TTL", describeTtl(sandbox.ttlMinutes)]
|
|
83
|
+
],
|
|
84
|
+
message: "Added it to the pool, unleased."
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
errors: {
|
|
89
|
+
...configErrors,
|
|
90
|
+
...credentialErrors,
|
|
91
|
+
...prBuildRefusalErrors("No Testserver sandbox was created."),
|
|
92
|
+
poolUnavailable: {
|
|
93
|
+
exitCode: 1,
|
|
94
|
+
description: "storm couldn't use the pool, so it minted no credential and created no Testserver sandbox.",
|
|
95
|
+
schema: z.object({
|
|
96
|
+
/** The pool directory that couldn't be made, or where the pool would live. */
|
|
97
|
+
path: z.string(),
|
|
98
|
+
/** What the OS said, or why there is no place for the pool. */
|
|
99
|
+
message: z.string()
|
|
100
|
+
}),
|
|
101
|
+
render: ({ path, message }) => ({
|
|
102
|
+
message: `Couldn't prepare the pool: ${message}`,
|
|
103
|
+
rows: [["Pool path", path]],
|
|
104
|
+
next: [{ type: "text", text: "Fix the pool path, then retry. No Testserver sandbox was created." }]
|
|
105
|
+
})
|
|
106
|
+
},
|
|
107
|
+
mintFailed: {
|
|
108
|
+
exitCode: 1,
|
|
109
|
+
description: "The vercel CLI couldn't mint a credential for the team and project.",
|
|
110
|
+
schema: z.object({ team: z.string(), project: z.string(), cause: z.string(), fix: z.string() }),
|
|
111
|
+
render: ({ cause, fix }) => ({
|
|
112
|
+
message: `Couldn't mint a credential: ${cause}.`,
|
|
113
|
+
next: [{ type: "text", text: fix }]
|
|
114
|
+
})
|
|
115
|
+
},
|
|
116
|
+
tokenRequestFailed: {
|
|
117
|
+
exitCode: 1,
|
|
118
|
+
description: "With --credential github-actions, the GitHub Actions OIDC token request failed.",
|
|
119
|
+
schema: z.object(tokenRequestFailureShape),
|
|
120
|
+
render: ({ detail, fix }) => ({
|
|
121
|
+
message: `Couldn't request a GitHub Actions OIDC token: ${detail}.`,
|
|
122
|
+
next: [{ type: "text", text: fix }]
|
|
123
|
+
})
|
|
124
|
+
},
|
|
125
|
+
credentialRejected: {
|
|
126
|
+
exitCode: 1,
|
|
127
|
+
description: "The Testserver control plane refused the credential, minted or a GitHub Actions OIDC token (a redirect to SSO, a 401 or a 403).",
|
|
128
|
+
schema: z.object({
|
|
129
|
+
...rejectedCredentialShape,
|
|
130
|
+
status: z.number(),
|
|
131
|
+
vercelId: z.string().nullable()
|
|
132
|
+
}),
|
|
133
|
+
render: ({ origin, fix, status, vercelId }) => ({
|
|
134
|
+
message: `The Testserver control plane rejected ${rejectedCredentialText(origin)} (HTTP ${status}, x-vercel-id ${vercelId ?? "unknown"}).`,
|
|
135
|
+
rows: credentialOriginRows(origin),
|
|
136
|
+
next: [{ type: "text", text: fix }]
|
|
137
|
+
})
|
|
138
|
+
},
|
|
139
|
+
testserverUnreachable: {
|
|
140
|
+
exitCode: 1,
|
|
141
|
+
description: "No create reached the Testserver control plane, after every attempt.",
|
|
142
|
+
schema: z.object({ attempts: z.number(), code: z.string() }),
|
|
143
|
+
render: ({ attempts, code }) => ({
|
|
144
|
+
message: `Couldn't reach the Testserver control plane after ${attempts} attempts (${code}).`,
|
|
145
|
+
next: [{ type: "text", text: "Check your network connection and any VPN or proxy, then retry." }]
|
|
146
|
+
})
|
|
147
|
+
},
|
|
148
|
+
poolWriteFailed: {
|
|
149
|
+
exitCode: 1,
|
|
150
|
+
description: "Created the Testserver sandbox, but couldn't add it to the pool.",
|
|
151
|
+
schema: sandboxSchema.extend({
|
|
152
|
+
/** The pool file or directory the write failed on. */
|
|
153
|
+
path: z.string(),
|
|
154
|
+
/** What the OS said. */
|
|
155
|
+
message: z.string()
|
|
156
|
+
}),
|
|
157
|
+
render: (failure) => ({
|
|
158
|
+
message: `Created the Testserver sandbox ${failure.testserverUrl}, but couldn't add it to the pool: ${failure.message}`,
|
|
159
|
+
rows: [
|
|
160
|
+
["Testserver URL", failure.testserverUrl],
|
|
161
|
+
["Log viewer URL", failure.logViewerUrl],
|
|
162
|
+
["Requested build", failure.requestedBuild],
|
|
163
|
+
["Resolved build", failure.resolvedBuild],
|
|
164
|
+
["Pool path", failure.path]
|
|
47
165
|
],
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
166
|
+
next: [
|
|
167
|
+
{
|
|
168
|
+
type: "text",
|
|
169
|
+
text: `The Testserver sandbox exists and expires within ${describeTtl(failure.ttlMinutes)}; nothing can delete it. Fix the pool path, then retry.`
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
})
|
|
173
|
+
},
|
|
174
|
+
createFailed: {
|
|
175
|
+
exitCode: 1,
|
|
176
|
+
description: "The create reached the Testserver control plane and failed.",
|
|
177
|
+
schema: z.object({
|
|
178
|
+
kind: z.enum(createFailedKinds),
|
|
179
|
+
build: z.string(),
|
|
180
|
+
/** The TTL the create asked for, in minutes: how long a Testserver sandbox it may have left lives. */
|
|
181
|
+
ttlMinutes: z.number(),
|
|
182
|
+
/** What the Testserver control plane or the connection said; null for stream-ended and timeout. */
|
|
183
|
+
detail: z.string().nullable(),
|
|
184
|
+
/** The HTTP status of an http-error; otherwise null. */
|
|
185
|
+
status: z.number().nullable(),
|
|
186
|
+
/** How long a timed-out create ran; otherwise null. */
|
|
187
|
+
seconds: z.number().nullable(),
|
|
188
|
+
/** Whether a Testserver sandbox may exist despite the failure: all kinds but http-error. */
|
|
189
|
+
sandboxMayExist: z.boolean()
|
|
190
|
+
}),
|
|
191
|
+
render: (failure) => ({
|
|
192
|
+
message: createFailedMessage(failure),
|
|
193
|
+
...failure.sandboxMayExist ? { next: [{ type: "text", text: sandboxMayExist(failure.ttlMinutes) }] } : {}
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
function createFailedMessage(failure) {
|
|
199
|
+
const said = failure.detail ?? "";
|
|
200
|
+
switch (failure.kind) {
|
|
201
|
+
case "http-error":
|
|
202
|
+
return `The Testserver control plane failed the create with HTTP ${failure.status ?? "an error"}: ${said}`;
|
|
203
|
+
case "stream-error":
|
|
204
|
+
return `The Testserver control plane couldn't create a Testserver sandbox on ${failure.build}: ${said}`;
|
|
205
|
+
case "stream-ended":
|
|
206
|
+
return "The create stream ended without a Testserver sandbox config.";
|
|
207
|
+
case "dropped":
|
|
208
|
+
return `The connection to the Testserver control plane dropped during the create: ${said}`;
|
|
209
|
+
case "timeout":
|
|
210
|
+
return failure.seconds === null ? "The create didn't finish in time." : `The create didn't finish within ${failure.seconds}s.`;
|
|
211
|
+
case "malformed":
|
|
212
|
+
return `The Testserver control plane's sandbox config is malformed: ${said}`;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// src/resources/testserver/commands/create/command.ts
|
|
217
|
+
function command(cmd) {
|
|
218
|
+
return cmd.define({
|
|
219
|
+
requestSchema: z2.object({
|
|
220
|
+
scope: z2.string().min(1).optional(),
|
|
221
|
+
project: z2.string().min(1).optional(),
|
|
222
|
+
build: z2.string().min(1).optional(),
|
|
223
|
+
ttl: z2.string().optional(),
|
|
224
|
+
credential: z2.enum(["mint", "github-actions"]).default("mint")
|
|
225
|
+
}),
|
|
226
|
+
cli: { options: { project: { short: "p" } } },
|
|
227
|
+
response: outcomes,
|
|
228
|
+
validate: ({ ttl, build }) => [
|
|
229
|
+
...ttl !== void 0 && parseTtl(ttl) === void 0 ? [{ field: "ttl", message: invalidTtlMessage(ttl) }] : [],
|
|
230
|
+
...build === void 0 ? [] : buildProblems(build)
|
|
231
|
+
],
|
|
232
|
+
handler: async ({ app, ui }, request) => {
|
|
233
|
+
const { credential: source, scope, project } = request;
|
|
234
|
+
const file = await loadSettingsFile(app.context.config, app.cwd, app.resourceConfigs);
|
|
235
|
+
if (!file.ok) return file.refusal;
|
|
236
|
+
const configFile = file.path;
|
|
237
|
+
const settings = fileSettings(file, { scope, project });
|
|
238
|
+
const pool = mergeResourceOptions(testserverPoolConfig, fileOptions(file, testserverPoolConfig), {
|
|
239
|
+
...request.build === void 0 ? {} : { build: settledBuild(request.build) },
|
|
240
|
+
...request.ttl === void 0 ? {} : { ttl: request.ttl }
|
|
241
|
+
});
|
|
242
|
+
if (!pool.ok) return invalidResourceOptions(configFile, pool.problems);
|
|
243
|
+
const chosen = settleCredential(source, settings.scope, settings.project);
|
|
244
|
+
if (!chosen.ok) return chosen.refusal;
|
|
245
|
+
const requestedBuild = pool.value.build.value;
|
|
246
|
+
const ttlMinutes = parseTtl(pool.value.ttl.value) ?? DEFAULT_TTL_MINUTES;
|
|
247
|
+
if (configFile !== null) await ui.progress?.(`Config: ${configFile}`);
|
|
248
|
+
const { context } = app;
|
|
249
|
+
const prepared = await context.pool.prepare();
|
|
250
|
+
if (!prepared.ok) return outcomes.poolUnavailable({ ...prepared.failure });
|
|
251
|
+
const credential = credentialSourceFor(chosen.credential, context, {
|
|
252
|
+
onMint: async (target) => {
|
|
253
|
+
await ui.progress?.(`Minting a credential for ${mintTargetText(target)}\u2026`);
|
|
254
|
+
},
|
|
255
|
+
onRequest: async () => {
|
|
256
|
+
await ui.progress?.(REQUESTING_TOKEN_LINE);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
let resolution;
|
|
260
|
+
const reference = parseBuildReference(requestedBuild);
|
|
261
|
+
if (reference.ok && reference.reference.kind === "pull-request") {
|
|
262
|
+
const resolved = await resolvePrBuild(context, { pr: reference.reference.number });
|
|
263
|
+
if (!resolved.ok) {
|
|
264
|
+
const { key, data } = prBuildRefusalFacts(resolved.refusal);
|
|
265
|
+
switch (key) {
|
|
266
|
+
case "pullRequestUnreadable":
|
|
267
|
+
return outcomes.pullRequestUnreadable(data);
|
|
268
|
+
case "prBuildsUnlisted":
|
|
269
|
+
return outcomes.prBuildsUnlisted(data);
|
|
270
|
+
case "prBuildNotReady":
|
|
271
|
+
return outcomes.prBuildNotReady(data);
|
|
272
|
+
case "prBuildExpired":
|
|
273
|
+
return outcomes.prBuildExpired(data);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
resolution = resolved.resolution;
|
|
277
|
+
await ui.progress?.(
|
|
278
|
+
`${TESTSERVER_REPO}#${resolution.pr} at ${shortSha(resolution.headSha)} \u2192 build ${resolution.build}${resolution.from === "pool" ? " (from the pool)" : ""}`
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
const build = resolution?.build ?? requestedBuild;
|
|
282
|
+
const got = await credential.get();
|
|
283
|
+
if (!got.ok) return credentialFailed(got.failure);
|
|
284
|
+
await ui.progress?.(`Creating a Testserver sandbox on ${build}\u2026`);
|
|
285
|
+
const progress = ui.progress;
|
|
286
|
+
const created = await createPooledSandbox(
|
|
287
|
+
app.context,
|
|
288
|
+
{
|
|
289
|
+
credential: got.credential,
|
|
290
|
+
build,
|
|
291
|
+
requestedBuild,
|
|
292
|
+
...resolution === void 0 ? {} : { headSha: resolution.headSha },
|
|
293
|
+
ttlMinutes,
|
|
294
|
+
lease: false
|
|
130
295
|
},
|
|
131
|
-
|
|
296
|
+
progress === void 0 ? {} : { onProgress: (message) => progress(` ${message}`) }
|
|
297
|
+
);
|
|
298
|
+
const pullRequest = resolution === void 0 ? null : { repo: TESTSERVER_REPO, number: resolution.pr, headSha: resolution.headSha };
|
|
299
|
+
switch (created.kind) {
|
|
300
|
+
case "pooled":
|
|
301
|
+
return outcomes.created({ ...sandboxFacts(created.entry), pullRequest, configFile });
|
|
302
|
+
case "pool-write-failed":
|
|
303
|
+
return outcomes.poolWriteFailed({
|
|
304
|
+
...sandboxFacts(created.entry),
|
|
305
|
+
pullRequest,
|
|
306
|
+
configFile,
|
|
307
|
+
path: created.failure.path,
|
|
308
|
+
message: created.failure.message
|
|
309
|
+
});
|
|
310
|
+
case "create-failed":
|
|
311
|
+
return createFailure(created.failure, credential.origin(got.credential), build, ttlMinutes);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
});
|
|
132
315
|
}
|
|
133
|
-
/** The `--build` problems the Testserver pool's `build` rule finds, as `validate` reports them. */
|
|
134
316
|
function buildProblems(build) {
|
|
135
|
-
|
|
136
|
-
|
|
317
|
+
const checked = testserverPoolConfig.options.build.check(build);
|
|
318
|
+
return checked.ok ? [] : checked.problems.map(({ problem }) => ({ field: "build", message: `--build ${problem}.` }));
|
|
137
319
|
}
|
|
138
|
-
/** `--build` as the Testserver pool's `build` rule settles it: a PR build reference as `pr:<N>`. */
|
|
139
320
|
function settledBuild(build) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
throw new Error(`--build ${build} should have been refused`);
|
|
144
|
-
return checked.value;
|
|
321
|
+
const checked = testserverPoolConfig.options.build.check(build);
|
|
322
|
+
if (!checked.ok) throw new Error(`--build ${build} should have been refused`);
|
|
323
|
+
return checked.value;
|
|
145
324
|
}
|
|
146
|
-
/** The outcome of a credential source that couldn't give a credential. */
|
|
147
325
|
function credentialFailed(failure) {
|
|
148
|
-
|
|
149
|
-
? outcomes.mintFailed({ ...failure.target, ...describeMintFailure(failure.failure, failure.target) })
|
|
150
|
-
: outcomes.tokenRequestFailed(tokenRequestFailureFacts(failure.failure));
|
|
326
|
+
return failure.source === "mint" ? outcomes.mintFailed({ ...failure.target, ...describeMintFailure(failure.failure, failure.target) }) : outcomes.tokenRequestFailed(tokenRequestFailureFacts(failure.failure));
|
|
151
327
|
}
|
|
152
328
|
function sandboxFacts(entry) {
|
|
153
|
-
|
|
154
|
-
|
|
329
|
+
const { testserverUrl, logViewerUrl, requestedBuild, resolvedBuild, ttlMinutes } = entry;
|
|
330
|
+
return { testserverUrl, logViewerUrl, requestedBuild, resolvedBuild, ttlMinutes };
|
|
155
331
|
}
|
|
156
332
|
function createFailure(failure, origin, build, ttlMinutes) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
333
|
+
const facts = {
|
|
334
|
+
build,
|
|
335
|
+
ttlMinutes,
|
|
336
|
+
detail: null,
|
|
337
|
+
status: null,
|
|
338
|
+
seconds: null,
|
|
339
|
+
sandboxMayExist: mayLeaveSandbox(failure)
|
|
340
|
+
};
|
|
341
|
+
switch (failure.kind) {
|
|
342
|
+
case "connect-failed":
|
|
343
|
+
return outcomes.testserverUnreachable({ attempts: CREATE_ATTEMPTS, code: failure.code });
|
|
344
|
+
case "rejected":
|
|
345
|
+
return outcomes.credentialRejected({
|
|
346
|
+
...rejectedCredentialFacts(origin),
|
|
347
|
+
status: failure.status,
|
|
348
|
+
vercelId: failure.vercelId ?? null
|
|
349
|
+
});
|
|
350
|
+
case "http-error":
|
|
351
|
+
return outcomes.createFailed({
|
|
352
|
+
...facts,
|
|
353
|
+
kind: failure.kind,
|
|
354
|
+
detail: failure.body,
|
|
355
|
+
status: failure.status
|
|
356
|
+
});
|
|
357
|
+
case "stream-error":
|
|
358
|
+
return outcomes.createFailed({
|
|
359
|
+
...facts,
|
|
360
|
+
kind: failure.kind,
|
|
361
|
+
detail: failure.error
|
|
362
|
+
});
|
|
363
|
+
case "stream-ended":
|
|
364
|
+
return outcomes.createFailed({ ...facts, kind: failure.kind });
|
|
365
|
+
case "dropped":
|
|
366
|
+
return outcomes.createFailed({
|
|
367
|
+
...facts,
|
|
368
|
+
kind: failure.kind,
|
|
369
|
+
detail: failure.message
|
|
370
|
+
});
|
|
371
|
+
case "timeout":
|
|
372
|
+
return outcomes.createFailed({
|
|
373
|
+
...facts,
|
|
374
|
+
kind: failure.kind,
|
|
375
|
+
seconds: failure.seconds
|
|
376
|
+
});
|
|
377
|
+
case "malformed":
|
|
378
|
+
return outcomes.createFailed({
|
|
379
|
+
...facts,
|
|
380
|
+
kind: failure.kind,
|
|
381
|
+
detail: failure.detail
|
|
382
|
+
});
|
|
383
|
+
}
|
|
208
384
|
}
|
|
385
|
+
export {
|
|
386
|
+
command
|
|
387
|
+
};
|