From 40bd92d9caf3dde810a48e6a4526452a777549df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 10 Nov 2026 12:12:06 +0100 Subject: [PATCH 1/3] GH-55392: [Dev] Add boring-cyborg app configuration and remove dev_pr.yml workflow --- .github/boring-cyborg.yml | 77 +++++++++++++ .github/pull_request_template.md | 2 + .github/workflows/dev_pr.yml | 107 ------------------ .github/workflows/dev_pr/helpers.js | 66 ----------- .github/workflows/dev_pr/issue_check.js | 84 -------------- .github/workflows/dev_pr/labeler.yml | 75 ------------ .github/workflows/dev_pr/link.js | 83 -------------- .github/workflows/dev_pr/title_check.js | 78 ------------- .github/workflows/dev_pr/title_check.md | 41 ------- .../continuous_integration/overview.rst | 3 +- 10 files changed, 81 insertions(+), 535 deletions(-) create mode 100644 .github/boring-cyborg.yml delete mode 100644 .github/workflows/dev_pr.yml delete mode 100644 .github/workflows/dev_pr/helpers.js delete mode 100644 .github/workflows/dev_pr/issue_check.js delete mode 100644 .github/workflows/dev_pr/labeler.yml delete mode 100644 .github/workflows/dev_pr/link.js delete mode 100644 .github/workflows/dev_pr/title_check.js delete mode 100644 .github/workflows/dev_pr/title_check.md diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml new file mode 100644 index 000000000000..8789531ae077 --- /dev/null +++ b/.github/boring-cyborg.yml @@ -0,0 +1,77 @@ +# 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. + +labelPRBasedOnFilePath: + "Component: C++": + - "cpp/**/*" + + "Component: GLib": + - "c_glib/**/*" + + "Component: MATLAB": + - "matlab/**/*" + + "Component: Python": + - "python/**/*" + + "Component: R": + - "r/**/*" + + "Component: Ruby": + - "ruby/**/*" + + "Component: FlightRPC": + - "cpp/src/arrow/flight/**/*" + - "r/R/flight.*" + - "python/pyarrow/*flight.*" + + "Component: Gandiva": + - "c_glib/gandiva-glib/**/*" + - "cpp/src/gandiva/**/*" + - "python/pyarrow/gandiva.*" + - "ruby/red-gandiva/**/*" + + "Component: Parquet": + - "c_glib/parquet-glib/**/*" + - "cpp/src/parquet/**/*" + - "r/R/parquet.*" + - "ruby/red-parquet/**/*" + + "Component: Documentation": + - "docs/**/*" + - "**/*.md" + - "**/*.rst" + - "**/*.Rmd" + - "**/*.Rd" + +verifyTitles: + titleRegexp: '^(WIP:?\s*)?GH-[0-9]+|^MINOR: ' + alwaysUsePrTitle: true + validateEitherPrOrSingleCommitTitle: false + statusTitle: "PR Title" + successMessage: "PR title format is valid" + failureMessage: "Title must start with 'GH-: [Component]' or 'MINOR: [Component]'" + +insertIssueLinkInPrDescription: + descriptionIssuePlaceholderRegexp: '^\* GitHub Issue: (.*)$' + matchers: + githubIssue: + titleIssueIdRegexp: '^(?:WIP:?\s*)?GH-([0-9]+)' + descriptionIssueLink: '#${1}' + minor: + titleIssueIdRegexp: '^(MINOR): ' + descriptionIssueLink: 'N/A (MINOR)' diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 0187ca2dc907..dd7509e2605a 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -33,3 +33,5 @@ In accordance to the [AI generation guidelines](https://arrow.apache.org/docs/de - [ ] Human - [ ] AI - [ ] Not reviewed + +* GitHub Issue: (filled in automatically from the PR title) diff --git a/.github/workflows/dev_pr.yml b/.github/workflows/dev_pr.yml deleted file mode 100644 index 83a98540ed1f..000000000000 --- a/.github/workflows/dev_pr.yml +++ /dev/null @@ -1,107 +0,0 @@ -# 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 - -on: - # TODO: Enable this when eps1lon/actions-label-merge-conflict is available. - # push: - # branches: - # - master - # - main - pull_request_target: - types: - - opened - - edited - - synchronize - -concurrency: - group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event.number }} - cancel-in-progress: true - -permissions: - # Required for the GraphQL convertPullRequestToDraft mutation. - contents: write - pull-requests: write - issues: write - -jobs: - process: - name: Process - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - with: - repository: apache/arrow - ref: main - persist-credentials: false - - - name: Add Issue link - if: | - (github.event.action == 'opened' || - github.event.action == 'edited') - uses: actions/github-script@v9 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/dev_pr/link.js`); - script({github, context}); - - - name: Check title - if: | - (github.event.action == 'opened' || - github.event.action == 'edited') - uses: actions/github-script@v9 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/dev_pr/title_check.js`); - script({github, context}); - - - name: Check Issue - if: | - (github.event.action == 'opened' || - github.event.action == 'edited') - uses: actions/github-script@v9 - with: - debug: true - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/dev_pr/issue_check.js`); - script({github, context}); - - - name: Assign GitHub labels - if: | - (github.event.action == 'opened' || - github.event.action == 'synchronize') - uses: actions/labeler@v7 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - configuration-path: .github/workflows/dev_pr/labeler.yml - sync-labels: true - - # TODO: Enable this when eps1lon/actions-label-merge-conflict is available. - # - name: Checks if PR needs rebase - # if: | - # github.event_name == 'push' || - # (github.event_name == 'pull_request_target' && - # (github.event.action == 'opened' || - # github.event.action == 'synchronize')) - # uses: eps1lon/actions-label-merge-conflict@releases/2.x - # with: - # dirtyLabel: "needs-rebase" - # repoToken: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/dev_pr/helpers.js b/.github/workflows/dev_pr/helpers.js deleted file mode 100644 index 222d2213771c..000000000000 --- a/.github/workflows/dev_pr/helpers.js +++ /dev/null @@ -1,66 +0,0 @@ -// 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. - -const https = require('https'); - -/** - * Given the title of a PullRequest return the Issue - * - * @param {String} title - * @returns {Issue} or null if no issue detected. - * - * @typedef {Object} Issue - * @property {string} kind - The kind of issue: minor or github - * @property {string} id - The numeric issue id of the issue - */ -function detectIssue(title) { - if (!title) { - return null; - } - if (title.startsWith("MINOR: ")) { - return {"kind": "minor"}; - } - const matched_gh = /^(WIP:?\s*)?GH-(\d+)/.exec(title); - if (matched_gh) { - return {"kind": "github", "id": matched_gh[2]}; - } - return null; -} - -/** - * Retrieves information about a GitHub issue. - * @param {String} issueID - * @returns {Object} the information about a GitHub issue. - */ - async function getGitHubInfo(github, context, issueID, pullRequestNumber) { - try { - const response = await github.rest.issues.get({ - issue_number: issueID, - owner: context.repo.owner, - repo: context.repo.repo, - }) - return response.data - } catch (error) { - console.log(`${error.name}: ${error.code}`); - return false - } -} - -module.exports = { - detectIssue, - getGitHubInfo -}; diff --git a/.github/workflows/dev_pr/issue_check.js b/.github/workflows/dev_pr/issue_check.js deleted file mode 100644 index 176349cdd051..000000000000 --- a/.github/workflows/dev_pr/issue_check.js +++ /dev/null @@ -1,84 +0,0 @@ -// 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. - -const helpers = require("./helpers.js"); - -/** - * Assigns the GitHub Issue to the PR creator. - * - * @param {Object} github - * @param {Object} context - * @param {String} pullRequestNumber - * @param {Object} issueInfo - */ -async function assignGitHubIssue(github, context, pullRequestNumber, issueInfo) { - await github.rest.issues.addAssignees({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueInfo.number, - assignees: context.payload.pull_request.user.login - }); - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pullRequestNumber, - body: ":warning: GitHub issue #" + issueInfo.number + " **has been automatically assigned in GitHub** to PR creator." - }); -} - -/** - * Performs checks on the GitHub Issue: - * - The issue is assigned to someone. If not assign it gets automatically - * assigned to the PR creator. - * - The issue contains any label. - * - * @param {Object} github - * @param {Object} context - * @param {String} pullRequestNumber - * @param {String} issueID - */ -async function verifyGitHubIssue(github, context, pullRequestNumber, issueID) { - const issueInfo = await helpers.getGitHubInfo(github, context, issueID, pullRequestNumber); - if (!issueInfo) { - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pullRequestNumber, - body: ":x: GitHub issue #" + issueID + " could not be retrieved." - }) - } - if (!issueInfo.assignees.length) { - await assignGitHubIssue(github, context, pullRequestNumber, issueInfo); - } - if(!issueInfo.labels.filter((label) => label.name.startsWith("Component:")).length) { - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pullRequestNumber, - body: ":warning: GitHub issue #" + issueID + " **has no components**, please add labels for components." - }) - } -} - -module.exports = async ({github, context}) => { - const pullRequestNumber = context.payload.number; - const title = context.payload.pull_request.title; - const issue = helpers.detectIssue(title) - if (issue && issue.kind === "github") { - await verifyGitHubIssue(github, context, pullRequestNumber, issue.id); - } -}; diff --git a/.github/workflows/dev_pr/labeler.yml b/.github/workflows/dev_pr/labeler.yml deleted file mode 100644 index 0950cacc2b9f..000000000000 --- a/.github/workflows/dev_pr/labeler.yml +++ /dev/null @@ -1,75 +0,0 @@ -# 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. - -"Component: C++": -- changed-files: - - any-glob-to-any-file: - - cpp/**/* - -"Component: GLib": -- changed-files: - - any-glob-to-any-file: - - c_glib/**/* - -"Component: MATLAB": -- changed-files: - - any-glob-to-any-file: - - matlab/**/* - -"Component: Python": -- changed-files: - - any-glob-to-any-file: - - python/**/* - -"Component: R": -- changed-files: - - any-glob-to-any-file: - - r/**/* - -"Component: Ruby": -- changed-files: - - any-glob-to-any-file: - - ruby/**/* - -"Component: FlightRPC": -- changed-files: - - any-glob-to-any-file: - - cpp/src/arrow/flight/**/* - - r/R/flight.* - - python/pyarrow/*flight.* - -"Component: Gandiva": -- changed-files: - - any-glob-to-any-file: - - c_glib/gandiva-glib/**/* - - cpp/src/gandiva/**/* - - python/pyarrow/gandiva.* - - ruby/red-gandiva/**/* - -"Component: Parquet": -- changed-files: - - any-glob-to-any-file: - - c_glib/parquet-glib/**/* - - cpp/src/parquet/**/* - - r/R/parquet.* - - ruby/red-parquet/**/* - -"Component: Documentation": -- changed-files: - - any-glob-to-any-file: - - docs/**/* - - "**/*.{md, rst, Rmd, Rd}" diff --git a/.github/workflows/dev_pr/link.js b/.github/workflows/dev_pr/link.js deleted file mode 100644 index 3f50a5b9b9d4..000000000000 --- a/.github/workflows/dev_pr/link.js +++ /dev/null @@ -1,83 +0,0 @@ -// 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. - -const helpers = require("./helpers.js"); - - -/** - * Checks whether message is present on Pull Request list of comments. - * - * @param {Object} github - * @param {Object} context - * @param {String} pullRequestNumber - * @param {String} message - * @returns {Boolean} true if message was found. - */ -async function haveComment(github, context, pullRequestNumber, message) { - const options = { - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pullRequestNumber, - page: 1 - }; - while (true) { - const response = await github.rest.issues.listComments(options); - if (response.data.some(comment => comment.body === message)) { - return true; - } - if (!/;\s*rel="next"/.test(response.headers.link || "")) { - break; - } - options.page++; - } - return false; -} - -/** - * Adds a comment on the Pull Request linking the GitHub issue. - * - * @param {Object} github - * @param {Object} context - * @param {String} pullRequestNumber - String containing numeric id of PR - * @param {String} issueID - String containing numeric id of the github issue - */ -async function commentGitHubURL(github, context, pullRequestNumber, issueID) { - // Make the call to ensure issue exists before adding comment - const issueInfo = await helpers.getGitHubInfo(github, context, issueID, pullRequestNumber); - const message = "* GitHub Issue: #" + issueInfo.number - if (issueInfo) { - const body = context.payload.pull_request.body || ""; - if (body.includes(message)) { - return; - } - await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pullRequestNumber, - body: body + "\n" + message - }); - } -} - -module.exports = async ({github, context}) => { - const pullRequestNumber = context.payload.number; - const title = context.payload.pull_request.title; - const issue = helpers.detectIssue(title); - if (issue && issue.kind === "github") { - await commentGitHubURL(github, context, pullRequestNumber, issue.id); - } -}; diff --git a/.github/workflows/dev_pr/title_check.js b/.github/workflows/dev_pr/title_check.js deleted file mode 100644 index a986c8bc5f03..000000000000 --- a/.github/workflows/dev_pr/title_check.js +++ /dev/null @@ -1,78 +0,0 @@ -// 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. - -const fs = require("fs"); -const helpers = require("./helpers.js"); - -async function commentOpenGitHubIssue(github, context, pullRequestNumber) { - const {data: comments} = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pullRequestNumber, - per_page: 1 - }); - if (comments.length > 0) { - return; - } - const commentPath = ".github/workflows/dev_pr/title_check.md"; - const comment = fs.readFileSync(commentPath).toString(); - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pullRequestNumber, - body: comment - }); -} - -/** - * Converts the pull request to draft. - * - * @param {Object} github - * @param {Object} context - */ -async function convertToDraft(github, context) { - if (context.payload.pull_request.draft) { - return; - } - - await github.graphql( - ` - mutation ($pullRequestId: ID!) { - convertPullRequestToDraft( - input: {pullRequestId: $pullRequestId} - ) { - pullRequest { - id - } - } - } - `, - { - pullRequestId: context.payload.pull_request.node_id, - }, - ); -} - -module.exports = async ({github, context}) => { - const pullRequestNumber = context.payload.number; - const title = context.payload.pull_request.title; - const issue = helpers.detectIssue(title) - if (!issue) { - await commentOpenGitHubIssue(github, context, pullRequestNumber); - await convertToDraft(github, context); - } -}; diff --git a/.github/workflows/dev_pr/title_check.md b/.github/workflows/dev_pr/title_check.md deleted file mode 100644 index 1919e0cadb4a..000000000000 --- a/.github/workflows/dev_pr/title_check.md +++ /dev/null @@ -1,41 +0,0 @@ - - -Thanks for opening a pull request! - -**This pull request has been automatically converted to a draft because its title doesn't match Arrow's required format.** - -If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes), could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose - -Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project. - -Then could you also rename the pull request title in the following format? - - GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY} - -or - - MINOR: [${COMPONENT}] ${SUMMARY} - -**After updating the title, you can mark the pull request as ready for review.** - -See also: - - * [Other pull requests](https://github.com/apache/arrow/pulls/) - * [Contribution Guidelines - Contributing Overview](https://arrow.apache.org/docs/developers/overview.html) diff --git a/docs/source/developers/continuous_integration/overview.rst b/docs/source/developers/continuous_integration/overview.rst index 71bc53ef59a7..4ae0e97297c4 100644 --- a/docs/source/developers/continuous_integration/overview.rst +++ b/docs/source/developers/continuous_integration/overview.rst @@ -53,7 +53,8 @@ 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.yml`` - runs any time a PR is opened or updated; checks the formatting of the PR title, adds assignee to the appropriate GitHub issue if needed (or adds a comment requesting the user to include the issue id in the title), and adds any relevant GitHub labels + +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``. Extended builds ----------------------- From f37b26bfff8f8b8303a685b31fb3ad1f70afc083 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Tue, 10 Nov 2026 22:40:56 +0100 Subject: [PATCH 2/3] 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 | 30 ++++- .../continuous_integration/overview.rst | 1 + docs/source/developers/overview.rst | 9 +- 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..0444c458ef82 100644 --- a/dev/README.md +++ b/dev/README.md @@ -33,8 +33,34 @@ 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 the milestone of the pull request: +set it before you merge if the pull request isn't released in the next +major release. If the pull request doesn't have a milestone, the +milestone of the issue is kept or 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..9454b808f385 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,9 @@ 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 of that commit has the pull request description, a link + back 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 34ba758d6ea3d6df9099e3d76bff69cc6dd9ee26 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Sun, 15 Nov 2026 17:56:12 +0100 Subject: [PATCH 3/3] Clarify milestone and commit message wording --- dev/README.md | 9 +++++---- docs/source/developers/overview.rst | 5 ++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dev/README.md b/dev/README.md index 0444c458ef82..6e891b39bad7 100644 --- a/dev/README.md +++ b/dev/README.md @@ -50,11 +50,12 @@ you merge, check that: 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 the milestone of the pull request: -set it before you merge if the pull request isn't released in the next +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 -milestone of the issue is kept or the next major release is used. This -is only done for pull requests to `main`. +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 diff --git a/docs/source/developers/overview.rst b/docs/source/developers/overview.rst index 9454b808f385..53a40fa6f54a 100644 --- a/docs/source/developers/overview.rst +++ b/docs/source/developers/overview.rst @@ -146,9 +146,8 @@ will merge the pull request. This is done with a **squash merge**. cherry-pick individual patches onto a maintenance branch. Your pull request will appear in the GitHub interface to have been "merged". - The commit message of that commit has 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: