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

release-smoke.ts

380 lines10.5 KB

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