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

release-smoke.ts

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