fix(ci): make pr-ci-sweeper clock injectable so lookback fixtures cannot rot

This commit is contained in:
Peter Steinberger
2026-07-19 03:26:50 -07:00
parent 6add21bf40
commit e2930422d0
2 changed files with 12 additions and 2 deletions
+10 -2
View File
@@ -131,13 +131,21 @@ async function reopenWithRetry({ github, core, owner, repo, pullNumber }) {
return false;
}
export async function runPrCiSweeper({ github, context, core, dryRun = false, appSlug = "" }) {
export async function runPrCiSweeper({
github,
context,
core,
dryRun = false,
appSlug = "",
// Injectable clock: fixture-based tests pin a fixed instant so lookback
// classification cannot rot as wall-clock time passes the fixture dates.
now = Date.now(),
}) {
const sweeperLogins = new Set(KNOWN_SWEEPER_LOGINS);
if (appSlug) {
sweeperLogins.add(`${appSlug}[bot]`);
}
const { owner, repo } = context.repo;
const now = Date.now();
const results = [];
let refires = 0;
const openPrs = await github.paginate(github.rest.pulls.list, {