-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
3 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,36 @@ 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' | ||
permissions: | ||
pull-requests: write | ||
contents: write # needed to edit the comment vs opening multiple ones | ||
actions: read | ||
steps: | ||
- name: Post comment | ||
- name: "Get the triggering workflow run details" | ||
id: get-run | ||
uses: octokit/[email protected] | ||
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 | ||
# 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: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters