fix(ci): reject malformed targeted docker group size

This commit is contained in:
Vincent Koc
2026-06-02 21:18:52 +02:00
parent c208a10619
commit 36a596aa9f
2 changed files with 17 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
import { fileURLToPath } from "node:url";
import { parsePositiveInt } from "./lib/numeric-options.mjs";
const BASELINE_SHARDED_LANES = new Set(["published-upgrade-survivor", "update-migration"]);
@@ -13,17 +14,6 @@ function splitTokens(raw) {
];
}
function parsePositiveInt(raw, fallback, label) {
const parsed = Number.parseInt(String(raw ?? ""), 10);
if (!Number.isFinite(parsed)) {
return fallback;
}
if (parsed < 1) {
throw new Error(`${label} must be a positive integer. Got: ${JSON.stringify(raw)}`);
}
return parsed;
}
function sanitizeLabel(value) {
return (
String(value)
@@ -43,7 +33,7 @@ export function planTargetedDockerLaneGroups({
throw new Error("docker_lanes is required when planning targeted Docker lane groups.");
}
const parsedGroupSize = parsePositiveInt(groupSize, 1, "groupSize");
const parsedGroupSize = parsePositiveInt(groupSize, "groupSize");
const baselineSpecs = splitTokens(upgradeSurvivorBaselines);
const groups = [];
let pendingLanes = [];

View File

@@ -65,4 +65,19 @@ describe("scripts/plan-targeted-docker-lane-groups", () => {
{ docker_lanes: "published-upgrade-survivor", label: "published-upgrade-survivor" },
]);
});
it("rejects malformed group size values", () => {
expect(() =>
planTargetedDockerLaneGroups({
groupSize: "2x",
lanes: "doctor-switch update-channel-switch",
}),
).toThrow("groupSize must be a positive integer");
expect(() =>
planTargetedDockerLaneGroups({
groupSize: 0,
lanes: "doctor-switch update-channel-switch",
}),
).toThrow("groupSize must be a positive integer");
});
});