fix(ci): keep equal-duration shard allocation from leaving jobs empty (#14257)

Co-authored-by: ShuaixinHuang <ShuaixinHuang@users.noreply.github.com>
This commit is contained in:
ShuaixinHuangandShuaixinHuang authored and GitHub committed 2026-11-24 11:48:01 -05:00
1 parent 8a77faf842
commit 5aef49a421
2 files changed
+14 -1

No files matched your search

@@ -235,3 +235,13 @@ describe("duration shard allocation", () => {
).toBe(300);
});
});
it("uses both shards when equal files fit into spare workers in one shard", () => {
const items = ["a", "b"].map((key) => ({
item: key,
key,
duration: 20,
laneWidth: 2,
}));
expect(allocateByDuration(items, 2)).toEqual([["a"], ["b"]]);
});
+4 -1
View File
@@ -181,7 +181,10 @@ export function allocateByDuration<T>(
for (const candidate of shards.slice(1)) {
const phases = place(candidate.phases, entry, duration);
const wall = wallOf(phases);
if (wall < chosenWall) {
if (
wall < chosenWall ||
(wall === chosenWall && candidate.items.length < chosen.items.length)
) {
chosen = candidate;
chosenPhases = phases;
chosenWall = wall;