Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

release-smoke.ts

433 lines12.9 KB

1// @effect-diagnostics nodeBuiltinImport:off
2import * as NodeChildProcess from "node:child_process";
3import * as NodeFS from "node:fs";
4import * as NodeOS from "node:os";
5import * as NodePath from "node:path";
6import * as NodeURL from "node:url";
7import * as Console from "effect/Console";
8import * as Effect from "effect/Effect";
9​
10const repoRoot = NodePath.resolve(NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)), "..");
11​
12const workspaceFiles = [
13 "package.json",
14 "pnpm-lock.yaml",
15 "pnpm-workspace.yaml",
16 "apps/server/package.json",
17 "apps/desktop/package.json",
18 "apps/web/package.json",
19 "apps/mobile/package.json",
20 "apps/mobile/modules/t3-markdown-text/package.json",
21 "apps/mobile/modules/t3-review-diff/package.json",
22 "apps/mobile/modules/t3-terminal/package.json",
23 "apps/marketing/package.json",
24 "infra/relay/package.json",
25 "oxlint-plugin-t3code/package.json",
26 "packages/client-runtime/package.json",
27 "packages/contracts/package.json",
28 "packages/shared/package.json",
29 "packages/ssh/package.json",
30 "packages/tailscale/package.json",
31 "packages/provider-core/package.json",
32 "packages/provider-testing/package.json",
33 "packages/provider-pi/package.json",
34 "packages/provider-acp/package.json",
35 "packages/provider-cursor/package.json",
36 "packages/provider-grok/package.json",
37 "packages/provider-muse/package.json",
38 "packages/provider-opencode/package.json",
39 "packages/effect-acp/package.json",
40 "packages/effect-codex-app-server/package.json",
41 "scripts/package.json",
42] as const;
43​
44function copyWorkspaceManifestFixture(targetRoot: string): void {
45 for (const relativePath of workspaceFiles) {
46 const sourcePath = NodePath.resolve(repoRoot, relativePath);
47 const destinationPath = NodePath.resolve(targetRoot, relativePath);
48 NodeFS.mkdirSync(NodePath.dirname(destinationPath), { recursive: true });
49 NodeFS.cpSync(sourcePath, destinationPath);
50 }
51​
52 const mobileDependencies = NodePath.resolve(repoRoot, "apps/mobile/deps");
53 if (NodeFS.existsSync(mobileDependencies)) {
54 NodeFS.cpSync(mobileDependencies, NodePath.resolve(targetRoot, "apps/mobile/deps"), {
55 recursive: true,
56 });
57 }
58​
59 const patchesDirectory = NodePath.resolve(repoRoot, "patches");
60 if (NodeFS.existsSync(patchesDirectory)) {
61 NodeFS.cpSync(patchesDirectory, NodePath.resolve(targetRoot, "patches"), { recursive: true });
62 }
64​
65function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
66 const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
67 NodeFS.mkdirSync(assetDirectory, { recursive: true });
68​
69 const arm64Path = NodePath.resolve(assetDirectory, "latest-mac.yml");
70 const x64Path = NodePath.resolve(assetDirectory, "latest-mac-x64.yml");
71​
72 NodeFS.writeFileSync(
73 arm64Path,
74 `version: 9.9.9-smoke.0
75files:
76 - url: T3-Code-9.9.9-smoke.0-arm64.zip
77 sha512: arm64zip
78 size: 125621344
79 - url: T3-Code-9.9.9-smoke.0-arm64.dmg
80 sha512: arm64dmg
81 size: 131754935
82path: T3-Code-9.9.9-smoke.0-arm64.zip
83sha512: arm64zip
84releaseDate: '2026-03-08T10:32:14.587Z'
85`,
86 );
87​
88 NodeFS.writeFileSync(
89 x64Path,
90 `version: 9.9.9-smoke.0
91files:
92 - url: T3-Code-9.9.9-smoke.0-x64.zip
93 sha512: x64zip
94 size: 132000112
95 - url: T3-Code-9.9.9-smoke.0-x64.dmg
96 sha512: x64dmg
97 size: 138148807
98path: T3-Code-9.9.9-smoke.0-x64.zip
99sha512: x64zip
100releaseDate: '2026-03-08T10:36:07.540Z'
101`,
102 );
103​
104 return { arm64Path, x64Path };
106​
107function writeWindowsManifestFixtures(
108 targetRoot: string,
109 channel: string,
110): { arm64Path: string; x64Path: string } {
111 const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
112 NodeFS.mkdirSync(assetDirectory, { recursive: true });
113​
114 const arm64Path = NodePath.resolve(assetDirectory, `${channel}-win-arm64.yml`);
115 const x64Path = NodePath.resolve(assetDirectory, `${channel}-win-x64.yml`);
116​
117 NodeFS.writeFileSync(
118 arm64Path,
119 `version: 9.9.9-smoke.0
120files:
121 - url: T3-Code-9.9.9-smoke.0-arm64.exe
122 sha512: arm64exe
123 size: 126621344
124 - url: T3-Code-9.9.9-smoke.0-arm64.exe.blockmap
125 sha512: arm64blockmap
126 size: 152344
127path: T3-Code-9.9.9-smoke.0-arm64.exe
128sha512: arm64exe
129releaseDate: '2026-03-08T10:32:14.587Z'
130`,
131 );
132​
133 NodeFS.writeFileSync(
134 x64Path,
135 `version: 9.9.9-smoke.0
136files:
137 - url: T3-Code-9.9.9-smoke.0-x64.exe
138 sha512: x64exe
139 size: 132000112
140 - url: T3-Code-9.9.9-smoke.0-x64.exe.blockmap
141 sha512: x64blockmap
142 size: 160112
143path: T3-Code-9.9.9-smoke.0-x64.exe
144sha512: x64exe
145releaseDate: '2026-03-08T10:36:07.540Z'
146`,
147 );
148​
149 return { arm64Path, x64Path };
151​
152function writeWindowsBuilderDebugFixtures(targetRoot: string): {
153 arm64Path: string;
154 x64Path: string;
155} {
156 const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
157 NodeFS.mkdirSync(assetDirectory, { recursive: true });
158​
159 const arm64Path = NodePath.resolve(assetDirectory, "builder-debug-win-arm64.yml");
160 const x64Path = NodePath.resolve(assetDirectory, "builder-debug-win-x64.yml");
161 const debugFixture = `arm64:
162 firstOrDefaultFilePatterns:
163 - '**/*'
164nsis:
165 script: |-
166 !include "example.nsh"
167`;
168​
169 NodeFS.writeFileSync(arm64Path, debugFixture);
170 NodeFS.writeFileSync(x64Path, debugFixture);
171​
172 return { arm64Path, x64Path };
174function assertContains(haystack: string, needle: string, message: string): void {
175 if (!haystack.includes(needle)) {
176 throw new Error(message);
177 }
179​
180function assertExists(path: string, message: string): void {
181 if (!NodeFS.existsSync(path)) {
182 throw new Error(message);
183 }
185​
186function assertPackageVersion(path: string, version: string): void {
187 const packageJson = JSON.parse(NodeFS.readFileSync(path, "utf8")) as {
188 readonly version?: unknown;
189 };
190​
191 if (packageJson.version !== version) {
192 throw new Error(`Expected ${path} to have version ${version}.`);
193 }
195​
196function assertMissing(path: string, message: string): void {
197 if (NodeFS.existsSync(path)) {
198 throw new Error(message);
199 }
201​
202const tempRoot = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-release-smoke-"));
203​
204try {
205 NodeChildProcess.execFileSync(
206 process.execPath,
207 ["--test", NodePath.resolve(repoRoot, ".github/scripts/relay-state-output.test.cjs")],
208 { stdio: "inherit" },
209 );
210​
211 copyWorkspaceManifestFixture(tempRoot);
212​
213 NodeChildProcess.execFileSync(
214 process.execPath,
215 [
216 NodePath.resolve(repoRoot, "scripts/update-release-package-versions.ts"),
217 "9.9.9-smoke.0",
218 "--root",
219 tempRoot,
220 ],
221 {
222 cwd: repoRoot,
223 stdio: "inherit",
224 },
225 );
226​
227 NodeFS.rmSync(NodePath.resolve(tempRoot, "pnpm-lock.yaml"), { force: true });
228​
229 NodeChildProcess.execFileSync("vp", ["install", "--lockfile-only", "--ignore-scripts"], {
230 cwd: tempRoot,
231 stdio: "inherit",
232 });
233​
234 const lockfile = NodeFS.readFileSync(NodePath.resolve(tempRoot, "pnpm-lock.yaml"), "utf8");
235 assertContains(lockfile, "lockfileVersion:", "Expected pnpm-lock.yaml to be regenerated.");
236​
237 for (const relativePath of [
238 "apps/server/package.json",
239 "apps/desktop/package.json",
240 "apps/web/package.json",
241 "packages/contracts/package.json",
242 ]) {
243 assertPackageVersion(NodePath.resolve(tempRoot, relativePath), "9.9.9-smoke.0");
244 }
245​
246 const nightlyReleaseMetadata = NodeChildProcess.execFileSync(
247 process.execPath,
248 [
249 NodePath.resolve(repoRoot, "scripts/resolve-nightly-release.ts"),
250 "--date",
251 "20260413",
252 "--run-number",
253 "321",
254 "--sha",
255 "abcdef1234567890",
256 "--root",
257 tempRoot,
258 ],
259 {
260 cwd: repoRoot,
261 encoding: "utf8",
262 },
263 );
264 assertContains(
265 nightlyReleaseMetadata,
266 "version=9.9.10-nightly.20260413.321",
267 "Expected nightly metadata to contain the derived nightly version.",
268 );
269 assertContains(
270 nightlyReleaseMetadata,
271 "tag=v9.9.10-nightly.20260413.321",
272 "Expected nightly metadata to contain the derived nightly tag.",
273 );
274 assertContains(
275 nightlyReleaseMetadata,
276 "name=T3 Code Nightly 9.9.10-nightly.20260413.321 (abcdef123456)",
277 "Expected nightly metadata to include the short commit SHA in the release name.",
278 );
279​
280 const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
281 NodeChildProcess.execFileSync(
282 process.execPath,
283 [
284 NodePath.resolve(repoRoot, "scripts/merge-update-manifests.ts"),
285 "--platform",
286 "mac",
287 arm64Path,
288 x64Path,
289 ],
290 {
291 cwd: repoRoot,
292 stdio: "inherit",
293 },
294 );
295​
296 const mergedManifest = NodeFS.readFileSync(arm64Path, "utf8");
297 assertContains(
298 mergedManifest,
299 "T3-Code-9.9.9-smoke.0-arm64.zip",
300 "Merged manifest is missing the arm64 asset.",
301 );
302 assertContains(
303 mergedManifest,
304 "T3-Code-9.9.9-smoke.0-x64.zip",
305 "Merged manifest is missing the x64 asset.",
306 );
307​
308 const { arm64Path: winArm64Path, x64Path: winX64Path } = writeWindowsManifestFixtures(
309 tempRoot,
310 "latest",
311 );
312 const mergedWindowsManifestPath = NodePath.resolve(tempRoot, "release-assets/latest.yml");
313 const { arm64Path: nightlyWinArm64Path, x64Path: nightlyWinX64Path } =
314 writeWindowsManifestFixtures(tempRoot, "nightly");
315 const mergedNightlyWindowsManifestPath = NodePath.resolve(tempRoot, "release-assets/nightly.yml");
316 const { arm64Path: previewWinArm64Path, x64Path: previewWinX64Path } =
317 writeWindowsManifestFixtures(tempRoot, "preview");
318 const mergedPreviewWindowsManifestPath = NodePath.resolve(tempRoot, "release-assets/preview.yml");
319 const { arm64Path: winDebugArm64Path, x64Path: winDebugX64Path } =
320 writeWindowsBuilderDebugFixtures(tempRoot);
321 NodeChildProcess.execFileSync(
322 "bash",
323 [
324 "-lc",
325 `
326 release_assets_dir=${JSON.stringify(NodePath.resolve(tempRoot, "release-assets"))}
327 shopt -s nullglob
328 found_windows_manifest=false
329 for x64_manifest in "$release_assets_dir"/*-win-x64.yml; do
330 if [[ "$(basename "$x64_manifest")" == builder-debug-* ]]; then
331 continue
332 fi
333​
334 arm64_manifest="\${x64_manifest/-x64.yml/-arm64.yml}"
335 output_manifest="\${x64_manifest/-win-x64.yml/.yml}"
336 if [[ ! -f "$arm64_manifest" ]]; then
337 echo "Missing matching arm64 Windows manifest for $x64_manifest" >&2
338 exit 1
339 fi
340​
341 found_windows_manifest=true
342 ${JSON.stringify(process.execPath)} ${JSON.stringify(NodePath.resolve(repoRoot, "scripts/merge-update-manifests.ts"))} --platform win \
343 "$arm64_manifest" \
344 "$x64_manifest" \
345 "$output_manifest"
346 rm -f "$arm64_manifest" "$x64_manifest"
347 done
348​
349 if [[ "$found_windows_manifest" != true ]]; then
350 echo "No Windows updater manifests found to merge." >&2
351 exit 1
352 fi
353 `,
354 ],
355 {
356 cwd: repoRoot,
357 stdio: "inherit",
358 },
359 );
360​
361 const mergedWindowsManifest = NodeFS.readFileSync(mergedWindowsManifestPath, "utf8");
362 assertContains(
363 mergedWindowsManifest,
364 "T3-Code-9.9.9-smoke.0-arm64.exe",
365 "Merged Windows manifest is missing the arm64 asset.",
366 );
367 assertContains(
368 mergedWindowsManifest,
369 "T3-Code-9.9.9-smoke.0-x64.exe",
370 "Merged Windows manifest is missing the x64 asset.",
371 );
372 const mergedNightlyWindowsManifest = NodeFS.readFileSync(
373 mergedNightlyWindowsManifestPath,
374 "utf8",
375 );
376 assertContains(
377 mergedNightlyWindowsManifest,
378 "T3-Code-9.9.9-smoke.0-arm64.exe",
379 "Merged nightly Windows manifest is missing the arm64 asset.",
380 );
381 assertContains(
382 mergedNightlyWindowsManifest,
383 "T3-Code-9.9.9-smoke.0-x64.exe",
384 "Merged nightly Windows manifest is missing the x64 asset.",
385 );
386 const mergedPreviewWindowsManifest = NodeFS.readFileSync(
387 mergedPreviewWindowsManifestPath,
388 "utf8",
389 );
390 assertContains(
391 mergedPreviewWindowsManifest,
392 "T3-Code-9.9.9-smoke.0-arm64.exe",
393 "Merged preview Windows manifest is missing the arm64 asset.",
394 );
395 assertContains(
396 mergedPreviewWindowsManifest,
397 "T3-Code-9.9.9-smoke.0-x64.exe",
398 "Merged preview Windows manifest is missing the x64 asset.",
399 );
400 assertMissing(
401 winArm64Path,
402 "Windows release smoke unexpectedly kept the arm64 updater manifest.",
403 );
404 assertMissing(winX64Path, "Windows release smoke unexpectedly kept the x64 updater manifest.");
405 assertMissing(
406 nightlyWinArm64Path,
407 "Windows release smoke unexpectedly kept the nightly arm64 updater manifest.",
408 );
409 assertMissing(
410 nightlyWinX64Path,
411 "Windows release smoke unexpectedly kept the nightly x64 updater manifest.",
412 );
413 assertMissing(
414 previewWinArm64Path,
415 "Windows release smoke unexpectedly kept the preview arm64 updater manifest.",
416 );
417 assertMissing(
418 previewWinX64Path,
419 "Windows release smoke unexpectedly kept the preview x64 updater manifest.",
420 );
421 assertExists(
422 winDebugArm64Path,
423 "Windows release smoke unexpectedly removed the arm64 builder debug fixture.",
424 );
425 assertExists(
426 winDebugX64Path,
427 "Windows release smoke unexpectedly removed the x64 builder debug fixture.",
428 );
429​
430 Effect.runSync(Console.log("Release smoke checks passed."));
431} finally {
432 NodeFS.rmSync(tempRoot, { recursive: true, force: true });