From e68b0aef13a46e378255aa5a9eb22f13e9baf10c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 4 Nov 2025 18:29:12 +0100 Subject: [PATCH] ci/github-script/reviewers: improve "needs: reviewers" label This should fix the bug where the "needs: reviewer" label was set too early, just to be removed immediately, because reviewers were then requested. --- ci/github-script/bot.js | 5 ++++- ci/github-script/reviewers.js | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ci/github-script/bot.js b/ci/github-script/bot.js index e249e9c8cdbe..1b807b30ec7d 100644 --- a/ci/github-script/bot.js +++ b/ci/github-script/bot.js @@ -375,7 +375,10 @@ module.exports = async ({ github, context, core, dry }) => { }) if (!pull_request.draft) { - await handleReviewers({ + // We set this label earlier already, but the current PR state can be very different + // after handleReviewers has requested reviews, so update it in this case to prevent + // this label from flip-flopping. + prLabels['9.needs: reviewer'] = await handleReviewers({ github, context, core, diff --git a/ci/github-script/reviewers.js b/ci/github-script/reviewers.js index 56dc3ec8439a..81ad151264a1 100644 --- a/ci/github-script/reviewers.js +++ b/ci/github-script/reviewers.js @@ -68,7 +68,8 @@ async function handleReviewers({ log( `Too many reviewers (${reviewers.join(', ')}), skipping review requests.`, ) - return + // false indicates, that we do have reviewers and don't need the "needs: reviewers" label. + return false } const requested_reviewers = new Set( @@ -113,6 +114,13 @@ async function handleReviewers({ reviewers, }) } + + // Return a boolean on whether the "needs: reviewers" label should be set. + return ( + new_reviewers.size === 0 && + existing_reviewers.size === 0 && + requested_reviewers.size === 0 + ) } module.exports = {