fix: evaluate latest workflow run deterministically

This commit is contained in:
Masterluke77
2026-07-10 14:40:21 +02:00
parent d9d6f9e91a
commit ce2304cc52
+6 -3
View File
@@ -129,9 +129,12 @@ function normalizeRun(run) {
}
function bestRun(runs) {
const successful = runs.filter(run => run.state === 'success').sort((a, b) => time(b.updatedAt) - time(a.updatedAt))[0];
if (successful) return successful;
return [...runs].sort((a, b) => time(b.updatedAt) - time(a.updatedAt))[0];
return [...runs].sort((a, b) => {
const dateDelta = time(b.updatedAt) - time(a.updatedAt);
if (dateDelta) return dateDelta;
const rank = { success: 4, pending: 3, failure: 2, cancelled: 1, missing: 0 };
return (rank[b.state] || 0) - (rank[a.state] || 0);
})[0];
}
export function classifyChecks({ checks = [], workflowRuns = [], requiredChecks = REQUIRED_CHECKS, requiredWorkflows = REQUIRED_WORKFLOWS, elapsedSeconds = 0, gracePeriodSeconds = 90, timedOut = false }) {