mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(ci): reject malformed targeted docker group size
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user