tools: check CI availability and workload

Select mergeable PRs and check Jenkins availability and workload before
removing request labels. Leave requests for a later run when Jenkins is
unavailable or the workload has reached the configured limit.

Make the batch size and workload limit repository variables, defaulting
to 5 and 10 respectively.

Refs: https://github.com/nodejs/node-core-utils/pull/1204
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66280
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Filip Skokan authored and Antoine du Hamel committed 2026-09-28 23:54:54 +02:00
1 parent e6abdf6b01
commit aaaca48ce8
2 files changed
+48 -3

No files matched your search

+16 -3
View File
@@ -1,6 +1,9 @@
# This action uses the following secrets:
# JENKINS_USER: GitHub user whose Jenkins token is defined below
# JENKINS_TOKEN: Jenkins token, to be used to start or resume CI
# Optional repository variables:
# AUTO_START_CI_BATCH_SIZE: maximum PRs to process per run (default: 5)
# AUTO_START_CI_MAX_WORKLOAD: pause at this many running or queued PR jobs (default: 15)
name: Auto Start CI
on:
@@ -30,16 +33,25 @@ jobs:
steps:
- name: Get Pull Requests
id: get_prs_for_ci
# Explicit bash enables pipefail so jq cannot hide a failed gh query.
shell: bash
run: |
if ! [[ "$BATCH_SIZE" =~ ^[1-9][0-9]*$ ]]; then
echo '::error::AUTO_START_CI_BATCH_SIZE must be a strictly positive integer'
exit 1
fi
# Filter before selecting the batch; UNKNOWN mergeability is retried later.
numbers=$(gh pr list \
--repo "$GITHUB_REPOSITORY" \
--json 'number' \
--json 'number,mergeable' \
--search 'review:approved label:request-ci,resume-ci' \
-t '{{ range . }}{{ .number }} {{ end }}' \
--limit 5)
--limit 100 \
| jq --argjson limit "$BATCH_SIZE" \
'[.[] | select(.mergeable == "MERGEABLE") | .number] | .[:$limit] | map(tostring) | join(" ")' -r)
echo "numbers=$numbers" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
BATCH_SIZE: ${{ vars.AUTO_START_CI_BATCH_SIZE || '5' }}
start-ci:
permissions:
checks: read
@@ -78,3 +90,4 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
PULL_REQUESTS: ${{ needs.get-prs-for-ci.outputs.numbers }}
MAX_WORKLOAD: ${{ vars.AUTO_START_CI_MAX_WORKLOAD || '15' }}