rok commented on code in PR #55484: URL: https://github.com/apache/arrow/pull/55484#discussion_r4652324653
########## .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 + issues: write + +jobs: + update: + 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. The following steps set what GitHub doesn't set: + # the assignee and the milestone of the issue. + - name: Get issue + id: issue + env: + MESSAGE: ${{ github.event.head_commit.message }} + run: | + set -euo pipefail + + title=${MESSAGE%%$'\n'*} + if [[ ! "${title}" =~ ^GH-([0-9]+) ]]; then + echo "No GitHub issue in the commit title: ${title}" + exit 0 + fi + issue_number=${BASH_REMATCH[1]} + 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 + 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 + + # 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 Review Comment: Dropped issue assignment in e15f6cc534 since `Closes #XXX` links the resolving PR natively on the issue. I'm not sure about this though. If others like it let's go ahead. ########## .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 +<!-- +The line below is filled in automatically from the PR title. For a PR to main +it says "Closes #XXX" and GitHub closes the issue when the PR is merged. If +your PR fixes only a part of the issue, change "Closes" to "Refs" so that the +issue stays open. +--> * GitHub Issue: (filled in automatically from the PR title) Review Comment: Indeed, moved the note into the `(...)` placeholder in 46e282072a so Boring Cyborg replaces it automatically. ########## .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 + issues: write + +jobs: + update: + 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. The following steps set what GitHub doesn't set: + # the assignee and the milestone of the issue. + - name: Get issue + id: issue + env: + MESSAGE: ${{ github.event.head_commit.message }} + run: | + set -euo pipefail + + title=${MESSAGE%%$'\n'*} + if [[ ! "${title}" =~ ^GH-([0-9]+) ]]; then + echo "No GitHub issue in the commit title: ${title}" + exit 0 + fi + issue_number=${BASH_REMATCH[1]} + issue=$(gh api "repos/${GH_REPO}/issues/${issue_number}") Review Comment: Agreed that `gh issue view` would have been cleaner than raw `gh api`, though this workflow was replaced by the scheduled `archery release update-milestones` job in e15f6cc534. ########## .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 + issues: write + +jobs: + update: + 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. The following steps set what GitHub doesn't set: + # the assignee and the milestone of the issue. + - name: Get issue + id: issue + env: + MESSAGE: ${{ github.event.head_commit.message }} + run: | + set -euo pipefail + + title=${MESSAGE%%$'\n'*} + if [[ ! "${title}" =~ ^GH-([0-9]+) ]]; then + echo "No GitHub issue in the commit title: ${title}" + exit 0 + fi + issue_number=${BASH_REMATCH[1]} + 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 + 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 + + # 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 + + 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 Review Comment: Great idea — replaced `dev_pr_merged.yml` with `archery release update-milestones` and `.github/workflows/dev_update_milestones.yml` (every 6 hours + `workflow_dispatch`) in e15f6cc534 (simplified in 3ca2e4c908). A few details: - Uses `maint-X.0.0` (matching `MajorRelease.branch`), walking `previous_tag..maint-X.0.0` first and then `maint-X.0.0..main` (skipping cherry-picked summaries) so pre-cut/direct/cherry-picked commits get `X.0.0` while post-cut and partial-then-closing issues get the next major milestone. - Shares a batched GraphQL `issueOrPullRequest` helper with `count_committers` (skipping PRs, open issues, `NOT_PLANNED` closures, and existing milestones; tolerating `NOT_FOUND` typos with a warning). - Verified with unit tests and a `--dry-run` against `apache/arrow` (which already caught `#55335` missing `27.0.0`). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
