The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 20:45 UTC
fix(release): keep Vercel warnings out of deployment URLs (#22817)
Theo Browne committed
Oct 21, 2026 at 03:51 UTC
1688f965682d331da16a8c39f049592361f69c8d
4 files changed
+112
-4
.github/scripts/vercel-deployment-output.test.cjs
new
+87
@@ -0,0 +1,87 @@
1
+const assert = require("node:assert/strict");
2
+const { spawnSync } = require("node:child_process");
3
+const { mkdtempSync, readFileSync, rmSync, existsSync } = require("node:fs");
4
+const { tmpdir } = require("node:os");
5
+const { join } = require("node:path");
6
+const { test } = require("node:test");
7
+
8
+const release = readFileSync(join(__dirname, "../workflows/release.yml"), "utf8");
9
+const preview = readFileSync(join(__dirname, "../workflows/web-preview.yml"), "utf8");
10
+const stepPattern =
11
+ / name: (?:Build staged deployment|Deploy preview)\n shell: bash\n run: \|\n((?: .*\n|\n)+)/g;
12
+const steps = [
13
+ ...Array.from(release.matchAll(stepPattern), (match, index) => [
14
+ index === 0 ? "hosted web" : "marketing",
15
+ match[1],
16
+ ]),
17
+ ...Array.from(preview.matchAll(stepPattern), (match) => ["web preview", match[1]]),
18
+];
19
+assert.equal(steps.length, 3, "Expected both release steps and the preview step");
20
+
21
+const url = "https://t3code-fixture-pinglabs.vercel.app";
22
+const warning = 'Error while parsing config file: "/runner/t3code/pnpm-lock.yaml"';
23
+
24
+function runStep(script, stdout, exitCode = 0) {
25
+ const directory = mkdtempSync(join(tmpdir(), "t3-vercel-output-"));
26
+ const outputFile = join(directory, "output");
27
+ try {
28
+ const result = spawnSync(
29
+ "bash",
30
+ [
31
+ "-c",
32
+ 'vp() { printf "%s\\n" "$FIXTURE_STDOUT"; return "$FIXTURE_EXIT"; }\n' +
33
+ 'curl() { printf \'{"id":"fixture-project"}\\n\'; }\n' +
34
+ script.replace(/^ /gm, "").replace(/\$\{\{.*?\}\}/g, "fixture"),
35
+ ],
36
+ {
37
+ encoding: "utf8",
38
+ env: {
39
+ PATH: process.env.PATH,
40
+ VERCEL_TOKEN: "fixture-token",
41
+ VERCEL_ORG_ID: "fixture-org",
42
+ VERCEL_PROJECT_ID: "fixture-project",
43
+ GITHUB_OUTPUT: outputFile,
44
+ FIXTURE_STDOUT: stdout,
45
+ FIXTURE_EXIT: String(exitCode),
46
+ },
47
+ },
48
+ );
49
+ assert.ifError(result.error);
50
+ return {
51
+ ...result,
52
+ output: existsSync(outputFile) ? readFileSync(outputFile, "utf8") : "",
53
+ };
54
+ } finally {
55
+ rmSync(directory, { recursive: true, force: true });
56
+ }
57
+}
58
+
59
+for (const [name, script] of steps) {
60
+ for (const [label, stdout] of [
61
+ ["plain URL", url],
62
+ ["lockfile warning", `${warning}\n${url}`],
63
+ ["trailing diagnostic", `${url}\nDone`],
64
+ ]) {
65
+ test(`${name}: saves one deployment URL after ${label}`, () => {
66
+ const result = runStep(script, stdout);
67
+ assert.equal(result.status, 0, result.stderr);
68
+ assert.deepEqual(
69
+ result.output.split("\n").filter((line) => !line.startsWith("project_id=")),
70
+ [`deployment_url=${url}`, ""],
71
+ );
72
+ });
73
+ }
74
+
75
+ for (const [label, stdout, exitCode] of [
76
+ ["missing URL", warning, 0],
77
+ ["invalid URL", "https://example.invalid/deployment", 0],
78
+ ["multiple URLs", `${url}\nhttps://other.vercel.app`, 0],
79
+ ["failed deployment", url, 1],
80
+ ]) {
81
+ test(`${name}: rejects ${label} without saving output`, () => {
82
+ const result = runStep(script, stdout, exitCode);
83
+ assert.notEqual(result.status, 0);
84
+ assert.equal(result.output, "");
85
+ });
86
+ }
87
+}
.github/workflows/ci.yml
+1
-1
@@ -253,7 +253,7 @@ jobs:
253
run: python3 -B .github/scripts/stage-preview-bundle.test.py
254
255
- name: Test release checks
256
- run: node --test .github/scripts/check-nightly-release.test.cjs
256
+ run: node --test .github/scripts/check-nightly-release.test.cjs .github/scripts/vercel-deployment-output.test.cjs
257
258
- name: Finish installing browser secret helper build libraries
259
timeout-minutes: 5
.github/workflows/release.yml
+16
-2
@@ -1072,7 +1072,7 @@ jobs:
1072
fi
1073
1074
echo "Building hosted web app for $channel_name channel."
1075
- deployment_url="$(
1075
+ deployment_output="$(
1076
vp dlx vercel@53.1.1 deploy \
1077
--archive=tgz \
1078
--prod \
@@ -1091,6 +1091,13 @@ jobs:
1091
--build-env "VITE_HOSTED_APP_URL=$router_url" \
1092
--build-env "VITE_HOSTED_APP_CHANNEL=$channel_name"
1093
)"
1094
+ printf '%s\n' "$deployment_output"
1095
+ # Vercel can print lockfile warnings to stdout before the deployment URL.
1096
+ deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1097
+ if [[ "$deployment_url" == *$'\n'* ]]; then
1098
+ echo "Vercel returned multiple deployment URLs." >&2
1099
+ exit 1
1100
+ fi
1101
echo "Staged $deployment_url."
1102
echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1103
@@ -1219,7 +1226,7 @@ jobs:
1226
)"
1227
export VERCEL_PROJECT_ID
1228
1222
- deployment_url="$(
1229
+ deployment_output="$(
1230
vp dlx vercel@53.1.1 deploy \
1231
--archive=tgz \
1232
--prod \
@@ -1228,6 +1235,13 @@ jobs:
1235
--token "$VERCEL_TOKEN" \
1236
--scope "${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
1237
)"
1238
+ printf '%s\n' "$deployment_output"
1239
+ # Vercel can print lockfile warnings to stdout before the deployment URL.
1240
+ deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
1241
+ if [[ "$deployment_url" == *$'\n'* ]]; then
1242
+ echo "Vercel returned multiple deployment URLs." >&2
1243
+ exit 1
1244
+ fi
1245
echo "Staged $deployment_url."
1246
echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
1247
echo "project_id=$VERCEL_PROJECT_ID" >> "$GITHUB_OUTPUT"
.github/workflows/web-preview.yml
+8
-1
@@ -77,13 +77,20 @@ jobs:
77
78
vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
79
80
- deployment_url="$(
80
+ deployment_output="$(
81
vp dlx vercel@53.1.1 deploy \
82
--archive=tgz \
83
--yes \
84
--token "$VERCEL_TOKEN" \
85
--scope "$vercel_scope"
86
)"
87
+ printf '%s\n' "$deployment_output"
88
+ # Vercel can print lockfile warnings to stdout before the deployment URL.
89
+ deployment_url="$(printf '%s\n' "$deployment_output" | grep -E '^https://[[:alnum:].-]+\.vercel\.app$')"
90
+ if [[ "$deployment_url" == *$'\n'* ]]; then
91
+ echo "Vercel returned multiple deployment URLs." >&2
92
+ exit 1
93
+ fi
94
95
echo "Deployed $deployment_url"
96
echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"