Skip to content

Commit f4f3d18

Browse files
committed
fix(ci): cover time-balanced shards in the gate test
1 parent 76f1ffb commit f4f3d18

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

‎tests/unit/check-gate.test.ts‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,31 @@ describe("check gate", () => {
8686
});
8787

8888
test("CI test shards cover exactly the suite's paths", () => {
89+
// Time-balanced --shard slices each run the full union (bun partitions
90+
// files across the slices, balanced by --timings), so coverage holds
91+
// when the matrix has all four slices and the shard command template
92+
// carries the suite's paths plus the interpolated --shard flag.
8993
// Sharding must never silently drop (or double-run) part of the suite:
90-
// expanding the matrix shards' filters to test files has to equal the
91-
// unsharded `test` script's paths expanded the same way. Subdirectory
92-
// shards (src-a/b/c) can never equal the literal ./src string, so this
93-
// compares sorted file sets; a file covered twice fails the equality
94-
// through the duplicate entry.
95-
const shardFilters = [...ci.matchAll(/^\s+paths: (.+)$/gm)].flatMap(
96-
(match) => match[1]?.trim().split(/\s+/) ?? [],
97-
);
94+
// expanding the template's filters to test files has to equal the
95+
// unsharded `test` script's paths expanded the same way.
96+
for (const shard of ["1/4", "2/4", "3/4", "4/4"]) {
97+
expect(ci).toContain(`"${shard}"`);
98+
}
99+
const runArgs = [
100+
...ci.matchAll(/^\s*run: bun run check:projects-dir-guard(.+)$/gm),
101+
]
102+
.map((match) => match[1] ?? "")
103+
.find((args) => args.includes("--shard=${{ matrix.shard }}"));
104+
expect(runArgs).toBeDefined();
105+
const shardFilters = (runArgs ?? "")
106+
.split(/\s+/)
107+
.filter((part) => part.startsWith("./"));
98108
const suiteFilters = TEST_SUITE.split(" ").filter((part) =>
99109
part.startsWith("./"),
100110
);
101111
expect(expandToTestFiles(shardFilters)).toEqual(
102112
expandToTestFiles(suiteFilters),
103113
);
114+
expect(runArgs).toContain("--timings=./scripts/ci-timings.json");
104115
});
105116
});

0 commit comments

Comments
 (0)