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

release-smoke.ts

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