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

release-smoke.ts

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