From 868cc2a0d510bf721efa351619d3a17339077036 Mon Sep 17 00:00:00 2001 From: Axel RICHARD Date: Thu, 12 Nov 2026 11:31:39 +0100 Subject: [PATCH] [releng] Update the check-labels.js script to check new labels Update the `check-labels.js` script to check for the `queue:` and `review-window:` labels Signed-off-by: Axel RICHARD --- scripts/check-labels.js | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/scripts/check-labels.js b/scripts/check-labels.js index a413cf790a..ceb4a2114c 100644 --- a/scripts/check-labels.js +++ b/scripts/check-labels.js @@ -12,24 +12,29 @@ *******************************************************************************/ const event = process.env.GITHUB_EVENT; const body = JSON.parse(event); -const labels = body.pull_request.labels; -const errors = []; -if (labels.filter((label) => label.name.startsWith("priority:")).length !== 1) { - errors.push("The pull request must have exactly one 'priority:' label"); -} -if ( - labels.filter((label) => label.name.startsWith("pr: to review")).length !== 1 -) { - errors.push("The pull request must have exactly one 'pr: to review' label"); -} -if (labels.length > 2) { - errors.push( - "The pull request contains useless labels, please use only priority and pr labels for pull requests", +const hasOneQueueLabel = + body.pull_request.labels.filter((label) => label.name.startsWith("queue:")) + .length === 1; +const hasOneReviewWindowLabel = + body.pull_request.labels.filter((label) => + label.name.startsWith("review-window:"), + ).length === 1; + +const hasOnlyAllowedLabels = body.pull_request.labels + .map((label) => label.name) + .every( + (label) => label.startsWith("queue:") || label.startsWith("review-window:"), ); -} -if (errors.length > 0) { - errors.map((message) => console.log(message)); +if (!hasOneQueueLabel || !hasOneReviewWindowLabel) { + console.log( + "The pull request is either lacking the queue or the review-window label", + ); + process.exit(1); +} else if (!hasOnlyAllowedLabels) { + console.log( + "The pull request contains useless labels, please use queue and review-window labels for pull requests", + ); process.exit(1); }