From bc56b5cdfe035473d40355c7f30a3f837e98db9a Mon Sep 17 00:00:00 2001 From: damiano Date: Thu, 21 Nov 2024 04:49:01 +0000 Subject: [PATCH] chore(CI): remove redundant `bors x` actions, clean up new one (#19313) I did a fair amount of testing, making sure that the new action has the same functionality as the old one. As far as I can tell, they work the same. The only exception could be that the new action does not remove the `awaiting-author` label, since all the tests that I saw did not have the label in the first place. --- .github/workflows/add_label_from_comment.yml | 60 ------------------ .github/workflows/add_label_from_review.yml | 62 ------------------- .../add_label_from_review_comment.yml | 62 ------------------- .github/workflows/maintainer_bors.yml | 16 +---- 4 files changed, 3 insertions(+), 197 deletions(-) delete mode 100644 .github/workflows/add_label_from_comment.yml delete mode 100644 .github/workflows/add_label_from_review.yml delete mode 100644 .github/workflows/add_label_from_review_comment.yml diff --git a/.github/workflows/add_label_from_comment.yml b/.github/workflows/add_label_from_comment.yml deleted file mode 100644 index 30a161785134f..0000000000000 --- a/.github/workflows/add_label_from_comment.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Add "ready-to-merge" and "delegated" label from comment - -on: - issue_comment: - types: [created] - -jobs: - add_ready_to_merge_label: - name: Add ready-to-merge label - if: github.event.issue.pull_request && (startsWith(github.event.comment.body, 'bors r+') || contains(toJSON(github.event.comment.body), '\nbors r+') || startsWith(github.event.comment.body, 'bors merge') || contains(toJSON(github.event.comment.body), '\nbors merge')) - runs-on: ubuntu-latest - steps: - - id: user_permission - uses: actions-cool/check-user-permission@v2 - with: - require: 'admin' - - - if: (steps.user_permission.outputs.require-result == 'true') || (github.event.comment.user.login == 'leanprover-community-mathlib4-bot') || (github.event.comment.user.login == 'leanprover-community-bot-assistant') - uses: octokit/request-action@v2.x - id: add_label - name: Add label - with: - route: POST /repos/:repository/issues/:issue_number/labels - repository: ${{ github.repository }} - issue_number: ${{ github.event.issue.number }} - labels: '["ready-to-merge"]' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - if: (steps.user_permission.outputs.require-result == 'true') || (github.event.comment.user.login == 'leanprover-community-mathlib4-bot') || (github.event.comment.user.login == 'leanprover-community-bot-assistant') - id: remove_labels - name: Remove "awaiting-author" - # we use curl rather than octokit/request-action so that the job won't fail - # (and send an annoying email) if the labels don't exist - run: | - curl --request DELETE \ - --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/awaiting-author \ - --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' - - add_delegated_label: - name: Add delegated label - if: github.event.issue.pull_request && (startsWith(github.event.comment.body, 'bors d') || contains(toJSON(github.event.comment.body), '\nbors d')) - runs-on: ubuntu-latest - steps: - - id: user_permission - uses: actions-cool/check-user-permission@v2 - with: - require: 'admin' - - - if: (steps.user_permission.outputs.require-result == 'true') || (github.event.comment.user.login == 'leanprover-community-mathlib4-bot') || (github.event.comment.user.login == 'leanprover-community-bot-assistant') - uses: octokit/request-action@v2.x - id: add_label - name: Add label - with: - route: POST /repos/:repository/issues/:issue_number/labels - repository: ${{ github.repository }} - issue_number: ${{ github.event.issue.number }} - labels: '["delegated"]' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/add_label_from_review.yml b/.github/workflows/add_label_from_review.yml deleted file mode 100644 index 9406866ff214e..0000000000000 --- a/.github/workflows/add_label_from_review.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Add "ready-to-merge" and "delegated" label from PR review - -on: - pull_request_review: - types: [submitted] - -jobs: - add_ready_to_merge_label: - name: Add ready-to-merge label - if: (startsWith(github.event.review.body, 'bors r+') || contains(toJSON(github.event.review.body), '\nbors r+') || startsWith(github.event.review.body, 'bors merge') || contains(toJSON(github.event.review.body), '\nbors merge')) - runs-on: ubuntu-latest - steps: - - id: user_permission - uses: actions-cool/check-user-permission@v2 - with: - require: 'write' - token: ${{ secrets.TRIAGE_TOKEN }} - - - if: (steps.user_permission.outputs.require-result == 'true') || (github.event.review.user.login == 'leanprover-community-mathlib4-bot') || (github.event.review.user.login == 'leanprover-community-bot-assistant') - uses: octokit/request-action@v2.x - id: add_label - name: Add label - with: - route: POST /repos/:repository/issues/:issue_number/labels - repository: ${{ github.repository }} - issue_number: ${{ github.event.pull_request.number }} - labels: '["ready-to-merge"]' - env: - GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} - - - if: (steps.user_permission.outputs.require-result == 'true') || (github.event.review.user.login == 'leanprover-community-mathlib4-bot') || (github.event.review.user.login == 'leanprover-community-bot-assistant') - id: remove_labels - name: Remove "awaiting-author" - # we use curl rather than octokit/request-action so that the job won't fail - # (and send an annoying email) if the labels don't exist - run: | - curl --request DELETE \ - --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/awaiting-author \ - --header 'authorization: Bearer ${{ secrets.TRIAGE_TOKEN }}' - - add_delegated_label: - name: Add delegated label - if: (startsWith(github.event.review.body, 'bors d') || contains(toJSON(github.event.review.body), '\nbors d')) - runs-on: ubuntu-latest - steps: - - id: user_permission - uses: actions-cool/check-user-permission@v2 - with: - require: 'write' - token: ${{ secrets.TRIAGE_TOKEN }} - - - if: (steps.user_permission.outputs.require-result == 'true') || (github.event.review.user.login == 'leanprover-community-mathlib4-bot') || (github.event.review.user.login == 'leanprover-community-bot-assistant') - uses: octokit/request-action@v2.x - id: add_label - name: Add label - with: - route: POST /repos/:repository/issues/:issue_number/labels - repository: ${{ github.repository }} - issue_number: ${{ github.event.pull_request.number }} - labels: '["delegated"]' - env: - GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} diff --git a/.github/workflows/add_label_from_review_comment.yml b/.github/workflows/add_label_from_review_comment.yml deleted file mode 100644 index da8b643fb0ee4..0000000000000 --- a/.github/workflows/add_label_from_review_comment.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Add "ready-to-merge" and "delegated" label from PR review comment - -on: - pull_request_review_comment: - types: [created] - -jobs: - add_ready_to_merge_label: - name: Add ready-to-merge label - if: (startsWith(github.event.comment.body, 'bors r+') || contains(toJSON(github.event.comment.body), '\nbors r+') || startsWith(github.event.comment.body, 'bors merge') || contains(toJSON(github.event.comment.body), '\nbors merge')) - runs-on: ubuntu-latest - steps: - - id: user_permission - uses: actions-cool/check-user-permission@v2 - with: - require: 'write' - token: ${{ secrets.TRIAGE_TOKEN }} - - - if: (steps.user_permission.outputs.require-result == 'true') || (github.event.comment.user.login == 'leanprover-community-mathlib4-bot') || (github.event.comment.user.login == 'leanprover-community-bot-assistant') - uses: octokit/request-action@v2.x - id: add_label - name: Add label - with: - route: POST /repos/:repository/issues/:issue_number/labels - repository: ${{ github.repository }} - issue_number: ${{ github.event.pull_request.number }} - labels: '["ready-to-merge"]' - env: - GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} - - - if: (steps.user_permission.outputs.require-result == 'true') || (github.event.comment.user.login == 'leanprover-community-mathlib4-bot') || (github.event.comment.user.login == 'leanprover-community-bot-assistant') - id: remove_labels - name: Remove "awaiting-author" - # we use curl rather than octokit/request-action so that the job won't fail - # (and send an annoying email) if the labels don't exist - run: | - curl --request DELETE \ - --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/awaiting-author \ - --header 'authorization: Bearer ${{ secrets.TRIAGE_TOKEN }}' - - add_delegated_label: - name: Add delegated label - if: (startsWith(github.event.comment.body, 'bors d') || contains(toJSON(github.event.comment.body), '\nbors d')) - runs-on: ubuntu-latest - steps: - - id: user_permission - uses: actions-cool/check-user-permission@v2 - with: - require: 'write' - token: ${{ secrets.TRIAGE_TOKEN }} - - - if: (steps.user_permission.outputs.require-result == 'true') || (github.event.comment.user.login == 'leanprover-community-mathlib4-bot') || (github.event.comment.user.login == 'leanprover-community-bot-assistant') - uses: octokit/request-action@v2.x - id: add_label - name: Add label - with: - route: POST /repos/:repository/issues/:issue_number/labels - repository: ${{ github.repository }} - issue_number: ${{ github.event.pull_request.number }} - labels: '["delegated"]' - env: - GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} diff --git a/.github/workflows/maintainer_bors.yml b/.github/workflows/maintainer_bors.yml index 073477b4fa324..8b06a44a1b926 100644 --- a/.github/workflows/maintainer_bors.yml +++ b/.github/workflows/maintainer_bors.yml @@ -19,13 +19,8 @@ jobs: # both set simultaneously: depending on the event that triggers the PR, usually only one is set env: AUTHOR: ${{ github.event.comment.user.login }}${{ github.event.review.user.login }} - PR_NUMBER: ${{ github.event.issue.number }}${{ github.event.pull_request.number }} COMMENT_EVENT: ${{ github.event.comment.body }} COMMENT_REVIEW: ${{ github.event.review.body }} - PR_TITLE_ISSUE: ${{ github.event.issue.title }} - PR_TITLE_PR: ${{ github.event.pull_request.title }} - PR_URL: ${{ github.event.issue.html_url }}${{ github.event.pull_request.html_url }} - EVENT_NAME: ${{ github.event_name }} name: Add ready-to-merge or delegated label runs-on: ubuntu-latest steps: @@ -43,8 +38,7 @@ jobs: printf $'"bors delegate" or "bors merge" found? \'%s\'\n' "${m_or_d}" printf $'AUTHOR: \'%s\'\n' "${AUTHOR}" - printf $'PR_NUMBER: \'%s\'\n' "${PR_NUMBER}" - printf $'OTHER_NUMBER: \'%s\'\n' "${{ github.event.issue.number }}${{ github.event.pull_request.number }}" + printf $'PR_NUMBER: \'%s\'\n' "${{ github.event.issue.number }}${{ github.event.pull_request.number }}" printf $'%s' "${{ github.event.issue.number }}${{ github.event.pull_request.number }}" | hexdump -cC printf $'mOrD=%s\n' "${m_or_d}" >> "${GITHUB_OUTPUT}" @@ -64,9 +58,6 @@ jobs: uses: actions-cool/check-user-permission@v2 with: require: 'admin' - # review(_comment) use - # require: 'write' - # token: ${{ secrets.TRIAGE_TOKEN }} - name: Add ready-to-merge or delegated label id: add_label @@ -75,13 +66,12 @@ jobs: steps.merge_or_delegate.outputs.bot == 'true' ) }} uses: octokit/request-action@v2.x with: - # check is this ok? was /repos/:repository/issues/:issue_number/labels route: POST /repos/:repository/issues/:issue_number/labels repository: ${{ github.repository }} issue_number: ${{ github.event.issue.number }}${{ github.event.pull_request.number }} labels: '["${{ steps.merge_or_delegate.outputs.mOrD }}"]' env: - GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} # comment uses ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }} - if: ${{ ! steps.merge_or_delegate.outputs.mOrD == '' && ( steps.user_permission.outputs.require-result == 'true' || @@ -92,6 +82,6 @@ jobs: # (and send an annoying email) if the labels don't exist run: | curl --request DELETE \ - --url "https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/labels/awaiting-author" \ + --url "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}${{ github.event.pull_request.number }}/labels/awaiting-author" \ --header 'authorization: Bearer ${{ secrets.TRIAGE_TOKEN }}' # comment uses ${{ secrets.GITHUB_TOKEN }}