Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

80 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { classify, hostPlatform, manifest, notesName, platformOfTriple } from "./desktop-release.mjs";
5
6test("each job's notes are named for the platforms they hold, so jobs on the same kind of machine do not overwrite each other", () => {
7 const linux = [
8 { platform: "linux", arch: "x64" },
9 { platform: "linux", arch: "x64" },
10 ];
11 const windows = [{ platform: "windows", arch: "x64" }];
12 assert.equal(notesName(linux), "collect-linux-x64.json");
13 assert.equal(notesName(windows), "collect-windows-x64.json");
14 assert.notEqual(notesName(linux), notesName(windows));
15 assert.equal(notesName([...windows, ...linux]), "collect-linux-x64+windows-x64.json");
16});
17
18test("a bundle's place in a release", () => {
19 assert.deepEqual(classify("g1t_0.1.0_x64-setup.exe", "windows-x64", "0.1.0"), {
20 platform: "windows",
21 arch: "x64",
22 kind: "installer",
23 name: "g1t-0.1.0-windows-x64-setup.exe",
24 updater: true,
25 });
26 assert.deepEqual(classify("g1t.app.tar.gz", "macos-arm64", "0.1.0"), {
27 platform: "macos",
28 arch: "arm64",
29 kind: "update",
30 name: "g1t-0.1.0-macos-arm64.app.tar.gz",
31 updater: true,
32 });
33 assert.equal(classify("g1t_0.1.0_aarch64.dmg", "macos-arm64", "0.1.0").kind, "dmg");
34 assert.equal(classify("g1t_0.1.0_amd64.AppImage", "linux-x64", "0.1.0").name, "g1t-0.1.0-linux-x64.AppImage");
35 assert.equal(classify("g1t_0.1.0_amd64.deb", "linux-x64", "0.1.0").updater, false);
36 assert.equal(classify("g1t-0.1.0-1.x86_64.rpm", "linux-x64", "0.1.0").kind, "rpm");
37 // Signatures ride with their file; an MSI is not published.
38 assert.equal(classify("g1t_0.1.0_x64-setup.exe.sig", "windows-x64", "0.1.0"), null);
39 assert.equal(classify("g1t_0.1.0_x64_en-US.msi", "windows-x64", "0.1.0"), null);
40});
41
42test("platforms, from a machine and from a target", () => {
43 assert.equal(hostPlatform("win32", "x64"), "windows-x64");
44 assert.equal(hostPlatform("darwin", "arm64"), "macos-arm64");
45 assert.equal(hostPlatform("linux", "x64"), "linux-x64");
46 assert.equal(platformOfTriple("x86_64-pc-windows-msvc"), "windows-x64");
47 assert.equal(platformOfTriple("aarch64-apple-darwin"), "macos-arm64");
48 assert.equal(platformOfTriple("debug"), null);
49});
50
51test("the manifest serves the updater and the download page", () => {
52 const entries = [
53 {
54 platform: "windows",
55 arch: "x64",
56 kind: "installer",
57 name: "g1t-0.1.0-windows-x64-setup.exe",
58 updater: true,
59 size: 10,
60 sha256: "a",
61 signature: "sig-win",
62 },
63 { platform: "macos", arch: "arm64", kind: "update", name: "g1t-0.1.0-macos-arm64.app.tar.gz", updater: true, size: 20, sha256: "b", signature: "sig-mac" },
64 { platform: "macos", arch: "arm64", kind: "dmg", name: "g1t-0.1.0-macos-arm64.dmg", updater: false, size: 30, sha256: "c", signature: null },
65 { platform: "linux", arch: "x64", kind: "deb", name: "g1t-0.1.0-linux-x64.deb", updater: false, size: 40, sha256: "d", signature: null },
66 ];
67 const m = manifest(entries, "0.1.0", { date: "2026-10-11T00:00:00.000Z", notes: "First." });
68 assert.equal(m.version, "0.1.0");
69 assert.equal(m.notes, "First.");
70 assert.deepEqual(m.platforms, {
71 "windows-x86_64": { url: "https://g1t.sh/downloads/desktop/0.1.0/g1t-0.1.0-windows-x64-setup.exe", signature: "sig-win" },
72 "darwin-aarch64": { url: "https://g1t.sh/downloads/desktop/0.1.0/g1t-0.1.0-macos-arm64.app.tar.gz", signature: "sig-mac" },
73 });
74 // The update archive is the updater's alone; people download the disk image.
75 assert.deepEqual(
76 m.downloads.map((d) => d.name),
77 ["g1t-0.1.0-linux-x64.deb", "g1t-0.1.0-macos-arm64.dmg", "g1t-0.1.0-windows-x64-setup.exe"],
78 );
79 assert.deepEqual(m.downloads[1], { platform: "macos", arch: "arm64", kind: "dmg", name: "g1t-0.1.0-macos-arm64.dmg", size: 30, sha256: "c" });
80});