mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 02:52:15 +00:00
fix(ci): fail closed on partial kova reports
This commit is contained in:
@@ -3,6 +3,9 @@ import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
function numericCount(value) {
|
||||
if (typeof value !== "number") {
|
||||
return undefined;
|
||||
}
|
||||
const count = Number(value);
|
||||
return Number.isFinite(count) ? count : undefined;
|
||||
}
|
||||
@@ -16,15 +19,21 @@ export function evaluateToleratedPartialKovaReport(report) {
|
||||
return { ok: false, reason: `gate verdict was ${JSON.stringify(gate.verdict)}` };
|
||||
}
|
||||
|
||||
const blockingCount = numericCount(gate.blockingCount ?? 0);
|
||||
if (blockingCount === undefined || blockingCount !== 0) {
|
||||
const blockingCount = numericCount(gate.blockingCount);
|
||||
if (blockingCount === undefined) {
|
||||
return { ok: false, reason: "missing blocking count" };
|
||||
}
|
||||
if (blockingCount !== 0) {
|
||||
return { ok: false, reason: `blocking count was ${JSON.stringify(gate.blockingCount)}` };
|
||||
}
|
||||
|
||||
const baselineRegressionCount = numericCount(
|
||||
report?.baseline?.comparison?.regressionCount ?? report?.gate?.baseline?.regressionCount ?? 0,
|
||||
report?.baseline?.comparison?.regressionCount ?? report?.gate?.baseline?.regressionCount,
|
||||
);
|
||||
if (baselineRegressionCount === undefined || baselineRegressionCount !== 0) {
|
||||
if (baselineRegressionCount === undefined) {
|
||||
return { ok: false, reason: "missing baseline regression count" };
|
||||
}
|
||||
if (baselineRegressionCount !== 0) {
|
||||
return {
|
||||
ok: false,
|
||||
reason: `baseline regression count was ${JSON.stringify(baselineRegressionCount)}`,
|
||||
|
||||
@@ -47,6 +47,46 @@ describe("scripts/lib/kova-report-gate.mjs", () => {
|
||||
).toEqual({ ok: false, reason: "missing status summary" });
|
||||
});
|
||||
|
||||
it("rejects partial reports without explicit blocking counts", () => {
|
||||
expect(
|
||||
evaluateToleratedPartialKovaReport(
|
||||
partialReport({
|
||||
gate: { verdict: "PARTIAL" },
|
||||
}),
|
||||
),
|
||||
).toEqual({ ok: false, reason: "missing blocking count" });
|
||||
});
|
||||
|
||||
it("rejects partial reports with malformed zero-like blocking counts", () => {
|
||||
expect(
|
||||
evaluateToleratedPartialKovaReport(
|
||||
partialReport({
|
||||
gate: { blockingCount: "", verdict: "PARTIAL" },
|
||||
}),
|
||||
),
|
||||
).toEqual({ ok: false, reason: "missing blocking count" });
|
||||
});
|
||||
|
||||
it("rejects partial reports without explicit baseline regression counts", () => {
|
||||
expect(
|
||||
evaluateToleratedPartialKovaReport(
|
||||
partialReport({
|
||||
baseline: {},
|
||||
}),
|
||||
),
|
||||
).toEqual({ ok: false, reason: "missing baseline regression count" });
|
||||
});
|
||||
|
||||
it("rejects partial reports with malformed zero-like baseline regression counts", () => {
|
||||
expect(
|
||||
evaluateToleratedPartialKovaReport(
|
||||
partialReport({
|
||||
baseline: { comparison: { regressionCount: null } },
|
||||
}),
|
||||
),
|
||||
).toEqual({ ok: false, reason: "missing baseline regression count" });
|
||||
});
|
||||
|
||||
it("rejects partial reports without PASS records", () => {
|
||||
expect(
|
||||
evaluateToleratedPartialKovaReport(
|
||||
|
||||
Reference in New Issue
Block a user