From 0a2a48a9f0eaee4aa75b46654d12ee9f67a0545b Mon Sep 17 00:00:00 2001 From: peptiderepo <273788462+peptiderepo@users.noreply.github.com> Date: Tue, 9 Jun 2026 13:39:10 +0700 Subject: [PATCH] ci(audit): retry PR-association check (#58) listPullRequestsAssociatedWithCommit is eventually-consistent after a squash merge; the single immediate call intermittently flagged legit merges as 'direct push to main'. Now polls up to 5x/10s before opening an issue. Agent-Session: cto audit-race-fix --- .github/workflows/main-push-audit.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main-push-audit.yml b/.github/workflows/main-push-audit.yml index 0c5bec3..e892e6a 100644 --- a/.github/workflows/main-push-audit.yml +++ b/.github/workflows/main-push-audit.yml @@ -29,12 +29,22 @@ jobs: with: script: | const sha = context.sha; - const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ - owner: context.repo.owner, - repo: context.repo.repo, - commit_sha: sha, - }); - const merged = prs.find(p => p.merged_at); + // Squash-merge -> PR association is eventually-consistent; poll briefly + // before concluding this was a direct push (avoids false positives on merges). + async function findMergedPR() { + for (let attempt = 1; attempt <= 5; attempt++) { + const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ + owner: context.repo.owner, + repo: context.repo.repo, + commit_sha: sha, + }); + const m = prs.find(p => p.merged_at); + if (m) return m; + if (attempt < 5) await new Promise(r => setTimeout(r, 10000)); + } + return null; + } + const merged = await findMergedPR(); if (merged) { core.info(`OK: commit ${sha.substring(0,7)} came from PR #${merged.number}`); return;