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-tanstack-source/package.json",
57 "packages/source-control-testing/package.json",
58 "packages/effect-acp/package.json",
59 "packages/effect-codex-app-server/package.json",
60 "scripts/package.json",
61] as const;
62​
63function copyWorkspaceManifestFixture(targetRoot: string): void {
64 for (const relativePath of workspaceFiles) {
65 const sourcePath = NodePath.resolve(repoRoot, relativePath);
66 const destinationPath = NodePath.resolve(targetRoot, relativePath);
67 NodeFS.mkdirSync(NodePath.dirname(destinationPath), { recursive: true });
68 NodeFS.cpSync(sourcePath, destinationPath);
69 }
70​
71 // Fork tarballs that file: dependencies install from.
72 for (const forks of ["apps/mobile/deps", "apps/web/deps"]) {
73 const source = NodePath.resolve(repoRoot, forks);
74 if (NodeFS.existsSync(source)) {
75 NodeFS.cpSync(source, NodePath.resolve(targetRoot, forks), { recursive: true });
76 }
77 }
78​
79 const patchesDirectory = NodePath.resolve(repoRoot, "patches");
80 if (NodeFS.existsSync(patchesDirectory)) {
81 NodeFS.cpSync(patchesDirectory, NodePath.resolve(targetRoot, "patches"), { recursive: true });
82 }
84​
85function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
86 const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
87 NodeFS.mkdirSync(assetDirectory, { recursive: true });
88​
89 const arm64Path = NodePath.resolve(assetDirectory, "latest-mac.yml");
90 const x64Path = NodePath.resolve(assetDirectory, "latest-mac-x64.yml");
91​
92 NodeFS.writeFileSync(
93 arm64Path,
94 `version: 9.9.9-smoke.0
95files:
96 - url: T3-Code-9.9.9-smoke.0-arm64.zip
97 sha512: arm64zip
98 size: 125621344
99 - url: T3-Code-9.9.9-smoke.0-arm64.dmg
100 sha512: arm64dmg
101 size: 131754935
102path: T3-Code-9.9.9-smoke.0-arm64.zip
103sha512: arm64zip
104releaseDate: '2026-03-08T10:32:14.587Z'
105`,
106 );
107​
108 NodeFS.writeFileSync(
109 x64Path,
110 `version: 9.9.9-smoke.0
111files:
112 - url: T3-Code-9.9.9-smoke.0-x64.zip
113 sha512: x64zip
114 size: 132000112
115 - url: T3-Code-9.9.9-smoke.0-x64.dmg
116 sha512: x64dmg
117 size: 138148807
118path: T3-Code-9.9.9-smoke.0-x64.zip
119sha512: x64zip
120releaseDate: '2026-03-08T10:36:07.540Z'
121`,
122 );
123​
124 return { arm64Path, x64Path };
126​
127function writeWindowsManifestFixtures(
128 targetRoot: string,
129 channel: string,
130): { arm64Path: string; x64Path: string } {
131 const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
132 NodeFS.mkdirSync(assetDirectory, { recursive: true });
133​
134 const arm64Path = NodePath.resolve(assetDirectory, `${channel}-win-arm64.yml`);
135 const x64Path = NodePath.resolve(assetDirectory, `${channel}-win-x64.yml`);
136​
137 NodeFS.writeFileSync(
138 arm64Path,
139 `version: 9.9.9-smoke.0
140files:
141 - url: T3-Code-9.9.9-smoke.0-arm64.exe
142 sha512: arm64exe
143 size: 126621344
144 - url: T3-Code-9.9.9-smoke.0-arm64.exe.blockmap
145 sha512: arm64blockmap
146 size: 152344
147path: T3-Code-9.9.9-smoke.0-arm64.exe
148sha512: arm64exe
149releaseDate: '2026-03-08T10:32:14.587Z'
150`,
151 );
152​
153 NodeFS.writeFileSync(
154 x64Path,
155 `version: 9.9.9-smoke.0
156files:
157 - url: T3-Code-9.9.9-smoke.0-x64.exe
158 sha512: x64exe
159 size: 132000112
160 - url: T3-Code-9.9.9-smoke.0-x64.exe.blockmap
161 sha512: x64blockmap
162 size: 160112
163path: T3-Code-9.9.9-smoke.0-x64.exe
164sha512: x64exe
165releaseDate: '2026-03-08T10:36:07.540Z'
166`,
167 );
168​
169 return { arm64Path, x64Path };
171​
172function writeWindowsBuilderDebugFixtures(targetRoot: string): {
173 arm64Path: string;
174 x64Path: string;
175} {
176 const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
177 NodeFS.mkdirSync(assetDirectory, { recursive: true });
178​
179 const arm64Path = NodePath.resolve(assetDirectory, "builder-debug-win-arm64.yml");
180 const x64Path = NodePath.resolve(assetDirectory, "builder-debug-win-x64.yml");
181 const debugFixture = `arm64:
182 firstOrDefaultFilePatterns:
183 - '**/*'
184nsis:
185 script: |-
186 !include "example.nsh"
187`;
188​
189 NodeFS.writeFileSync(arm64Path, debugFixture);
190 NodeFS.writeFileSync(x64Path, debugFixture);
191​
192 return { arm64Path, x64Path };
194function assertContains(haystack: string, needle: string, message: string): void {
195 if (!haystack.includes(needle)) {
196 throw new Error(message);
197 }
199​
200function assertExists(path: string, message: string): void {
201 if (!NodeFS.existsSync(path)) {
202 throw new Error(message);
203 }
205​
206function assertPackageVersion(path: string, version: string): void {
207 const packageJson = JSON.parse(NodeFS.readFileSync(path, "utf8")) as {
208 readonly version?: unknown;
209 };
210​
211 if (packageJson.version !== version) {
212 throw new Error(`Expected ${path} to have version ${version}.`);
213 }
215​
216function assertMissing(path: string, message: string): void {
217 if (NodeFS.existsSync(path)) {
218 throw new Error(message);
219 }
221​
222const tempRoot = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-release-smoke-"));
223​
224try {
225 NodeChildProcess.execFileSync(
226 process.execPath,
227 ["--test", NodePath.resolve(repoRoot, ".github/scripts/relay-state-output.test.cjs")],
228 { stdio: "inherit" },
229 );
230​
231 copyWorkspaceManifestFixture(tempRoot);
232​
233 NodeChildProcess.execFileSync(
234 process.execPath,
235 [
236 NodePath.resolve(repoRoot, "scripts/update-release-package-versions.ts"),
237 "9.9.9-smoke.0",
238 "--root",
239 tempRoot,
240 ],
241 {
242 cwd: repoRoot,
243 stdio: "inherit",
244 },
245 );
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 });