Skip to content

Commit c0c9544

Browse files
authored
Merge pull request #2546 from lidge-jun/codex/release-gate-isolation-parity
fix(release): run the preflight suite in the same groups CI does
2 parents 5170fc8 + 89295c6 commit c0c9544

2 files changed

Lines changed: 53 additions & 3 deletions

File tree

‎scripts/release.ts‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,40 @@ await runLoud(["bun", "run", "audit:high"]);
519519
console.log("→ typecheck");
520520
await runLoud(["bun", "x", "tsc", "--noEmit"]);
521521
console.log("→ test suite");
522-
await runLoud(["bun", "test", "--isolate", "tests"]);
522+
// Match CI's isolation policy instead of inventing a second one. `ci.yml` runs
523+
// the storage-policy and api-usage harnesses in DEDICATED jobs and excludes them
524+
// from the general shards (`scripts/ci/run-bun-test-batches.sh`
525+
// `is_general_test_file`), because those Worker-heavy files corrupt the isolate
526+
// state around them.
527+
//
528+
// This preflight used to run `bun test --isolate tests` — the whole directory in
529+
// one process — so it exercised a grouping CI never runs. The result was a
530+
// release gate that failed on `api-usage` while every CI job for the same commit
531+
// was green: the worst kind of gate, one that blocks a good release and teaches
532+
// you to distrust it. Same files and same coverage as before (915), now in the
533+
// same groups CI uses.
534+
// Every command here stays a `bun` invocation. The release-helper suite shims
535+
// exactly `bun`, `gh`, `git` and `npm` onto a scratch PATH to record calls
536+
// without executing them; a `bash` step would miss that shim, escape into the
537+
// real suite, and fail the helper tests with exit 127.
538+
const ISOLATED_TEST_FILES = [
539+
"./tests/api-storage-policy-already-running.test.ts",
540+
"./tests/api-storage-policy-mutation-busy.test.ts",
541+
"./tests/api-storage-policy-put-race.test.ts",
542+
"./tests/api-storage-policy-run.test.ts",
543+
"./tests/api-storage-policy.test.ts",
544+
"./tests/api-storage.test.ts",
545+
"./tests/api-usage.test.ts",
546+
];
547+
await runLoud([
548+
"bun", "test", "--isolate", "tests",
549+
"--path-ignore-patterns=**/api-storage-policy*.test.ts",
550+
"--path-ignore-patterns=**/api-storage.test.ts",
551+
"--path-ignore-patterns=**/api-usage.test.ts",
552+
]);
553+
for (const isolated of ISOLATED_TEST_FILES) {
554+
await runLoud(["bun", "test", "--isolate", isolated]);
555+
}
523556
console.log("→ privacy scan");
524557
await runLoud(["bun", "run", "privacy:scan"]);
525558

‎tests/release-helper.test.ts‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,21 @@ describe("release helper", () => {
324324

325325
const auditIndex = findCallIndex(calls, "bun", call => call.args.join(" ") === "run audit:high");
326326
const typecheckIndex = findCallIndex(calls, "bun", call => call.args.join(" ") === "x tsc --noEmit");
327-
const testIndex = findCallIndex(calls, "bun", call => call.args.join(" ") === "test --isolate tests");
327+
// The suite runs in CI's two groups, not as one directory sweep: the general
328+
// files with the Worker-heavy harnesses ignored, then those harnesses one at
329+
// a time. Assert the grouping, not just that "a test command ran" — the whole
330+
// point of the change is WHICH processes the files land in.
331+
const testIndex = findCallIndex(calls, "bun", call =>
332+
call.args[0] === "test"
333+
&& call.args.includes("tests")
334+
&& call.args.some(arg => arg.startsWith("--path-ignore-patterns=") && arg.includes("api-usage")),
335+
);
336+
const isolatedUsageIndex = findCallIndex(calls, "bun", call =>
337+
call.args.join(" ") === "test --isolate ./tests/api-usage.test.ts",
338+
);
339+
const isolatedStorageIndex = findCallIndex(calls, "bun", call =>
340+
call.args.join(" ") === "test --isolate ./tests/api-storage.test.ts",
341+
);
328342
const privacyIndex = findCallIndex(calls, "bun", call => call.args.join(" ") === "run privacy:scan");
329343
const versionIndex = findCallIndex(calls, "npm", call => call.args.join(" ") === "version 9.9.9 --no-git-tag-version");
330344
const dispatchIndex = findCallIndex(calls, "gh", call =>
@@ -338,7 +352,10 @@ describe("release helper", () => {
338352
expect(auditIndex).toBeGreaterThanOrEqual(0);
339353
expect(typecheckIndex).toBeGreaterThan(auditIndex);
340354
expect(testIndex).toBeGreaterThan(typecheckIndex);
341-
expect(privacyIndex).toBeGreaterThan(testIndex);
355+
// Every excluded harness is still executed, in its own process.
356+
expect(isolatedUsageIndex).toBeGreaterThan(testIndex);
357+
expect(isolatedStorageIndex).toBeGreaterThan(testIndex);
358+
expect(privacyIndex).toBeGreaterThan(isolatedUsageIndex);
342359
expect(versionIndex).toBeGreaterThan(privacyIndex);
343360
expect(dispatchIndex).toBeGreaterThan(versionIndex);
344361
});

0 commit comments

Comments
 (0)