From dd946201153e27db2db9cf962e7c68180178496e Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 12 Jun 2024 17:59:21 +0100 Subject: [PATCH 1/9] :construction_worker: Collect workflow_run event context --- .github/workflows/coverage.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ecda6620a..3e3eb80a4 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -8,15 +8,33 @@ on: jobs: test: - name: Run tests & display coverage + name: "Run tests & display coverage" runs-on: ubuntu-latest - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + # Only run this job if the tests workflow was successful + if: ${{ github.event.workflow_run.conclusion == 'success' }} permissions: pull-requests: write contents: write # needed to edit the comment vs opening multiple ones actions: read steps: - - name: Post comment + # note that the workflow_run does not have context of the PR that triggered it + - name: "Get the triggering workflow run details" + id: get-run + uses: octokit/request-action@v2.x + with: + route: GET /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: "Check if the trigger was a PR event" + run: | + TRIGGER_EVENT=$(echo '${{ steps.get-run.outputs.data }}' | jq -r '.event') + if [[ "$TRIGGER_EVENT" != "pull_request" ]]; then + echo "Workflow was not triggered by a PR, skipping coverage comment." + exit 78 # Exiting with a neutral status + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: "Post coverage comment" uses: py-cov-action/python-coverage-comment-action@v3 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7b039f2a7c5be294deb9cc9c753c70154eef19a1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:03:55 +0000 Subject: [PATCH 2/9] [pre-commit.ci] Automatic linting and formatting fixes --- docs/community/practices/versions.md | 1 + docs/user_guide/theme-elements.md | 3 +++ 2 files changed, 4 insertions(+) diff --git a/docs/community/practices/versions.md b/docs/community/practices/versions.md index 18d7a7364..b52bcd189 100644 --- a/docs/community/practices/versions.md +++ b/docs/community/practices/versions.md @@ -14,6 +14,7 @@ We define "support" as testing against each of these versions so that users can For example, if we made a minor release tomorrow, we'd [look at the EOL schedule for Python](https://endoflife.date/python) and support all the versions that fall within a 3.5-year window. [^1]: Our support for Python versions is inspired by [NEP 029](https://numpy.org/neps/nep-0029-deprecation_policy.html). + [^2]: These policies are goals, not promises. We are a volunteer-led community with limited time. Consider these sections to be our intention, but we recognize that we may not always be able to meet these criteria if we cannot do so. We welcome contributions from others to help us more sustainably meet these goals! ## Supported Sphinx versions diff --git a/docs/user_guide/theme-elements.md b/docs/user_guide/theme-elements.md index 464f5cd57..3e54a750d 100644 --- a/docs/user_guide/theme-elements.md +++ b/docs/user_guide/theme-elements.md @@ -203,8 +203,11 @@ Here's a numeric footnote[^1], another one (preceded by a space) [^2], a named f All will end up as numbers in the rendered HTML, but in the source they look like `[^1]`, `[^2]`, `[^named]` and `[^*]`. [^1]: Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. + [^2]: Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. + [^named]: Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. + [^*]: Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. ## Link shortening for git repository services From 8aeeb7c2d852e3f6688a7b854b135c555bf99070 Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 12 Jun 2024 18:34:50 +0100 Subject: [PATCH 3/9] Simplify workflows --- .github/workflows/CI.yml | 6 ++++++ .github/workflows/coverage.yml | 27 +++++---------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cf976dbee..7d6aea7de 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -244,3 +244,9 @@ jobs: name: profile-results path: docbuild_profile.svg if-no-files-found: ignore + + post-coverage-comment: + name: "Post coverage comment" + # we call the coverage workflow directly to avoid issues with artefacts + if: ${{ github.event_name == 'pull_request' }} + uses: ./.github/workflows/coverage.yml \ No newline at end of file diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3e3eb80a4..b70e922e5 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,39 +1,22 @@ name: Post coverage comment on: - workflow_run: - workflows: ["continuous-integration"] - types: - - completed + workflow_call: jobs: test: name: "Run tests & display coverage" runs-on: ubuntu-latest - # Only run this job if the tests workflow was successful - if: ${{ github.event.workflow_run.conclusion == 'success' }} permissions: pull-requests: write contents: write # needed to edit the comment vs opening multiple ones actions: read steps: - # note that the workflow_run does not have context of the PR that triggered it - - name: "Get the triggering workflow run details" - id: get-run - uses: octokit/request-action@v2.x + - name: "Download coverage data 📥" + uses: actions/download-artifact@v4 with: - route: GET /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: "Check if the trigger was a PR event" - run: | - TRIGGER_EVENT=$(echo '${{ steps.get-run.outputs.data }}' | jq -r '.event') - if [[ "$TRIGGER_EVENT" != "pull_request" ]]; then - echo "Workflow was not triggered by a PR, skipping coverage comment." - exit 78 # Exiting with a neutral status - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + pattern: coverage-data-* + merge-multiple: true - name: "Post coverage comment" uses: py-cov-action/python-coverage-comment-action@v3 with: From 2ed9ae966d7bbea631ca9e19ccc62502e6fd51b6 Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 12 Jun 2024 19:09:37 +0100 Subject: [PATCH 4/9] Add download artefacts --- .github/workflows/coverage.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b70e922e5..b063f01fc 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,11 +12,29 @@ jobs: contents: write # needed to edit the comment vs opening multiple ones actions: read steps: + - name: "Download coverage data 📥" + uses: actions/download-artifact@v4 + with: + route: GET /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: "Check if the trigger was a PR event" + run: | + TRIGGER_EVENT=$(echo '${{ steps.get-run.outputs.data }}' | jq -r '.event') + if [[ "$TRIGGER_EVENT" != "pull_request" ]]; then + echo "Workflow was not triggered by a PR, skipping coverage comment." + exit 78 # Exiting with a neutral status + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # this needs the .coverage file so we download from the CI workflow artifacts - name: "Download coverage data 📥" uses: actions/download-artifact@v4 with: pattern: coverage-data-* merge-multiple: true + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} - name: "Post coverage comment" uses: py-cov-action/python-coverage-comment-action@v3 with: From 596852d25bb7cc545a27fe519b07c6e27240bfbb Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 12 Jun 2024 20:29:28 +0100 Subject: [PATCH 5/9] Fix workflow --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7d6aea7de..212e558d0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -249,4 +249,4 @@ jobs: name: "Post coverage comment" # we call the coverage workflow directly to avoid issues with artefacts if: ${{ github.event_name == 'pull_request' }} - uses: ./.github/workflows/coverage.yml \ No newline at end of file + uses: ./.github/workflows/coverage.yml From f1a53b9ffe49d8486dda3a0e709088643dc60d75 Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 12 Jun 2024 20:38:39 +0100 Subject: [PATCH 6/9] :bug: Remove leftover lines --- .github/workflows/CI.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 212e558d0..cf976dbee 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -244,9 +244,3 @@ jobs: name: profile-results path: docbuild_profile.svg if-no-files-found: ignore - - post-coverage-comment: - name: "Post coverage comment" - # we call the coverage workflow directly to avoid issues with artefacts - if: ${{ github.event_name == 'pull_request' }} - uses: ./.github/workflows/coverage.yml From adc6d96b710e14a39ede9dac4cefe0d1cf21718f Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 12 Jun 2024 20:42:57 +0100 Subject: [PATCH 7/9] Remove duplicated download --- .github/workflows/coverage.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b063f01fc..ba5b1a1b8 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,8 +12,9 @@ jobs: contents: write # needed to edit the comment vs opening multiple ones actions: read steps: - - name: "Download coverage data 📥" - uses: actions/download-artifact@v4 + - name: "Get the triggering workflow run details" + id: get-run + uses: octokit/request-action@v2.x with: route: GET /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} env: From 1137a82cabd83e06ffeec050d1415983f96b64d7 Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 12 Jun 2024 20:53:40 +0100 Subject: [PATCH 8/9] Add CI trigger --- .github/workflows/coverage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ba5b1a1b8..94114891d 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,7 +1,10 @@ name: Post coverage comment on: - workflow_call: + workflow_run: + workflows: ["continuous-integration"] + types: + - completed jobs: test: From 51cc23dd8b77fb027e1f1242057c4c8c0fe90bdd Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Thu, 13 Jun 2024 01:42:03 -0700 Subject: [PATCH 9/9] Update .github/workflows/coverage.yml --- .github/workflows/coverage.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 94114891d..482eb655b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,8 +29,6 @@ jobs: echo "Workflow was not triggered by a PR, skipping coverage comment." exit 78 # Exiting with a neutral status fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # this needs the .coverage file so we download from the CI workflow artifacts - name: "Download coverage data 📥" uses: actions/download-artifact@v4