Skip to content

Commit 92d34de

Browse files
committed
tools: skip early single-approval PRs in commit queue
Filter regular commit-queue PRs in the workflow so PRs with only one approval are skipped until they have been open for 7 days. Keep the fast-track path unchanged and update the commit-queue documentation to match the workflow behavior. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5
1 parent 87d6386 commit 92d34de

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

.github/workflows/commit-queue.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,25 @@ jobs:
3333
- name: Get Pull Requests
3434
id: get_mergeable_prs
3535
run: |
36-
prs=$(gh pr list \
36+
seven_days_ago=$(date --date="7 days ago" +"%Y-%m-%dT%H:%M:%SZ")
37+
regular_prs=$(gh pr list \
3738
--repo "$GITHUB_REPOSITORY" \
3839
--base "$GITHUB_REF_NAME" \
3940
--label 'commit-queue' \
40-
--json 'number' \
41-
--search "created:<=$(date --date="2 days ago" +"%Y-%m-%dT%H:%M:%S%z") -label:blocked" \
42-
-t '{{ range . }}{{ .number }} {{ end }}' \
43-
--limit 100)
41+
--json 'number,createdAt,reviews,commits' \
42+
--search "created:<=$(date --date="2 days ago" +"%Y-%m-%dT%H:%M:%S%z") -label:blocked -label:fast-track" \
43+
--limit 100 | jq --arg seven_days_ago "$seven_days_ago" -r '
44+
.[]
45+
| . as $pr
46+
| ([.reviews[]
47+
| select(
48+
.state == "APPROVED" and
49+
.author.login != null and
50+
.submittedAt > $pr.commits[-1].committedDate
51+
)
52+
| .author.login] | unique | length) as $approvals
53+
| select($approvals >= 2 or ($approvals == 1 and .createdAt <= $seven_days_ago))
54+
| .number' | xargs)
4455
fast_track_prs=$(gh pr list \
4556
--repo "$GITHUB_REPOSITORY" \
4657
--base "$GITHUB_REF_NAME" \
@@ -50,7 +61,7 @@ jobs:
5061
--json 'number' \
5162
-t '{{ range . }}{{ .number }} {{ end }}' \
5263
--limit 100)
53-
numbers=$(echo $prs' '$fast_track_prs | jq -r -s 'unique | join(" ")')
64+
numbers=$(echo "${regular_prs} ${fast_track_prs}" | xargs)
5465
echo "numbers=$numbers" >> "$GITHUB_OUTPUT"
5566
env:
5667
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

doc/contributing/commit-queue.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@ From a high-level, the Commit Queue works as follow:
1818
1. Collaborators will add `commit-queue` label to pull requests ready to land
1919
2. Every five minutes the queue will do the following for each mergeable pull request
2020
with the label:
21-
1. Check if the PR also has a `request-ci` label (if it has, skip this PR
21+
1. For regular pull requests without `fast-track`, skip PRs that have only one
22+
approval unless they have been open for at least 7 days
23+
2. Check if the PR also has a `request-ci` label (if it has, skip this PR
2224
since it's pending a CI run)
23-
2. Check if the last Jenkins CI is finished running (if it is not, skip this
25+
3. Check if the last Jenkins CI is finished running (if it is not, skip this
2426
PR)
25-
3. Remove the `commit-queue` label
26-
4. Run `git node land <pr> --oneCommitMax`
27-
5. If it fails:
27+
4. Remove the `commit-queue` label
28+
5. Run `git node land <pr> --oneCommitMax`
29+
6. If it fails:
2830
1. Abort `git node land` session
2931
2. Add `commit-queue-failed` label to the PR
3032
3. Leave a comment on the PR with the output from `git node land`
3133
4. Skip next steps, go to next PR in the queue
32-
6. If it succeeds:
34+
7. If it succeeds:
3335
1. Push the changes to nodejs/node
3436
2. Leave a comment on the PR with `Landed in ...`
3537
3. Close the PR
@@ -79,9 +81,10 @@ reasons:
7981
`@node-core/utils` is configured with a personal token and
8082
a Jenkins token from
8183
[@nodejs-github-bot](https://github.com/nodejs/github-bot).
82-
`octokit/graphql-action` is used to fetch all pull requests with the
83-
`commit-queue` label. The output is a JSON payload, so `jq` is used to turn
84-
that into a list of PR ids we can pass as arguments to
84+
The workflow fetches pull requests with the `commit-queue` label. For pull
85+
requests without `fast-track`, it filters out PRs that have only one approval
86+
unless they have been open for at least 7 days. The output is then turned into
87+
a list of PR ids we can pass as arguments to
8588
[`commit-queue.sh`](../../tools/actions/commit-queue.sh).
8689

8790
> The personal token only needs permission for public repositories and to read

0 commit comments

Comments
 (0)