Skip to content

Commit 3cc2496

Browse files
committed
Clean up macOS release hygiene tests
1 parent 40862a1 commit 3cc2496

2 files changed

Lines changed: 32 additions & 62 deletions

File tree

tests/unit/macos-release-signing.test.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ printf '%s\\n' "$STUB_NOTARY_JSON"`,
4545
await command("ditto", `: > "$5"`);
4646
await command("plutil", `cp "$5" "$4"`);
4747

48-
const run = (operation = "sign-and-notarize", architecture = "arm64", overrides = {}) =>
48+
const run = (operation = "sign", architecture = "arm64", overrides = {}) =>
4949
Bun.spawnSync({
5050
cmd: ["bash", helper, operation, artifact, architecture],
5151
cwd: root,
@@ -81,7 +81,7 @@ describe("macOS release signing gate", () => {
8181

8282
test("signs, notarizes, and validates an accepted artifact", async () => {
8383
const { run } = await createFixture();
84-
const signed = run("sign");
84+
const signed = run();
8585
expect({ exitCode: signed.exitCode, stderr: signed.stderr.toString() }).toEqual({
8686
exitCode: 0,
8787
stderr: "",
@@ -119,30 +119,4 @@ describe("macOS release signing gate", () => {
119119
const { run } = await createFixture();
120120
expect(run("verify", "x86_64", { STUB_ARCHES: "arm64" }).exitCode).not.toBe(0);
121121
});
122-
123-
test("keeps both macOS architectures on the mandatory pre-publication path", async () => {
124-
const release = await readFile(join(root, "scripts/release.sh"), "utf8");
125-
expect(release).toContain('"macos-arm64|bun-darwin-arm64|macos|-"');
126-
expect(release).toContain('"macos-x64|bun-darwin-x64|macos|-"');
127-
expect(release).toContain('[ "$kind" != macos ] && [ -f "$tarball" ]');
128-
129-
const signing = release.indexOf('"$MACOS_RELEASE_HELPER" sign ');
130-
const nativeSmoke = release.indexOf('"$MACOS_HOST_NATIVE_SMOKE" "$label"');
131-
const notarization = release.indexOf('"$MACOS_RELEASE_HELPER" notarize ');
132-
const extraction = release.indexOf('tar -xzf "$tarball"');
133-
const checksum = release.indexOf('shasum -a 256 "$pkg.tar.gz"');
134-
const publication = release.indexOf('step "Land release commit');
135-
expect(signing).toBeGreaterThan(0);
136-
expect(nativeSmoke).toBeGreaterThan(signing);
137-
expect(notarization).toBeGreaterThan(nativeSmoke);
138-
expect(extraction).toBeGreaterThan(notarization);
139-
expect(checksum).toBeGreaterThan(extraction);
140-
expect(publication).toBeGreaterThan(checksum);
141-
expect(release.slice(0, publication)).toContain(
142-
'[ "$validated_macos" -eq 2 ] || die "both macOS architectures must rebuild and pass release validation"',
143-
);
144-
expect(release.slice(0, publication)).toContain(
145-
'[ "$native_smoked_macos" -eq 1 ] || die "host-native signed OpenTUI smoke is required before publication"',
146-
);
147-
});
148122
});

tests/unit/release-native-validation.test.ts

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ async function createStubBinDirectory() {
3030
return { directory, binDirectory, command };
3131
}
3232

33+
async function stubCurlDownload(
34+
command: (name: string, body: string) => Promise<void>,
35+
tarball: string,
36+
) {
37+
await command(
38+
"curl",
39+
`out=""
40+
prev=""
41+
for arg in "$@"; do
42+
if [ "$prev" = "-o" ]; then out="$arg"; fi
43+
prev="$arg"
44+
done
45+
[ -n "$out" ]
46+
cp "${tarball}" "$out"`,
47+
);
48+
}
49+
3350
describe("host-native signed OpenTUI smoke counting", () => {
3451
test("release gate separates host-native smoke from opposite-arch signature validation", async () => {
3552
const source = await readFile(release, "utf8");
@@ -40,10 +57,15 @@ describe("host-native signed OpenTUI smoke counting", () => {
4057
expect(source).toContain(
4158
'[ "$validated_macos" -eq 2 ] || die "both macOS architectures must rebuild and pass release validation"',
4259
);
60+
expect(source).toContain('"macos-arm64|bun-darwin-arm64|macos|-"');
61+
expect(source).toContain('"macos-x64|bun-darwin-x64|macos|-"');
62+
expect(source).toContain('[ "$kind" != macos ] && [ -f "$tarball" ]');
4363

4464
const sign = source.indexOf('"$MACOS_RELEASE_HELPER" sign ');
4565
const smoke = source.indexOf('"$MACOS_HOST_NATIVE_SMOKE" "$label"');
4666
const notarize = source.indexOf('"$MACOS_RELEASE_HELPER" notarize ');
67+
const extraction = source.indexOf('tar -xzf "$tarball"');
68+
const checksum = source.indexOf('shasum -a 256 "$pkg.tar.gz"');
4769
const validated = source.indexOf("validated_macos=$((validated_macos + 1))");
4870
const nativeGate = source.indexOf(
4971
'[ "$native_smoked_macos" -eq 1 ] || die "host-native signed OpenTUI smoke is required before publication"',
@@ -52,8 +74,10 @@ describe("host-native signed OpenTUI smoke counting", () => {
5274
expect(sign).toBeGreaterThan(0);
5375
expect(smoke).toBeGreaterThan(sign);
5476
expect(notarize).toBeGreaterThan(smoke);
55-
expect(validated).toBeGreaterThan(notarize);
56-
expect(nativeGate).toBeGreaterThan(validated);
77+
expect(extraction).toBeGreaterThan(notarize);
78+
expect(validated).toBeGreaterThan(extraction);
79+
expect(checksum).toBeGreaterThan(validated);
80+
expect(nativeGate).toBeGreaterThan(checksum);
5781
expect(publication).toBeGreaterThan(nativeGate);
5882
});
5983

@@ -112,7 +136,7 @@ describe("OpenTUI native package lockfile integrity", () => {
112136
});
113137

114138
test("mismatched checksum fails before unpack", async () => {
115-
const { directory, binDirectory } = await createStubBinDirectory();
139+
const { directory, binDirectory, command } = await createStubBinDirectory();
116140
const lockfile = join(directory, "bun.lock");
117141
const dest = join(directory, "node_modules/@opentui/core-darwin-arm64");
118142
const tarball = join(directory, "payload.tgz");
@@ -121,21 +145,7 @@ describe("OpenTUI native package lockfile integrity", () => {
121145
lockfile,
122146
`{\n "packages": {\n "@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.5.1", "", {}, "sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],\n }\n}\n`,
123147
);
124-
await writeFile(
125-
join(binDirectory, "curl"),
126-
`#!/bin/sh
127-
set -eu
128-
out=""
129-
prev=""
130-
for arg in "$@"; do
131-
if [ "$prev" = "-o" ]; then out="$arg"; fi
132-
prev="$arg"
133-
done
134-
[ -n "$out" ]
135-
cp "${tarball}" "$out"
136-
`,
137-
);
138-
await chmod(join(binDirectory, "curl"), 0o755);
148+
await stubCurlDownload(command, tarball);
139149

140150
const result = Bun.spawnSync({
141151
cmd: ["bash", fetchOpentui, "core-darwin-arm64", "0.5.1", dest, lockfile],
@@ -153,7 +163,7 @@ cp "${tarball}" "$out"
153163
});
154164

155165
test("packages-array hash wins over nested optionalDependencies false match", async () => {
156-
const { directory, binDirectory } = await createStubBinDirectory();
166+
const { directory, binDirectory, command } = await createStubBinDirectory();
157167
const lockfile = join(directory, "bun.lock");
158168
const dest = join(directory, "node_modules/@opentui/core-darwin-arm64");
159169
const packageRoot = join(directory, "package");
@@ -192,21 +202,7 @@ cp "${tarball}" "$out"
192202
}
193203
`,
194204
);
195-
await writeFile(
196-
join(binDirectory, "curl"),
197-
`#!/bin/sh
198-
set -eu
199-
out=""
200-
prev=""
201-
for arg in "$@"; do
202-
if [ "$prev" = "-o" ]; then out="$arg"; fi
203-
prev="$arg"
204-
done
205-
[ -n "$out" ]
206-
cp "${tarball}" "$out"
207-
`,
208-
);
209-
await chmod(join(binDirectory, "curl"), 0o755);
205+
await stubCurlDownload(command, tarball);
210206

211207
const accept = Bun.spawnSync({
212208
cmd: ["bash", fetchOpentui, "core-darwin-arm64", "0.5.1", dest, lockfile],

0 commit comments

Comments
 (0)