From fdd0ac97cce4d541fd7578e9312cb63660ac3f20 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 23 Oct 2021 18:17:23 +0200 Subject: [PATCH 1/3] tools: abort CQ session when landing several commits Most PRs are meant to be squashed in one commit when landing. If the collaborator hasn't been using `fixup!` commits, the CQ lands the PR as several commits. This change makes the CQ abort by default when attempting to land several commits, unless there's another label added to the PR to force squashing or landing as several commits. Fixes: https://github.com/nodejs/node/issues/40436 Refs: https://github.com/nodejs/node-core-utils/pull/572 --- doc/guides/commit-queue.md | 8 +++++++- tools/actions/commit-queue.sh | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/guides/commit-queue.md b/doc/guides/commit-queue.md index dec153196ea30e..bb372f6138bc72 100644 --- a/doc/guides/commit-queue.md +++ b/doc/guides/commit-queue.md @@ -25,7 +25,7 @@ From a high-level, the Commit Queue works as follow: 2. Check if the last Jenkins CI is finished running (if it is not, skip this PR) 3. Remove the `commit-queue` label - 4. Run `git node land ` + 4. Run `git node land --oneCommitMax` 5. If it fails: 1. Abort `git node land` session 2. Add `commit-queue-failed` label to the PR @@ -37,6 +37,12 @@ From a high-level, the Commit Queue works as follow: 3. Close the PR 4. Go to next PR in the queue +To make the Commit Queue squash all the commits on a pull request in the first +one, add the `commit-queue-fixupAll` label. +To make the Commit Queue land a pull request containing several commits, add the +`commit-queue-land-multiple-commits` label. When using this option, make sure +that all commits are self-contained, meaning every commit should pass all tests. + ## Current limitations The Commit Queue feature is still in early stages, and as such it might not diff --git a/tools/actions/commit-queue.sh b/tools/actions/commit-queue.sh index 22f306cc36b684..ab635d2fa1b17a 100755 --- a/tools/actions/commit-queue.sh +++ b/tools/actions/commit-queue.sh @@ -70,7 +70,15 @@ for pr in "$@"; do # Delete the commit queue label gitHubCurl "$(labelsUrl "$pr")"/"$COMMIT_QUEUE_LABEL" DELETE - git node land --autorebase --yes "$pr" >output 2>&1 || echo "Failed to land #${pr}" + if gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-fixupAll")'; then + MULTIPLE_COMMIT_POLICY="--fixupAll" + elif gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-land-multiple-commits")'; then + MULTIPLE_COMMIT_POLICY="" + else + MULTIPLE_COMMIT_POLICY="--oneCommitMax" + fi + + git node land --autorebase --yes $MULTIPLE_COMMIT_POLICY "$pr" >output 2>&1 || echo "Failed to land #${pr}" # cat here otherwise we'll be supressing the output of git node land cat output From 6ded3d4b7441533cbe17a269f559c66ed99febb0 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 25 Oct 2021 18:16:52 +0200 Subject: [PATCH 2/3] fixup! tools: abort CQ session when landing several commits --- doc/guides/commit-queue.md | 4 ++-- tools/actions/commit-queue.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/guides/commit-queue.md b/doc/guides/commit-queue.md index bb372f6138bc72..d7ecef57c5044f 100644 --- a/doc/guides/commit-queue.md +++ b/doc/guides/commit-queue.md @@ -38,9 +38,9 @@ From a high-level, the Commit Queue works as follow: 4. Go to next PR in the queue To make the Commit Queue squash all the commits on a pull request in the first -one, add the `commit-queue-fixupAll` label. +one, add the `commit-queue-squash` label. To make the Commit Queue land a pull request containing several commits, add the -`commit-queue-land-multiple-commits` label. When using this option, make sure +`commit-queue-rebase` label. When using this option, make sure that all commits are self-contained, meaning every commit should pass all tests. ## Current limitations diff --git a/tools/actions/commit-queue.sh b/tools/actions/commit-queue.sh index ab635d2fa1b17a..7272c71b4db0ac 100755 --- a/tools/actions/commit-queue.sh +++ b/tools/actions/commit-queue.sh @@ -70,9 +70,9 @@ for pr in "$@"; do # Delete the commit queue label gitHubCurl "$(labelsUrl "$pr")"/"$COMMIT_QUEUE_LABEL" DELETE - if gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-fixupAll")'; then + if gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-squash")'; then MULTIPLE_COMMIT_POLICY="--fixupAll" - elif gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-land-multiple-commits")'; then + elif gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-rebase")'; then MULTIPLE_COMMIT_POLICY="" else MULTIPLE_COMMIT_POLICY="--oneCommitMax" From 3c4672b112d911949d5b2d6fbc7730991ac2b120 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 31 Oct 2021 15:10:08 +0100 Subject: [PATCH 3/3] fixup! tools: abort CQ session when landing several commits --- doc/guides/commit-queue.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/guides/commit-queue.md b/doc/guides/commit-queue.md index d7ecef57c5044f..edb9c7ad4a877f 100644 --- a/doc/guides/commit-queue.md +++ b/doc/guides/commit-queue.md @@ -37,8 +37,8 @@ From a high-level, the Commit Queue works as follow: 3. Close the PR 4. Go to next PR in the queue -To make the Commit Queue squash all the commits on a pull request in the first -one, add the `commit-queue-squash` label. +To make the Commit Queue squash all the commits of a pull request into the +first one, add the `commit-queue-squash` label. To make the Commit Queue land a pull request containing several commits, add the `commit-queue-rebase` label. When using this option, make sure that all commits are self-contained, meaning every commit should pass all tests.