From 8b609f1c534df41ee7001d987657769e9e292b51 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sat, 31 Oct 2026 23:27:19 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B1=20chore(ci):=20share=20the=20close?= =?UTF-8?q?d-PR=20no-op=20message=20in=20native-queue-policy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .github/scripts/native-queue-policy.cjs | 8 +++++--- .github/scripts/native-queue-policy.test.cjs | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/scripts/native-queue-policy.cjs b/.github/scripts/native-queue-policy.cjs index fbc0ccba1a..b2c4f8f698 100644 --- a/.github/scripts/native-queue-policy.cjs +++ b/.github/scripts/native-queue-policy.cjs @@ -22,6 +22,8 @@ const SHA = /^[a-f0-9]{40}$/; const BLOCKED_LABEL = /^(hold|needs-human|release-in-progress|do-not-merge(?:\/.*)?)$/i; const MAX_QUEUE_PAGES = 10; +const closedNoop = (pr) => `PR #${pr.number} is closed; nothing to evaluate`; + class PendingEvidence extends Error {} function membersForGroup(entries, group) { @@ -173,11 +175,11 @@ async function evaluate({ github, context }) { const event = context.payload.pull_request; const { data: pr } = await github.rest.pulls.get({ ...repo, pull_number: event.number }); // Post-merge label/comment edits re-fire this event; a closed PR has nothing to gate. - if (pr.state === 'closed') return `PR #${pr.number} is closed; nothing to evaluate`; + if (pr.state === 'closed') return closedNoop(pr); assertEligible(pr, event.head.sha, event.base.ref); await assertEvidence(github, repo, pr.number, pr.head.sha, POLICY_CHECKS); const { data: current } = await github.rest.pulls.get({ ...repo, pull_number: event.number }); - if (current.state === 'closed') return `PR #${current.number} is closed; nothing to evaluate`; + if (current.state === 'closed') return closedNoop(current); assertEligible(current, event.head.sha, event.base.ref); return `PR #${pr.number}: five existing policy providers succeeded on ${pr.head.sha}`; } @@ -219,5 +221,5 @@ async function evaluate({ github, context }) { module.exports = { ACTIONS_APP_ID, DCO_APP_ID, POLICY_CHECKS, BUILD_CHECKS, - PendingEvidence, membersForGroup, assertEligible, evidenceForHead, evaluate, + PendingEvidence, membersForGroup, assertEligible, evidenceForHead, closedNoop, evaluate, }; diff --git a/.github/scripts/native-queue-policy.test.cjs b/.github/scripts/native-queue-policy.test.cjs index 5000c63700..e64e50471a 100644 --- a/.github/scripts/native-queue-policy.test.cjs +++ b/.github/scripts/native-queue-policy.test.cjs @@ -3,7 +3,7 @@ const { test } = require('node:test'); const assert = require('node:assert/strict'); const { ACTIONS_APP_ID, DCO_APP_ID, POLICY_CHECKS, BUILD_CHECKS, - PendingEvidence, membersForGroup, assertEligible, evidenceForHead, evaluate, + PendingEvidence, membersForGroup, assertEligible, evidenceForHead, closedNoop, evaluate, } = require('./native-queue-policy.cjs'); const sha = n => n.toString(16).padStart(40, '0'); @@ -191,7 +191,7 @@ test('closed PR on pull_request_target passes as a no-op and skips evidence look let lookups = 0; const paginate = f.github.paginate; f.github.paginate = async (...args) => { lookups++; return paginate(...args); }; - assert.match(await evaluate(f), /PR #1 is closed; nothing to evaluate/); + assert.match(await evaluate(f), new RegExp(closedNoop(f.state.prs[0]))); assert.equal(lookups, 0); }); @@ -204,7 +204,7 @@ test('PR closed during evidence wait passes as a no-op', async () => { if (++reads === 2) res.data.state = 'closed'; return res; }; - assert.match(await evaluate(f), /is closed; nothing to evaluate/); + assert.match(await evaluate(f), new RegExp(closedNoop(f.state.prs[0]))); }); test('open PR with moved head still fails closed on pull_request_target', async () => {