From f9342f91d3b95a06054839b3a925ad8a56504d6d Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 8 May 2023 18:48:44 -0400 Subject: [PATCH 1/5] WIP --- .github/workflows/label.yml | 18 ++++++++ .github/workflows/label_on_approval.yml | 59 +++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 6060fe1c1..ec8592c86 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -23,3 +23,21 @@ jobs: - uses: actions/labeler@v4.3.0 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" + + label_approved: + name: Label on Approval + if: | + !contains(github.event.pull_request.labels.*.name, 'approved') && + (github.event.review.state == 'approved') && + runs-on: ubuntu-latest + steps: + - name: Label Approved + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['approved'] + }) diff --git a/.github/workflows/label_on_approval.yml b/.github/workflows/label_on_approval.yml index 38b9f8a78..c21024203 100644 --- a/.github/workflows/label_on_approval.yml +++ b/.github/workflows/label_on_approval.yml @@ -4,14 +4,27 @@ on: pull_request_review: types: - submitted + pull_request_target: + types: + - ready_for_review + - review_requested + +permissions: + checks: write + contents: read + pull-requests: write jobs: - approved: + label_approved: name: Label on Approval - if: github.event.review.state == 'approved' + if: | + (!contains(github.event.pull_request.labels.*.name, 'approved')) && + (github.event.review.state == 'approved') && + (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) runs-on: ubuntu-latest steps: - - uses: actions/github-script@v6.4.1 + - name: Label Approved + uses: actions/github-script@v6.4.1 with: script: | github.rest.issues.addLabels({ @@ -20,3 +33,43 @@ jobs: repo: context.repo.repo, labels: ['approved'] }) + + comment_approved: + name: Comment Concerning Approved Tag + if: | + (github.event_name == 'pull_request_target') || + (github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) + runs-on: ubuntu-latest + steps: + - name: Find comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: This Pull Request is coming from a fork and must be manually tagged `approved` in order to perform additional testing + - name: Create comment + if: | + (steps.fc.outputs.comment-id == '') || + (!contains(github.event.pull_request.labels.*.name, 'approved')) + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + > **Warning** + > This Pull Request is coming from a fork and must be manually tagged `approved` in order to perform additional testing. + edit-mode: replace + - name: Update comment + if: | + contains(github.event.pull_request.labels.*.name, 'approved') + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + + Pull Request is approved! + reactions: | + hooray + edit-mode: append From 85388cf43223ccedc99b80b4e6b9e99238e8ecec Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 15 Sep 2023 17:38:30 -0400 Subject: [PATCH 2/5] labelling happens in label.yml unless part of approval process --- .github/workflows/label.yml | 18 ------------------ .github/workflows/label_on_approval.yml | 1 - 2 files changed, 19 deletions(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index ec8592c86..6060fe1c1 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -23,21 +23,3 @@ jobs: - uses: actions/labeler@v4.3.0 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" - - label_approved: - name: Label on Approval - if: | - !contains(github.event.pull_request.labels.*.name, 'approved') && - (github.event.review.state == 'approved') && - runs-on: ubuntu-latest - steps: - - name: Label Approved - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ['approved'] - }) diff --git a/.github/workflows/label_on_approval.yml b/.github/workflows/label_on_approval.yml index c21024203..2d58ac3be 100644 --- a/.github/workflows/label_on_approval.yml +++ b/.github/workflows/label_on_approval.yml @@ -68,7 +68,6 @@ jobs: comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} body: | - Pull Request is approved! reactions: | hooray From 7dc07910c99f407dcc7af764984b75a6fd4254f5 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 18 Sep 2023 12:26:40 -0400 Subject: [PATCH 3/5] more specific label target --- .github/labeler.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index 99b5500da..50a3cba46 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,4 +1,3 @@ - # label rules used by .github/workflows/label.yml # label 'ci' all automation-related steps and files @@ -10,7 +9,10 @@ API: - xclim/cli.py CI: - - .* # all '.' files + - .editorconfig + - .pre-commit-config.yaml + - .readthedocs.yml + - .yamllint.yml - .github/workflows/* - docs/Makefile - pylintrc @@ -34,5 +36,9 @@ indicators: - xclim/data/**/*.json - xclim/data/**/*.yml +information: + - CONTRIBUTING.rst + sdba: - xclim/sdba/**/* + - tests/test_sdba/*.py From 8cc15ce1fc5382a907aac31db46ac251fb77ac4b Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 21 Sep 2023 11:38:54 -0400 Subject: [PATCH 4/5] update CHANGES.rst --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index fe21033d9..848def71e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -29,6 +29,8 @@ Internal changes * Added a `pytest` marker (``pytest.mark.requires_internet``) to allow for skipping of tests that depend on remote network calls to function properly. (:pull:`1473`). * Added handling for `pytest-socket`'s ``SocketBlockedError`` in ``xclim.testing.open_dataset`` when attempting to fetch md5 validation files for cached testing data while explicitly disabling internet sockets. (:issue:`1468`, :pull:`1473`). * Updated the testing data used in the `analogs.ipynb` notebook to use the testing data now found in `Ouranosinc/xclim-testdata`'s main branch. (`xclim-testdata PR/26 `_, :pull:`1473`). +* Fixed an issue with automatic labelling that occurs when a Pull Request is made from a forked repository. (:pull:`1479`). +* Changes to the ``.zenodo.json` file no longer are marked as CI-related changes. (:pull:`1479`). v0.45.0 (2023-09-05) -------------------- From 6e791100138ff0b274745ca957cc8919e92127bc Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 21 Sep 2023 13:33:02 -0400 Subject: [PATCH 5/5] fix back-tick --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 848def71e..933c7377b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -30,7 +30,7 @@ Internal changes * Added handling for `pytest-socket`'s ``SocketBlockedError`` in ``xclim.testing.open_dataset`` when attempting to fetch md5 validation files for cached testing data while explicitly disabling internet sockets. (:issue:`1468`, :pull:`1473`). * Updated the testing data used in the `analogs.ipynb` notebook to use the testing data now found in `Ouranosinc/xclim-testdata`'s main branch. (`xclim-testdata PR/26 `_, :pull:`1473`). * Fixed an issue with automatic labelling that occurs when a Pull Request is made from a forked repository. (:pull:`1479`). -* Changes to the ``.zenodo.json` file no longer are marked as CI-related changes. (:pull:`1479`). +* Changes to the ``.zenodo.json`` file no longer are marked as CI-related changes. (:pull:`1479`). v0.45.0 (2023-09-05) --------------------