Skip to content

Commit 80d4f30

Browse files
authored
BUG - Ensure coverage comment is triggered (#1879)
It seems the coverage comment workflow was not being triggered due to a lack of context regarding the original workflow trigger event. This change should ensure that it accesses the correct context only when the trigger workflow has been completed successfully.
1 parent 9c5636c commit 80d4f30

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

.github/workflows/coverage.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,36 @@ on:
88

99
jobs:
1010
test:
11-
name: Run tests & display coverage
11+
name: "Run tests & display coverage"
1212
runs-on: ubuntu-latest
13-
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
1413
permissions:
1514
pull-requests: write
1615
contents: write # needed to edit the comment vs opening multiple ones
1716
actions: read
1817
steps:
19-
- name: Post comment
18+
- name: "Get the triggering workflow run details"
19+
id: get-run
20+
uses: octokit/request-action@v2.x
21+
with:
22+
route: GET /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
- name: "Check if the trigger was a PR event"
26+
run: |
27+
TRIGGER_EVENT=$(echo '${{ steps.get-run.outputs.data }}' | jq -r '.event')
28+
if [[ "$TRIGGER_EVENT" != "pull_request" ]]; then
29+
echo "Workflow was not triggered by a PR, skipping coverage comment."
30+
exit 78 # Exiting with a neutral status
31+
fi
32+
# this needs the .coverage file so we download from the CI workflow artifacts
33+
- name: "Download coverage data 📥"
34+
uses: actions/download-artifact@v4
35+
with:
36+
pattern: coverage-data-*
37+
merge-multiple: true
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
run-id: ${{ github.event.workflow_run.id }}
40+
- name: "Post coverage comment"
2041
uses: py-cov-action/python-coverage-comment-action@v3
2142
with:
2243
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/community/practices/versions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ We define "support" as testing against each of these versions so that users can
1414
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.
1515

1616
[^1]: Our support for Python versions is inspired by [NEP 029](https://numpy.org/neps/nep-0029-deprecation_policy.html).
17+
1718
[^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!
1819

1920
## Supported Sphinx versions

docs/user_guide/theme-elements.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,11 @@ Here's a numeric footnote[^1], another one (preceded by a space) [^2], a named f
203203
All will end up as numbers in the rendered HTML, but in the source they look like `[^1]`, `[^2]`, `[^named]` and `[^*]`.
204204

205205
[^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.
206+
206207
[^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.
208+
207209
[^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.
210+
208211
[^*]: 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.
209212

210213
## Link shortening for git repository services

0 commit comments

Comments
 (0)