From 7c60120074293464b7f535086b64382ee1531611 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Tue, 10 Nov 2026 22:40:56 +0100 Subject: [PATCH 1/9] GH-55475: [Dev] Use merge button instead of merge script Document the "Squash and merge" button as the way to merge pull requests. The merge script is still available. Before the merge, the "PR Title" status of the Boring Cyborg app is a required status check on main: the pull request title must start with "GH-XXX" or "MINOR: ". The required check rejects direct pushes to main, so the release guide tells release managers to bump versions with a pull request. After the merge, a workflow for pushes to main assigns the issue to the pull request author if it isn't assigned, sets its milestone, closes it and comments which pull request resolved it. --- .asf.yaml | 11 +- .github/workflows/dev_pr_merged.yml | 110 ++++++++++++++++++ dev/README.md | 31 ++++- .../continuous_integration/overview.rst | 1 + docs/source/developers/overview.rst | 8 +- docs/source/developers/release.rst | 31 ++++- 6 files changed, 178 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/dev_pr_merged.yml diff --git a/.asf.yaml b/.asf.yaml index e4652b3f86ec..4893aa313b60 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -29,7 +29,16 @@ github: protected_branches: # protect main against force push - main: {} + main: + required_status_checks: + # Don't require branches to be up to date before merging. + strict: false + # The title check ("verifyTitles") of the Boring Cyborg app + # in .github/boring-cyborg.yml. The merge button is disabled + # while the pull request title doesn't start with "GH-XXX" + # or "MINOR: ". + contexts: + - PR Title collaborators: - alinaliBQ diff --git a/.github/workflows/dev_pr_merged.yml b/.github/workflows/dev_pr_merged.yml new file mode 100644 index 000000000000..f5bdcbd336ea --- /dev/null +++ b/.github/workflows/dev_pr_merged.yml @@ -0,0 +1,110 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Dev PR merged + +on: + push: + branches: + - main + +permissions: + contents: read + pull-requests: read + issues: write + +jobs: + resolve: + name: Resolve + if: github.repository == 'apache/arrow' + runs-on: ubuntu-latest + steps: + # A pushed commit that isn't the merge commit of a pull request + # is ignored. + - name: Resolve issue + env: + COMMIT: ${{ github.sha }} + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + + pull_request=$( + gh api "repos/${GH_REPO}/commits/${COMMIT}/pulls" \ + --jq "map(select(.merge_commit_sha == \"${COMMIT}\"))[0] // empty") + if [ -z "${pull_request}" ]; then + echo "${COMMIT} isn't the merge commit of a pull request." + exit 0 + fi + title=$(jq -r .title <<< "${pull_request}") + if [[ ! "${title}" =~ ^GH-([0-9]+) ]]; then + echo "No GitHub issue in the title: ${title}" + exit 0 + fi + issue_number=${BASH_REMATCH[1]} + issue_path="repos/${GH_REPO}/issues/${issue_number}" + issue=$(gh api "${issue_path}") + if [ "$(jq 'has("pull_request")' <<< "${issue}")" = "true" ]; then + echo "#${issue_number} is a pull request, not an issue." + exit 0 + fi + + # Assign the issue to the pull request author if it isn't + # assigned to anyone. GitHub ignores this silently if the + # author can't be assigned. + if [ "$(jq '.assignees | length' <<< "${issue}")" -eq 0 ]; then + author=$(jq -r .user.login <<< "${pull_request}") + gh api "${issue_path}/assignees" -f "assignees[]=${author}" > /dev/null + fi + + # Use the milestone of the pull request. If the pull request + # doesn't have a milestone, keep the milestone of the issue. + # If the issue doesn't have a milestone either, use the next + # major release that doesn't have a maintenance branch yet + # like dev/merge_arrow_pr.py does. + milestone=$(jq -r '.milestone.number // empty' <<< "${pull_request}") + if [ -z "${milestone}" ] && \ + [ "$(jq '.milestone' <<< "${issue}")" = "null" ]; then + maintenance_versions=$( + gh api --paginate "repos/${GH_REPO}/git/matching-refs/heads/maint-" \ + --jq '.[].ref | ltrimstr("refs/heads/maint-")') + major_versions=$( + gh api --paginate "repos/${GH_REPO}/milestones?per_page=100" \ + --jq '.[] | select(.title | test("^[0-9]+\\.0\\.0$")) | "\(.title):\(.number)"' | + sort -V) + for major_version in ${major_versions}; do + if ! grep -qxF "${major_version%:*}" <<< "${maintenance_versions}"; then + milestone=${major_version#*:} + break + fi + done + fi + if [ -n "${milestone}" ]; then + gh api -X PATCH "${issue_path}" -F "milestone=${milestone}" > /dev/null + fi + + # Close the issue and comment which pull request resolved it + # after that. The merge script may have done them already. + if [ "$(jq -r .state <<< "${issue}")" != "closed" ]; then + gh issue close "${issue_number}" + fi + comment="Issue resolved by pull request $(jq -r .number <<< "${pull_request}")" + comments=$(gh api --paginate "${issue_path}/comments" --jq '.[].body') + if ! grep -qxF "${comment}" <<< "${comments}"; then + gh issue comment "${issue_number}" \ + --body "${comment}"$'\n'"$(jq -r .html_url <<< "${pull_request}")" + fi diff --git a/dev/README.md b/dev/README.md index 275e1ae5c92b..6e891b39bad7 100644 --- a/dev/README.md +++ b/dev/README.md @@ -33,8 +33,35 @@ committer. ## How to Merge a Pull Request -Please don't merge PRs using the GitHub Web interface. Instead, run -the following command: +Use the "Squash and merge" button of the GitHub Web interface. Before +you merge, check that: + +* The pull request title is what you want as the commit title: + `GH-XXX: [Component] Title` or `MINOR: [Component] Title`. The + merge is blocked by the "PR Title" status of the Boring Cyborg app + (`.github/boring-cyborg.yml`) unless the title starts with `GH-XXX` + or `MINOR: `. +* The pull request description is what you want as the commit + message. Remove leftovers of the pull request template in the + merge dialog if needed. You must remove CI directives such as + `[skip ci]`: GitHub doesn't run the workflow below for a commit + with them and you need to close the issue manually. + +After the merge, the "Dev PR merged" GitHub Actions workflow assigns +the issue `GH-XXX` to the pull request author if it isn't assigned to +anyone, sets its milestone, closes it and comments which pull request +resolved the issue. The milestone is taken from the pull request. Set +it before merging if the pull request isn't targeted for the next +major release. If the pull request doesn't have a milestone, the +existing issue milestone is retained; if the issue doesn't have a +milestone either, the next major release is used. This is only done +for pull requests to `main`. + +### Merge script + +The merge script is still available for now. It additionally adds +`Authored-by:`, `Co-authored-by:` and `Signed-off-by:` trailers to the +commit message. Run the following command: ```bash dev/merge_arrow_pr.sh diff --git a/docs/source/developers/continuous_integration/overview.rst b/docs/source/developers/continuous_integration/overview.rst index 4ae0e97297c4..ddb23693ba7c 100644 --- a/docs/source/developers/continuous_integration/overview.rst +++ b/docs/source/developers/continuous_integration/overview.rst @@ -53,6 +53,7 @@ The ``.yml`` files in ``.github/workflows`` are workflows which are run on GitHu - ``@github-actions crossbow submit ...`` - runs the specified Crossbow command - ``@github-actions rebase`` - rebases the PR onto the main branch - ``dev.yml`` - runs any time there is activity on a PR, or a PR is merged; it runs the linter and tests that the PR can be merged +- ``dev_pr_merged.yml`` - runs any time a PR is merged to the main branch; assigns the GitHub issue of the PR to the PR author if needed, sets its milestone and closes it PR housekeeping (component labels, PR title validation and the GitHub issue link in the PR description) is handled by the `Boring Cyborg `_ GitHub App, configured in ``.github/boring-cyborg.yml``. diff --git a/docs/source/developers/overview.rst b/docs/source/developers/overview.rst index 3b8775023236..53a40fa6f54a 100644 --- a/docs/source/developers/overview.rst +++ b/docs/source/developers/overview.rst @@ -133,8 +133,7 @@ in the end. To make the review process smooth for everyone, try to When tests are passing and the pull request has been approved by the interested parties, a `committer `_ -will merge the pull request. This is done with a -**command-line utility that does a squash merge**. +will merge the pull request. This is done with a **squash merge**. .. dropdown:: Details on squash merge :animate: fade-in-slide-down @@ -147,9 +146,8 @@ will merge the pull request. This is done with a cherry-pick individual patches onto a maintenance branch. Your pull request will appear in the GitHub interface to have been "merged". - In the commit message of that commit, the merge tool adds the pull request - description, a link back to the pull request, and attribution to the contributor - and any co-authors. + The commit message includes the pull request description, a link to the + pull request, and attribution to the contributor and any co-authors. .. _ai-generated-code: diff --git a/docs/source/developers/release.rst b/docs/source/developers/release.rst index fbce61ae9d17..835e081bd15e 100644 --- a/docs/source/developers/release.rst +++ b/docs/source/developers/release.rst @@ -105,7 +105,7 @@ assigned. archery release curate Ensure a major version milestone for a follow up release is created on GitHub. This will -automatically be used by our merge script as the new version for issues closed when +automatically be used on merging pull requests as the new version for issues closed when the maintenance branch is created. Patch Releases @@ -621,11 +621,30 @@ Be sure to go through on the following checklist: .. code-block:: Bash - # You can run the script with BUMP_TAG=0 and BUMP_PUSH=0 - # this will avoid default pushing to main and pushing the tag - # but you will require to push manually after reviewing the commits. - # dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 - dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z + # BUMP_PUSH=0 BUMP_TAG=0 dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 + BUMP_PUSH=0 BUMP_TAG=0 dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z + + ``BUMP_PUSH=0`` and ``BUMP_TAG=0`` are needed because we can't push + to ``main`` directly: ``main`` requires the "PR Title" status check. + The script only creates the commits in your local ``main``. You need + to push them to a branch, create a pull request from the branch with + a ``MINOR: [Release] Update versions for NEXT_X.NEXT_Y.NEXT_Z-SNAPSHOT`` + title and merge it: + + .. code-block:: Bash + + git push origin main:bump-versions-X.Y.Z + + After the pull request is merged, reset your local ``main``. For a + major release, you also need to tag the merged commit: + + .. code-block:: Bash + + git fetch upstream + git reset --hard upstream/main + # Only for a major release. Use the merged commit of the pull request. + git tag apache-arrow-NEXT_X.NEXT_Y.NEXT_Z.dev + git push upstream apache-arrow-NEXT_X.NEXT_Y.NEXT_Z.dev .. dropdown:: Update docs :animate: fade-in-slide-down From ffd59426651782b360a309991685d79db9f08dd4 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 18 Nov 2026 10:12:13 +0100 Subject: [PATCH 2/9] Reject WIP titles and don't push version bumps by default The "PR Title" check no longer accepts "WIP: GH-XXX" titles. They passed the required check but the "Dev PR merged" workflow ignored them, so the issue stayed open after the merge. dev/release/post-10-bump-versions.sh no longer pushes to main or creates the dev tag by default because the push is rejected by the required check. --- .github/boring-cyborg.yml | 5 ++++- dev/release/post-10-bump-versions.sh | 9 +++++++-- docs/source/developers/release.rst | 17 +++++++++-------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml index 8789531ae077..b19811992259 100644 --- a/.github/boring-cyborg.yml +++ b/.github/boring-cyborg.yml @@ -59,7 +59,10 @@ labelPRBasedOnFilePath: - "**/*.Rd" verifyTitles: - titleRegexp: '^(WIP:?\s*)?GH-[0-9]+|^MINOR: ' + # "PR Title" is a required status check of main in .asf.yaml. A + # "WIP: GH-XXX: ..." title must not pass: it blocks the merge until + # "WIP: " is removed. + titleRegexp: '^GH-[0-9]+|^MINOR: ' alwaysUsePrTitle: true validateEitherPrOrSingleCommitTitle: false statusTitle: "PR Title" diff --git a/dev/release/post-10-bump-versions.sh b/dev/release/post-10-bump-versions.sh index 958a536f243b..cd4c39fa2c6b 100755 --- a/dev/release/post-10-bump-versions.sh +++ b/dev/release/post-10-bump-versions.sh @@ -33,8 +33,13 @@ fi : ${BUMP_VERSION_POST_TAG:=${BUMP_DEFAULT}} : ${BUMP_DEB_PACKAGE_NAMES:=${BUMP_DEFAULT}} : ${BUMP_LINUX_PACKAGES:=${BUMP_DEFAULT}} -: ${BUMP_PUSH:=${BUMP_DEFAULT}} -: ${BUMP_TAG:=${BUMP_DEFAULT}} +# These are disabled by default because we can't push to the default +# branch directly: it requires the "PR Title" status check. Create a +# pull request from the commits and tag the merged commit instead. +# See also the "Bump versions" step in +# docs/source/developers/release.rst. +: ${BUMP_PUSH:=0} +: ${BUMP_TAG:=0} . $SOURCE_DIR/utils-prepare.sh diff --git a/docs/source/developers/release.rst b/docs/source/developers/release.rst index 835e081bd15e..f3332155bc88 100644 --- a/docs/source/developers/release.rst +++ b/docs/source/developers/release.rst @@ -621,14 +621,15 @@ Be sure to go through on the following checklist: .. code-block:: Bash - # BUMP_PUSH=0 BUMP_TAG=0 dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 - BUMP_PUSH=0 BUMP_TAG=0 dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z - - ``BUMP_PUSH=0`` and ``BUMP_TAG=0`` are needed because we can't push - to ``main`` directly: ``main`` requires the "PR Title" status check. - The script only creates the commits in your local ``main``. You need - to push them to a branch, create a pull request from the branch with - a ``MINOR: [Release] Update versions for NEXT_X.NEXT_Y.NEXT_Z-SNAPSHOT`` + # dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 + dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z + + The script only creates the commits in your local ``main``. It + doesn't push them and doesn't create a tag because we can't push to + ``main`` directly: ``main`` requires the "PR Title" status check. You + need to push the commits to a branch, create a pull request from the + branch with a + ``MINOR: [Release] Update versions for NEXT_X.NEXT_Y.NEXT_Z-SNAPSHOT`` title and merge it: .. code-block:: Bash From fab625796d4d6b9aecb301ae1a74ce1fb7b9177d Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 18 Nov 2026 11:45:51 +0100 Subject: [PATCH 3/9] Don't require the title check and read the issue from the commit Address review comments: * The "PR Title" status isn't a required status check of main. The Boring Cyborg app may be down when we need to merge. * Direct pushes to main work again, so the changes of dev/release/post-10-bump-versions.sh and the "Bump versions" step of the release guide are reverted. * The "Dev PR merged" workflow reads the issue and the pull request from the title of the pushed commit, "GH-XXX: ... (#YYY)", instead of asking GitHub for the pull request of the commit. The milestone of the pull request isn't used anymore. * dev/release/post-04-website.sh asks GitHub who merged the pull requests for "Patch Committers". Commits merged with the merge button don't have "Signed-off-by:" trailers. --- .asf.yaml | 11 +----- .github/boring-cyborg.yml | 3 -- .github/workflows/dev_pr_merged.yml | 58 ++++++++++++---------------- dev/README.md | 25 ++++++------ dev/release/post-04-website.sh | 31 +++++++++++++-- dev/release/post-10-bump-versions.sh | 9 +---- docs/source/developers/release.rst | 26 ++----------- 7 files changed, 70 insertions(+), 93 deletions(-) diff --git a/.asf.yaml b/.asf.yaml index 4893aa313b60..e4652b3f86ec 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -29,16 +29,7 @@ github: protected_branches: # protect main against force push - main: - required_status_checks: - # Don't require branches to be up to date before merging. - strict: false - # The title check ("verifyTitles") of the Boring Cyborg app - # in .github/boring-cyborg.yml. The merge button is disabled - # while the pull request title doesn't start with "GH-XXX" - # or "MINOR: ". - contexts: - - PR Title + main: {} collaborators: - alinaliBQ diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml index b19811992259..b9097d96115b 100644 --- a/.github/boring-cyborg.yml +++ b/.github/boring-cyborg.yml @@ -59,9 +59,6 @@ labelPRBasedOnFilePath: - "**/*.Rd" verifyTitles: - # "PR Title" is a required status check of main in .asf.yaml. A - # "WIP: GH-XXX: ..." title must not pass: it blocks the merge until - # "WIP: " is removed. titleRegexp: '^GH-[0-9]+|^MINOR: ' alwaysUsePrTitle: true validateEitherPrOrSingleCommitTitle: false diff --git a/.github/workflows/dev_pr_merged.yml b/.github/workflows/dev_pr_merged.yml index f5bdcbd336ea..86de58101b6e 100644 --- a/.github/workflows/dev_pr_merged.yml +++ b/.github/workflows/dev_pr_merged.yml @@ -24,7 +24,6 @@ on: permissions: contents: read - pull-requests: read issues: write jobs: @@ -33,29 +32,25 @@ jobs: if: github.repository == 'apache/arrow' runs-on: ubuntu-latest steps: - # A pushed commit that isn't the merge commit of a pull request - # is ignored. + # A pushed commit that isn't the merge commit of a + # "GH-XXX: ... (#YYY)" pull request is ignored. - name: Resolve issue env: - COMMIT: ${{ github.sha }} + AUTHOR: ${{ github.event.head_commit.author.username }} GH_REPO: ${{ github.repository }} GH_TOKEN: ${{ github.token }} + MESSAGE: ${{ github.event.head_commit.message }} run: | set -euo pipefail - pull_request=$( - gh api "repos/${GH_REPO}/commits/${COMMIT}/pulls" \ - --jq "map(select(.merge_commit_sha == \"${COMMIT}\"))[0] // empty") - if [ -z "${pull_request}" ]; then - echo "${COMMIT} isn't the merge commit of a pull request." - exit 0 - fi - title=$(jq -r .title <<< "${pull_request}") - if [[ ! "${title}" =~ ^GH-([0-9]+) ]]; then - echo "No GitHub issue in the title: ${title}" + title=${MESSAGE%%$'\n'*} + title=${title%$'\r'} + if [[ ! "${title}" =~ ^GH-([0-9]+).*\ \(#([0-9]+)\)$ ]]; then + echo "Not the merge commit of a GH-XXX pull request: ${title}" exit 0 fi issue_number=${BASH_REMATCH[1]} + pull_request_number=${BASH_REMATCH[2]} issue_path="repos/${GH_REPO}/issues/${issue_number}" issue=$(gh api "${issue_path}") if [ "$(jq 'has("pull_request")' <<< "${issue}")" = "true" ]; then @@ -63,22 +58,19 @@ jobs: exit 0 fi - # Assign the issue to the pull request author if it isn't - # assigned to anyone. GitHub ignores this silently if the - # author can't be assigned. - if [ "$(jq '.assignees | length' <<< "${issue}")" -eq 0 ]; then - author=$(jq -r .user.login <<< "${pull_request}") - gh api "${issue_path}/assignees" -f "assignees[]=${author}" > /dev/null + # Assign the issue to the commit author, who is the pull + # request author for a squash merge, if it isn't assigned to + # anyone. GitHub ignores this silently if the author can't be + # assigned. + if [ -n "${AUTHOR}" ] && \ + [ "$(jq '.assignees | length' <<< "${issue}")" -eq 0 ]; then + gh api "${issue_path}/assignees" -f "assignees[]=${AUTHOR}" > /dev/null fi - # Use the milestone of the pull request. If the pull request - # doesn't have a milestone, keep the milestone of the issue. - # If the issue doesn't have a milestone either, use the next - # major release that doesn't have a maintenance branch yet - # like dev/merge_arrow_pr.py does. - milestone=$(jq -r '.milestone.number // empty' <<< "${pull_request}") - if [ -z "${milestone}" ] && \ - [ "$(jq '.milestone' <<< "${issue}")" = "null" ]; then + # Keep the milestone of the issue. If the issue doesn't have + # a milestone, use the next major release that doesn't have a + # maintenance branch yet like dev/merge_arrow_pr.py does. + if [ "$(jq '.milestone' <<< "${issue}")" = "null" ]; then maintenance_versions=$( gh api --paginate "repos/${GH_REPO}/git/matching-refs/heads/maint-" \ --jq '.[].ref | ltrimstr("refs/heads/maint-")') @@ -88,23 +80,21 @@ jobs: sort -V) for major_version in ${major_versions}; do if ! grep -qxF "${major_version%:*}" <<< "${maintenance_versions}"; then - milestone=${major_version#*:} + gh api -X PATCH "${issue_path}" \ + -F "milestone=${major_version#*:}" > /dev/null break fi done fi - if [ -n "${milestone}" ]; then - gh api -X PATCH "${issue_path}" -F "milestone=${milestone}" > /dev/null - fi # Close the issue and comment which pull request resolved it # after that. The merge script may have done them already. if [ "$(jq -r .state <<< "${issue}")" != "closed" ]; then gh issue close "${issue_number}" fi - comment="Issue resolved by pull request $(jq -r .number <<< "${pull_request}")" + comment="Issue resolved by pull request ${pull_request_number}" comments=$(gh api --paginate "${issue_path}/comments" --jq '.[].body') if ! grep -qxF "${comment}" <<< "${comments}"; then gh issue comment "${issue_number}" \ - --body "${comment}"$'\n'"$(jq -r .html_url <<< "${pull_request}")" + --body "${comment}"$'\n'"${GITHUB_SERVER_URL}/${GH_REPO}/pull/${pull_request_number}" fi diff --git a/dev/README.md b/dev/README.md index 6e891b39bad7..fcbabe97e3c6 100644 --- a/dev/README.md +++ b/dev/README.md @@ -38,24 +38,25 @@ you merge, check that: * The pull request title is what you want as the commit title: `GH-XXX: [Component] Title` or `MINOR: [Component] Title`. The - merge is blocked by the "PR Title" status of the Boring Cyborg app - (`.github/boring-cyborg.yml`) unless the title starts with `GH-XXX` - or `MINOR: `. + "PR Title" status of the Boring Cyborg app + (`.github/boring-cyborg.yml`) fails unless the title starts with + `GH-XXX` or `MINOR: ` but it doesn't block the merge. Keep the + ` (#YYY)` suffix that GitHub adds to the commit title in the merge + dialog: the workflow below needs it. * The pull request description is what you want as the commit message. Remove leftovers of the pull request template in the merge dialog if needed. You must remove CI directives such as `[skip ci]`: GitHub doesn't run the workflow below for a commit with them and you need to close the issue manually. -After the merge, the "Dev PR merged" GitHub Actions workflow assigns -the issue `GH-XXX` to the pull request author if it isn't assigned to -anyone, sets its milestone, closes it and comments which pull request -resolved the issue. The milestone is taken from the pull request. Set -it before merging if the pull request isn't targeted for the next -major release. If the pull request doesn't have a milestone, the -existing issue milestone is retained; if the issue doesn't have a -milestone either, the next major release is used. This is only done -for pull requests to `main`. +After the merge, the "Dev PR merged" GitHub Actions workflow reads +`GH-XXX` and `(#YYY)` from the commit title. It assigns the issue to +the pull request author if it isn't assigned to anyone, sets its +milestone, closes it and comments which pull request resolved the +issue. The existing issue milestone is retained: set it before merging +if the pull request isn't targeted for the next major release. If the +issue doesn't have a milestone, the next major release is used. This +is only done for pull requests to `main`. ### Merge script diff --git a/dev/release/post-04-website.sh b/dev/release/post-04-website.sh index 41a7ee4a04cf..defab0d23e11 100755 --- a/dev/release/post-04-website.sh +++ b/dev/release/post-04-website.sh @@ -75,10 +75,34 @@ rough_n_development_months=$(( git_tag=apache-arrow-${version} git_range=apache-arrow-${previous_version}..${git_tag} -committers_command_line="git shortlog -sn --group=trailer:signed-off-by ${git_range}" contributors_command_line="git shortlog -sn ${git_range}" -committers=$(${committers_command_line}) +# Count the pull requests of the commits in ${git_range} by who merged +# them. We ask GitHub because commits merged with the merge button +# don't have "Signed-off-by:" trailers. +list_committers() { + git log --pretty=%s ${git_range} | + sed -n -E 's/^.* \(#([0-9]+)\)$/\1/p' | + xargs -n 50 | + while read -r -a numbers; do + local query="query {repository(owner: \"apache\", name: \"arrow\") {" + local number + for number in "${numbers[@]}"; do + query+=" pr${number}: pullRequest(number: ${number})" + query+=" {mergedBy {login ... on User {name}}}" + done + query+="}}" + gh api graphql -f query="${query}" \ + --jq '.data.repository[].mergedBy | select(. != null) | + if (.name // "") == "" then .login else .name end' + done | + sort | + uniq -c | + sort -k1,1nr -k2 | + awk '{count = $1; sub(/^ *[0-9]+ /, ""); printf "%6d\t%s\n", count, $0}' +} + +committers=$(set -o pipefail; list_committers) contributors=$(${contributors_command_line}) n_commits=$(git log --pretty=oneline ${git_range} | wc -l) @@ -151,8 +175,7 @@ cat <> "${announce_file}" The following Apache committers merged contributed patches to the repository. -\`\`\`console -$ ${committers_command_line} +\`\`\`text ANNOUNCE echo "${committers}" >> "${announce_file}" diff --git a/dev/release/post-10-bump-versions.sh b/dev/release/post-10-bump-versions.sh index cd4c39fa2c6b..958a536f243b 100755 --- a/dev/release/post-10-bump-versions.sh +++ b/dev/release/post-10-bump-versions.sh @@ -33,13 +33,8 @@ fi : ${BUMP_VERSION_POST_TAG:=${BUMP_DEFAULT}} : ${BUMP_DEB_PACKAGE_NAMES:=${BUMP_DEFAULT}} : ${BUMP_LINUX_PACKAGES:=${BUMP_DEFAULT}} -# These are disabled by default because we can't push to the default -# branch directly: it requires the "PR Title" status check. Create a -# pull request from the commits and tag the merged commit instead. -# See also the "Bump versions" step in -# docs/source/developers/release.rst. -: ${BUMP_PUSH:=0} -: ${BUMP_TAG:=0} +: ${BUMP_PUSH:=${BUMP_DEFAULT}} +: ${BUMP_TAG:=${BUMP_DEFAULT}} . $SOURCE_DIR/utils-prepare.sh diff --git a/docs/source/developers/release.rst b/docs/source/developers/release.rst index f3332155bc88..da44d3e0f0c8 100644 --- a/docs/source/developers/release.rst +++ b/docs/source/developers/release.rst @@ -621,32 +621,12 @@ Be sure to go through on the following checklist: .. code-block:: Bash + # You can run the script with BUMP_TAG=0 and BUMP_PUSH=0 + # this will avoid default pushing to main and pushing the tag + # but you will require to push manually after reviewing the commits. # dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z - The script only creates the commits in your local ``main``. It - doesn't push them and doesn't create a tag because we can't push to - ``main`` directly: ``main`` requires the "PR Title" status check. You - need to push the commits to a branch, create a pull request from the - branch with a - ``MINOR: [Release] Update versions for NEXT_X.NEXT_Y.NEXT_Z-SNAPSHOT`` - title and merge it: - - .. code-block:: Bash - - git push origin main:bump-versions-X.Y.Z - - After the pull request is merged, reset your local ``main``. For a - major release, you also need to tag the merged commit: - - .. code-block:: Bash - - git fetch upstream - git reset --hard upstream/main - # Only for a major release. Use the merged commit of the pull request. - git tag apache-arrow-NEXT_X.NEXT_Y.NEXT_Z.dev - git push upstream apache-arrow-NEXT_X.NEXT_Y.NEXT_Z.dev - .. dropdown:: Update docs :animate: fade-in-slide-down :class-title: sd-fs-5 From 6609282bf45b218df647db50d702e4822696fa57 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 18 Nov 2026 12:38:06 +0100 Subject: [PATCH 4/9] Stop the release announcement on a failed "Patch Committers" request dev/release/post-04-website.sh published a partial count if one of the GitHub requests failed. Also document that the script needs an authenticated gh. --- dev/release/post-04-website.sh | 6 ++++-- docs/source/developers/release.rst | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/release/post-04-website.sh b/dev/release/post-04-website.sh index defab0d23e11..1a28126425cd 100755 --- a/dev/release/post-04-website.sh +++ b/dev/release/post-04-website.sh @@ -79,7 +79,8 @@ contributors_command_line="git shortlog -sn ${git_range}" # Count the pull requests of the commits in ${git_range} by who merged # them. We ask GitHub because commits merged with the merge button -# don't have "Signed-off-by:" trailers. +# don't have "Signed-off-by:" trailers. A failed request stops the +# script: we must not publish a partial count. list_committers() { git log --pretty=%s ${git_range} | sed -n -E 's/^.* \(#([0-9]+)\)$/\1/p' | @@ -94,7 +95,8 @@ list_committers() { query+="}}" gh api graphql -f query="${query}" \ --jq '.data.repository[].mergedBy | select(. != null) | - if (.name // "") == "" then .login else .name end' + if (.name // "") == "" then .login else .name end' || + exit 1 done | sort | uniq -c | diff --git a/docs/source/developers/release.rst b/docs/source/developers/release.rst index da44d3e0f0c8..af821e69c7c9 100644 --- a/docs/source/developers/release.rst +++ b/docs/source/developers/release.rst @@ -400,7 +400,8 @@ Be sure to go through on the following checklist: :class-title: sd-fs-5 :class-container: sd-shadow-md - Add a release note for the new version to our website and update the latest release information: + Add a release note for the new version to our website and update the latest release information. + The script needs an authenticated ``gh`` to ask GitHub who merged the pull requests of the release: .. code-block:: Bash From 5619a5bd0f0e3690c1873cecb911556e3040be3d Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 19 Nov 2026 00:28:22 +0100 Subject: [PATCH 5/9] Let GitHub close the issue Address review comments: rely on GitHub closing the issue from a closing keyword in the pull request description. * The Boring Cyborg app writes "Closes #XXX" to the "GitHub Issue:" line of a pull request to main. It leaves "Refs #XXX" alone: that is for a partial fix, which keeps the issue open. * The "Dev PR merged" workflow doesn't close the issue or comment on it anymore. It only assigns the issue and sets its milestone, and only if GitHub closed the issue. It doesn't need the "(#YYY)" suffix of the commit title anymore. --- .github/boring-cyborg.yml | 6 +++- .github/workflows/dev_pr_merged.yml | 36 ++++++++----------- dev/README.md | 28 ++++++++------- .../continuous_integration/overview.rst | 2 +- docs/source/developers/overview.rst | 6 ++++ 5 files changed, 43 insertions(+), 35 deletions(-) diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml index b9097d96115b..1d0a7b331591 100644 --- a/.github/boring-cyborg.yml +++ b/.github/boring-cyborg.yml @@ -67,8 +67,12 @@ verifyTitles: failureMessage: "Title must start with 'GH-: [Component]' or 'MINOR: [Component]'" insertIssueLinkInPrDescription: - descriptionIssuePlaceholderRegexp: '^\* GitHub Issue: (.*)$' + descriptionIssuePlaceholderRegexp: '^\* GitHub Issue: (?!Refs )(.*)$' matchers: + closedIssue: + targetBranchFilter: '^main$' + titleIssueIdRegexp: '^GH-([0-9]+)' + descriptionIssueLink: 'Closes #${1}' githubIssue: titleIssueIdRegexp: '^(?:WIP:?\s*)?GH-([0-9]+)' descriptionIssueLink: '#${1}' diff --git a/.github/workflows/dev_pr_merged.yml b/.github/workflows/dev_pr_merged.yml index 86de58101b6e..7f3ffbb8d88c 100644 --- a/.github/workflows/dev_pr_merged.yml +++ b/.github/workflows/dev_pr_merged.yml @@ -27,14 +27,16 @@ permissions: issues: write jobs: - resolve: - name: Resolve + update: + name: Update issue if: github.repository == 'apache/arrow' runs-on: ubuntu-latest steps: - # A pushed commit that isn't the merge commit of a - # "GH-XXX: ... (#YYY)" pull request is ignored. - - name: Resolve issue + # GitHub closes the issue of a "GH-XXX: ..." pull request on merge + # because of "* GitHub Issue: Closes #XXX" in the pull request + # description. This sets what GitHub doesn't set: the assignee + # and the milestone of the issue. + - name: Update issue env: AUTHOR: ${{ github.event.head_commit.author.username }} GH_REPO: ${{ github.repository }} @@ -44,19 +46,23 @@ jobs: set -euo pipefail title=${MESSAGE%%$'\n'*} - title=${title%$'\r'} - if [[ ! "${title}" =~ ^GH-([0-9]+).*\ \(#([0-9]+)\)$ ]]; then - echo "Not the merge commit of a GH-XXX pull request: ${title}" + if [[ ! "${title}" =~ ^GH-([0-9]+) ]]; then + echo "No GitHub issue in the commit title: ${title}" exit 0 fi issue_number=${BASH_REMATCH[1]} - pull_request_number=${BASH_REMATCH[2]} issue_path="repos/${GH_REPO}/issues/${issue_number}" issue=$(gh api "${issue_path}") if [ "$(jq 'has("pull_request")' <<< "${issue}")" = "true" ]; then echo "#${issue_number} is a pull request, not an issue." exit 0 fi + # The issue is open if the pull request description didn't + # have "Closes #XXX", for example for a partial fix. + if [ "$(jq -r .state <<< "${issue}")" != "closed" ]; then + echo "::notice::#${issue_number} is still open. It isn't updated." + exit 0 + fi # Assign the issue to the commit author, who is the pull # request author for a squash merge, if it isn't assigned to @@ -86,15 +92,3 @@ jobs: fi done fi - - # Close the issue and comment which pull request resolved it - # after that. The merge script may have done them already. - if [ "$(jq -r .state <<< "${issue}")" != "closed" ]; then - gh issue close "${issue_number}" - fi - comment="Issue resolved by pull request ${pull_request_number}" - comments=$(gh api --paginate "${issue_path}/comments" --jq '.[].body') - if ! grep -qxF "${comment}" <<< "${comments}"; then - gh issue comment "${issue_number}" \ - --body "${comment}"$'\n'"${GITHUB_SERVER_URL}/${GH_REPO}/pull/${pull_request_number}" - fi diff --git a/dev/README.md b/dev/README.md index fcbabe97e3c6..2703d8c13eb7 100644 --- a/dev/README.md +++ b/dev/README.md @@ -40,23 +40,27 @@ you merge, check that: `GH-XXX: [Component] Title` or `MINOR: [Component] Title`. The "PR Title" status of the Boring Cyborg app (`.github/boring-cyborg.yml`) fails unless the title starts with - `GH-XXX` or `MINOR: ` but it doesn't block the merge. Keep the - ` (#YYY)` suffix that GitHub adds to the commit title in the merge - dialog: the workflow below needs it. + `GH-XXX` or `MINOR: ` but it doesn't block the merge. +* The last line of the pull request description is + `* GitHub Issue: Closes #XXX`. The Boring Cyborg app writes it for a + pull request to `main` and GitHub closes the issue on merge because + of it. If the pull request fixes only a part of the issue, change + the line to `* GitHub Issue: Refs #XXX` before you merge: the issue + stays open. If the line doesn't say `Closes #XXX`, for example + because the app is down, change it or close the issue yourself. * The pull request description is what you want as the commit message. Remove leftovers of the pull request template in the - merge dialog if needed. You must remove CI directives such as + merge dialog if needed. You should remove CI directives such as `[skip ci]`: GitHub doesn't run the workflow below for a commit - with them and you need to close the issue manually. + with them. After the merge, the "Dev PR merged" GitHub Actions workflow reads -`GH-XXX` and `(#YYY)` from the commit title. It assigns the issue to -the pull request author if it isn't assigned to anyone, sets its -milestone, closes it and comments which pull request resolved the -issue. The existing issue milestone is retained: set it before merging -if the pull request isn't targeted for the next major release. If the -issue doesn't have a milestone, the next major release is used. This -is only done for pull requests to `main`. +`GH-XXX` from the commit title. If GitHub closed the issue, the +workflow assigns it to the pull request author if it isn't assigned to +anyone and sets its milestone. The existing issue milestone is +retained: set it before merging if the pull request isn't targeted for +the next major release. If the issue doesn't have a milestone, the next +major release is used. This is only done for pull requests to `main`. ### Merge script diff --git a/docs/source/developers/continuous_integration/overview.rst b/docs/source/developers/continuous_integration/overview.rst index ddb23693ba7c..43204a994c9c 100644 --- a/docs/source/developers/continuous_integration/overview.rst +++ b/docs/source/developers/continuous_integration/overview.rst @@ -53,7 +53,7 @@ The ``.yml`` files in ``.github/workflows`` are workflows which are run on GitHu - ``@github-actions crossbow submit ...`` - runs the specified Crossbow command - ``@github-actions rebase`` - rebases the PR onto the main branch - ``dev.yml`` - runs any time there is activity on a PR, or a PR is merged; it runs the linter and tests that the PR can be merged -- ``dev_pr_merged.yml`` - runs any time a PR is merged to the main branch; assigns the GitHub issue of the PR to the PR author if needed, sets its milestone and closes it +- ``dev_pr_merged.yml`` - runs any time a PR is merged to the main branch; assigns the GitHub issue that the PR closed to the PR author if needed and sets its milestone PR housekeeping (component labels, PR title validation and the GitHub issue link in the PR description) is handled by the `Boring Cyborg `_ GitHub App, configured in ``.github/boring-cyborg.yml``. diff --git a/docs/source/developers/overview.rst b/docs/source/developers/overview.rst index 53a40fa6f54a..fe5447c31382 100644 --- a/docs/source/developers/overview.rst +++ b/docs/source/developers/overview.rst @@ -135,6 +135,12 @@ When tests are passing and the pull request has been approved by the interested parties, a `committer `_ will merge the pull request. This is done with a **squash merge**. +The ``* GitHub Issue:`` line at the end of the pull request description is +filled in automatically from the pull request title. For a pull request to +``main`` it says ``Closes #XXX`` and GitHub closes the issue when the pull +request is merged. If your pull request fixes only a part of the issue, change +the line to ``* GitHub Issue: Refs #XXX`` so that the issue stays open. + .. dropdown:: Details on squash merge :animate: fade-in-slide-down :class-container: sd-shadow-none From 367a52b628241b71023dc693fb464bd49ea6241c Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 19 Nov 2026 12:29:01 +0100 Subject: [PATCH 6/9] Apply batched suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Raúl Cumplido --- dev/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/README.md b/dev/README.md index 2703d8c13eb7..5f2dd8e57506 100644 --- a/dev/README.md +++ b/dev/README.md @@ -64,7 +64,7 @@ major release is used. This is only done for pull requests to `main`. ### Merge script -The merge script is still available for now. It additionally adds +The merge script is still available for now but using the merge button is encouraged. It additionally adds `Authored-by:`, `Co-authored-by:` and `Signed-off-by:` trailers to the commit message. Run the following command: From 4b57792cffb6a94a230acf2abcfbad8ba2a90679 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 19 Nov 2026 12:47:48 +0100 Subject: [PATCH 7/9] Add a comment about Closes/Refs to the PR template --- .github/pull_request_template.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index dd7509e2605a..313d0a6269fc 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -34,4 +34,10 @@ In accordance to the [AI generation guidelines](https://arrow.apache.org/docs/de - [ ] AI - [ ] Not reviewed + * GitHub Issue: (filled in automatically from the PR title) From fe4116a3011b256a854a12fa0c2863a24ca16f44 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 19 Nov 2026 16:33:52 +0100 Subject: [PATCH 8/9] Count committers with archery release committers --- dev/archery/archery/release/cli.py | 16 ++++- dev/archery/archery/release/core.py | 40 +++++++++++++ .../archery/release/tests/test_release.py | 58 ++++++++++++++++++- dev/archery/setup.py | 2 +- dev/release/post-04-website.sh | 33 ++--------- docs/source/developers/release.rst | 2 +- 6 files changed, 120 insertions(+), 31 deletions(-) diff --git a/dev/archery/archery/release/cli.py b/dev/archery/archery/release/cli.py index 58979406c337..f95141bcc037 100644 --- a/dev/archery/archery/release/cli.py +++ b/dev/archery/archery/release/cli.py @@ -18,9 +18,10 @@ import pathlib import click +from git import Repo from ..utils.cli import validate_arrow_sources -from .core import IssueTracker, Release +from .core import IssueTracker, Release, count_committers @click.group('release') @@ -52,6 +53,19 @@ def release_curate(obj, version, minimal): click.echo(curation.render('console')) +@release.command('committers') +@click.argument('previous_version') +@click.argument('version') +@click.pass_obj +def release_committers(obj, previous_version, version): + """Count the pull requests of a release by who merged them.""" + commit_range = f"apache-arrow-{previous_version}..apache-arrow-{version}" + commits = Repo(obj['repo']).iter_commits(commit_range) + committers = count_committers(commits, obj['issue_tracker'].github_repo) + for name, count in committers: + click.echo(f"{count:6d}\t{name}") + + @release.group('changelog') def release_changelog(): """Release changelog.""" diff --git a/dev/archery/archery/release/core.py b/dev/archery/archery/release/core.py index 3ce2110a5506..e0521d8209da 100644 --- a/dev/archery/archery/release/core.py +++ b/dev/archery/archery/release/core.py @@ -242,6 +242,46 @@ def title(self): return self._title +_PULL_REQUEST_NUMBER_REGEX = re.compile(r" \(#(\d+)\)$") + + +def count_committers(commits, github_repo): + """ + Count the pull requests of the commits by who merged them. + + We ask GitHub because commits merged with the merge button don't + have "Signed-off-by:" trailers. + + Returns (name, count) pairs sorted by count (descending) and name. + """ + # Release commits and direct pushes don't have a pull request number. + matches = (_PULL_REQUEST_NUMBER_REGEX.search(commit.summary) + for commit in commits) + numbers = [int(match.group(1)) for match in matches if match] + + counts = defaultdict(int) + # We use GraphQL because it can return many pull requests per + # request. REST needs a request per pull request. + n_per_request = 50 + for i in range(0, len(numbers), n_per_request): + batch = numbers[i:i + n_per_request] + fields = " ".join( + f"pr{number}: pullRequest(number: {number}) " + "{mergedBy {login ... on User {name}}}" + for number in batch) + query = ('query {repository(owner: "apache", name: "arrow") {' + f'{fields}}}}}') + _, result = github_repo.requester.graphql_query(query, {}) + for number in batch: + merger = result["data"]["repository"][f"pr{number}"]["mergedBy"] + if merger is None: + warnings.warn(f"#{number} doesn't have a merger. It isn't " + "counted.") + continue + counts[merger.get("name") or merger["login"]] += 1 + return sorted(counts.items(), key=lambda item: (-item[1], item[0])) + + class Release: def __new__(self, version, repo=None, github_token=None, diff --git a/dev/archery/archery/release/tests/test_release.py b/dev/archery/archery/release/tests/test_release.py index fae2bdcea04a..f77743b9191b 100644 --- a/dev/archery/archery/release/tests/test_release.py +++ b/dev/archery/archery/release/tests/test_release.py @@ -15,11 +15,13 @@ # specific language governing permissions and limitations # under the License. +from types import SimpleNamespace + import pytest from archery.release.core import ( Release, MajorRelease, MinorRelease, PatchRelease, - IssueTracker, Version, Issue, CommitTitle, Commit + IssueTracker, Version, Issue, CommitTitle, Commit, count_committers ) @@ -355,3 +357,57 @@ def test_maintenance_patch_selection(fake_issue_tracker): '9123dadfd123bca7af4eaa9455f5b0d1ca8b929d', ] assert shas_to_pick == expected + + +def test_count_committers(): + commits = [ + SimpleNamespace(summary=summary) for summary in [ + "GH-1: [C++] Title (#11)", + "GH-2: [Python] Title (#12)", + "MINOR: [Release] Update versions for 2.0.0", + "GH-3: [R] Title (#13)", + "GH-4: [Docs] Title (#14)", + "GH-5: [CI] Mention (#10) in the middle", + "GH-6: [Ruby] Title (#15)", + "GH-7: [Go] Title (#16)", + ] + ] + mergers = { + "pr11": {"login": "zoe", "name": "Zoe Z"}, + "pr12": {"login": "bob", "name": "Bob B"}, + "pr13": {"login": "zoe", "name": "Zoe Z"}, + # a user without a name: the login is used + "pr14": {"login": "alice", "name": None}, + # no merger: not counted + "pr15": None, + # not a user, for example a bot: the login is used + "pr16": {"login": "carol"}, + } + queries = [] + + def graphql_query(query, variables): + queries.append(query) + pull_requests = { + alias: {"mergedBy": merger} for alias, merger in mergers.items() + } + return {}, {"data": {"repository": pull_requests}} + + github_repo = SimpleNamespace( + requester=SimpleNamespace(graphql_query=graphql_query)) + + with pytest.warns(UserWarning, match="#15 doesn't have a merger"): + committers = count_committers(commits, github_repo) + + assert committers == [ + ("Zoe Z", 2), + ("Bob B", 1), + ("alice", 1), + ("carol", 1), + ] + assert queries == [ + 'query {repository(owner: "apache", name: "arrow") {' + + " ".join(f"pr{number}: pullRequest(number: {number}) " + "{mergedBy {login ... on User {name}}}" + for number in range(11, 17)) + + '}}' + ] diff --git a/dev/archery/setup.py b/dev/archery/setup.py index 0b2bbfcb89c6..30c064ad951a 100755 --- a/dev/archery/setup.py +++ b/dev/archery/setup.py @@ -35,7 +35,7 @@ 'integration': ['cffi', 'numpy'], 'integration-java': ['jpype1'], 'numpydoc': ['numpydoc==1.1.0'], - 'release': ['pygithub<2.9.0', jinja_req, 'semver', 'gitpython'], + 'release': ['pygithub>=2.5.0,<2.9.0', jinja_req, 'semver', 'gitpython'], } extras['bot'] = extras['crossbow'] + ['pygithub<2.9.0'] extras['all'] = list(set(functools.reduce(operator.add, extras.values()))) diff --git a/dev/release/post-04-website.sh b/dev/release/post-04-website.sh index 1a28126425cd..df755ef608c0 100755 --- a/dev/release/post-04-website.sh +++ b/dev/release/post-04-website.sh @@ -35,6 +35,10 @@ if ! archery --help > /dev/null 2>&1; then exit 1 fi +# Without a token archery waits on the rate limit of GitHub for a long +# time instead of failing. +: "${GH_TOKEN:?GH_TOKEN is required to ask GitHub who merged the pull requests}" + previous_version=$1 version=$2 @@ -78,33 +82,8 @@ git_range=apache-arrow-${previous_version}..${git_tag} contributors_command_line="git shortlog -sn ${git_range}" # Count the pull requests of the commits in ${git_range} by who merged -# them. We ask GitHub because commits merged with the merge button -# don't have "Signed-off-by:" trailers. A failed request stops the -# script: we must not publish a partial count. -list_committers() { - git log --pretty=%s ${git_range} | - sed -n -E 's/^.* \(#([0-9]+)\)$/\1/p' | - xargs -n 50 | - while read -r -a numbers; do - local query="query {repository(owner: \"apache\", name: \"arrow\") {" - local number - for number in "${numbers[@]}"; do - query+=" pr${number}: pullRequest(number: ${number})" - query+=" {mergedBy {login ... on User {name}}}" - done - query+="}}" - gh api graphql -f query="${query}" \ - --jq '.data.repository[].mergedBy | select(. != null) | - if (.name // "") == "" then .login else .name end' || - exit 1 - done | - sort | - uniq -c | - sort -k1,1nr -k2 | - awk '{count = $1; sub(/^ *[0-9]+ /, ""); printf "%6d\t%s\n", count, $0}' -} - -committers=$(set -o pipefail; list_committers) +# them. This asks GitHub: it needs GH_TOKEN. +committers=$(archery release committers ${previous_version} ${version}) contributors=$(${contributors_command_line}) n_commits=$(git log --pretty=oneline ${git_range} | wc -l) diff --git a/docs/source/developers/release.rst b/docs/source/developers/release.rst index af821e69c7c9..537beffb91e5 100644 --- a/docs/source/developers/release.rst +++ b/docs/source/developers/release.rst @@ -401,7 +401,7 @@ Be sure to go through on the following checklist: :class-container: sd-shadow-md Add a release note for the new version to our website and update the latest release information. - The script needs an authenticated ``gh`` to ask GitHub who merged the pull requests of the release: + The script needs a GitHub token in ``GH_TOKEN`` to ask GitHub who merged the pull requests of the release: .. code-block:: Bash From 20eb0e7e7c46d9fd63d99f2592b43c66713bfab0 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 19 Nov 2026 18:22:56 +0100 Subject: [PATCH 9/9] Split the update of the issue into steps --- .github/workflows/dev_pr_merged.yml | 86 +++++++++++++++++------------ 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/.github/workflows/dev_pr_merged.yml b/.github/workflows/dev_pr_merged.yml index 7f3ffbb8d88c..8d388816b693 100644 --- a/.github/workflows/dev_pr_merged.yml +++ b/.github/workflows/dev_pr_merged.yml @@ -31,16 +31,17 @@ jobs: name: Update issue if: github.repository == 'apache/arrow' runs-on: ubuntu-latest + env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ github.token }} steps: # GitHub closes the issue of a "GH-XXX: ..." pull request on merge # because of "* GitHub Issue: Closes #XXX" in the pull request - # description. This sets what GitHub doesn't set: the assignee - # and the milestone of the issue. - - name: Update issue + # description. The following steps set what GitHub doesn't set: + # the assignee and the milestone of the issue. + - name: Get issue + id: issue env: - AUTHOR: ${{ github.event.head_commit.author.username }} - GH_REPO: ${{ github.repository }} - GH_TOKEN: ${{ github.token }} MESSAGE: ${{ github.event.head_commit.message }} run: | set -euo pipefail @@ -51,8 +52,7 @@ jobs: exit 0 fi issue_number=${BASH_REMATCH[1]} - issue_path="repos/${GH_REPO}/issues/${issue_number}" - issue=$(gh api "${issue_path}") + issue=$(gh api "repos/${GH_REPO}/issues/${issue_number}") if [ "$(jq 'has("pull_request")' <<< "${issue}")" = "true" ]; then echo "#${issue_number} is a pull request, not an issue." exit 0 @@ -64,31 +64,47 @@ jobs: exit 0 fi - # Assign the issue to the commit author, who is the pull - # request author for a squash merge, if it isn't assigned to - # anyone. GitHub ignores this silently if the author can't be - # assigned. - if [ -n "${AUTHOR}" ] && \ - [ "$(jq '.assignees | length' <<< "${issue}")" -eq 0 ]; then - gh api "${issue_path}/assignees" -f "assignees[]=${AUTHOR}" > /dev/null - fi + # The following steps don't run without these outputs. + { + echo "number=${issue_number}" + echo "n_assignees=$(jq '.assignees | length' <<< "${issue}")" + echo "has_milestone=$(jq '.milestone != null' <<< "${issue}")" + } | tee -a "${GITHUB_OUTPUT}" + # Assign the issue to the commit author, who is the pull request + # author for a squash merge, if it isn't assigned to anyone. + # GitHub ignores this silently if the author can't be assigned. + - name: Assign issue + if: >- + steps.issue.outputs.n_assignees == '0' && + github.event.head_commit.author.username + env: + AUTHOR: ${{ github.event.head_commit.author.username }} + ISSUE_NUMBER: ${{ steps.issue.outputs.number }} + run: | + gh api "repos/${GH_REPO}/issues/${ISSUE_NUMBER}/assignees" \ + -f "assignees[]=${AUTHOR}" > /dev/null + # Keep the milestone of the issue. If the issue doesn't have a + # milestone, use the next major release that doesn't have a + # maintenance branch yet like dev/merge_arrow_pr.py does. + - name: Set milestone + if: steps.issue.outputs.has_milestone == 'false' + env: + ISSUE_NUMBER: ${{ steps.issue.outputs.number }} + run: | + set -euo pipefail - # Keep the milestone of the issue. If the issue doesn't have - # a milestone, use the next major release that doesn't have a - # maintenance branch yet like dev/merge_arrow_pr.py does. - if [ "$(jq '.milestone' <<< "${issue}")" = "null" ]; then - maintenance_versions=$( - gh api --paginate "repos/${GH_REPO}/git/matching-refs/heads/maint-" \ - --jq '.[].ref | ltrimstr("refs/heads/maint-")') - major_versions=$( - gh api --paginate "repos/${GH_REPO}/milestones?per_page=100" \ - --jq '.[] | select(.title | test("^[0-9]+\\.0\\.0$")) | "\(.title):\(.number)"' | - sort -V) - for major_version in ${major_versions}; do - if ! grep -qxF "${major_version%:*}" <<< "${maintenance_versions}"; then - gh api -X PATCH "${issue_path}" \ - -F "milestone=${major_version#*:}" > /dev/null - break - fi - done - fi + maintenance_versions=$( + gh api --paginate "repos/${GH_REPO}/git/matching-refs/heads/maint-" \ + --jq '.[].ref | ltrimstr("refs/heads/maint-")') + major_versions=$( + gh api --paginate "repos/${GH_REPO}/milestones?per_page=100" \ + --jq '.[] | select(.title | test("^[0-9]+\\.0\\.0$")) | "\(.title):\(.number)"' | + sort -V) + for major_version in ${major_versions}; do + if ! grep -qxF "${major_version%:*}" <<< "${maintenance_versions}"; then + echo "Milestone: ${major_version%:*}" + gh api -X PATCH "repos/${GH_REPO}/issues/${ISSUE_NUMBER}" \ + -F "milestone=${major_version#*:}" > /dev/null + break + fi + done