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

release-smoke.ts

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