Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/boring-cyborg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ labelPRBasedOnFilePath:
- "**/*.Rd"

verifyTitles:
titleRegexp: '^(WIP:?\s*)?GH-[0-9]+|^MINOR: '
titleRegexp: '^GH-[0-9]+|^MINOR: '
alwaysUsePrTitle: true
validateEitherPrOrSingleCommitTitle: false
statusTitle: "PR Title"
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/dev_pr_merged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# 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
Comment thread
rok marked this conversation as resolved.
Resolved

permissions:
contents: 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
# "GH-XXX: ... (#YYY)" pull request is ignored.
- name: Resolve 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

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
echo "#${issue_number} is a pull request, not an issue."
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

# 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

# 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
32 changes: 30 additions & 2 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,36 @@ 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
"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 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

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
Expand Down
31 changes: 27 additions & 4 deletions dev/release/post-04-website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -151,8 +175,7 @@ cat <<ANNOUNCE >> "${announce_file}"

The following Apache committers merged contributed patches to the repository.

\`\`\`console
$ ${committers_command_line}
\`\`\`text
ANNOUNCE

echo "${committers}" >> "${announce_file}"
Expand Down
1 change: 1 addition & 0 deletions docs/source/developers/continuous_integration/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/kaxil/boring-cyborg>`_ GitHub App, configured in ``.github/boring-cyborg.yml``.

Expand Down
8 changes: 3 additions & 5 deletions docs/source/developers/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://arrow.apache.org/committers/>`_
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
Expand All @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/developers/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ assigned.
archery release curate <version>

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
Expand Down
Loading