Skip to content

Commit 20c2407

Browse files
committed
fix(ci): cover time-balanced shards in the gate test
1 parent a3a8271 commit 20c2407

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

tests/unit/check-gate.test.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,28 @@ describe("check gate", () => {
6767
});
6868

6969
test("CI test shards cover exactly the suite's paths", () => {
70-
// Sharding must never silently drop part of the suite: the union of the
71-
// matrix shards has to equal the unsharded `test` script's paths.
72-
const shardPaths = [...ci.matchAll(/^\s+paths: (.+)$/gm)]
73-
.flatMap((match) => match[1]?.trim().split(/\s+/) ?? [])
74-
.sort();
70+
// Time-balanced --shard slices each run the full union (bun splits by
71+
// file, balanced by --timings), so coverage holds when the matrix has
72+
// all four slices and the shard command template carries the suite's
73+
// paths plus the interpolated --shard flag. Sharding must never
74+
// silently drop part of the suite.
7575
const suitePaths = TEST_SUITE.split(" ")
7676
.filter((part) => part.startsWith("./"))
7777
.sort();
78-
expect(shardPaths).toEqual(suitePaths);
78+
for (const shard of ["1/4", "2/4", "3/4", "4/4"]) {
79+
expect(ci).toContain(`"${shard}"`);
80+
}
81+
const runArgs = [
82+
...ci.matchAll(/^\s*run: bun run check:projects-dir-guard(.+)$/gm),
83+
]
84+
.map((match) => match[1] ?? "")
85+
.find((args) => args.includes("--shard=${{ matrix.shard }}"));
86+
expect(runArgs).toBeDefined();
87+
const runPaths = (runArgs ?? "")
88+
.split(/\s+/)
89+
.filter((part) => part.startsWith("./"))
90+
.sort();
91+
expect(runPaths).toEqual(suitePaths);
92+
expect(runArgs).toContain("--timings=./scripts/ci-timings.json");
7993
});
8094
});

0 commit comments

Comments
 (0)