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

release-smoke.ts

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