-
-
Notifications
You must be signed in to change notification settings - Fork 127
Add Coverage workflow #623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 41 commits
7078342
56faf0f
045b6f7
21b240c
71daf3d
3b6319d
e69ace4
4384206
b852953
022d37b
9f1b3e1
4bd0aa1
7a7d6b3
ba46124
b9613f7
525e198
034ec43
88ba8f6
6c43f31
943aba7
5bbafa0
ee8f319
2757de5
084e39d
6ed9889
f48d961
8d7600b
8677db5
f77717e
4cc732b
30a30d1
b03f51f
1a7c6e5
355ccd7
90c0e0c
b16e770
26ace2b
b41735a
50eaad7
4547b9c
7f67cf3
f5999ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| name: Add coverage comment on PR | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Test and lint"] | ||
| types: | ||
| - completed | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| get-pr-number: | ||
| runs-on: ubuntu-latest | ||
| permissions: {} | ||
| if: > | ||
| github.event.workflow_run.event == 'pull_request' | ||
| && github.repository == github.event.workflow_run.repository.full_name | ||
|
||
| # The github.repository == ... check will prevent this workflow from running on forks. | ||
| steps: | ||
| - name: Get PR number | ||
| id: get_pr_number | ||
| env: | ||
| SHA: "${{ github.event.workflow_run.head_sha }}" | ||
|
||
| REPO: "${{ github.repository }}" | ||
| run: | | ||
| # Query GitHub API to find the PR number associated with the head commit SHA | ||
| PR_DATA=$(curl -s "https://api.github.com/search/issues?q=repo:$REPO+type:pr+sha:$SHA") | ||
| # Check if head commit is on a single PR else ambiguous which PR triggered the workflow | ||
| ITEMS_COUNT=$(jq '.items | length' <<< "$PR_DATA") | ||
| if [ "$ITEMS_COUNT" -ne 1 ]; then | ||
| echo "Error: Expected exactly one PR, but found $ITEMS_COUNT." >&2 | ||
| exit 1 | ||
| fi | ||
| PR_NUMBER=$(jq '.items[0].number' <<< "$PR_DATA") | ||
| echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT | ||
| outputs: | ||
| pr_number: ${{ steps.get_pr_number.outputs.pr_number }} | ||
|
|
||
| create-md-comment: | ||
| runs-on: ubuntu-latest | ||
| permissions: {} | ||
| if: > | ||
| github.event.workflow_run.event == 'pull_request' | ||
| && github.repository == github.event.workflow_run.repository.full_name | ||
| steps: | ||
| - name: Download coverage report | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: coverage | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| - name: Code Coverage Report | ||
| uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0 | ||
| with: | ||
| filename: coverage.xml | ||
| badge: true | ||
| fail_below_min: false | ||
| format: markdown | ||
| hide_branch_rate: false | ||
| hide_complexity: true | ||
| indicators: true | ||
| output: both | ||
| thresholds: '80 90' | ||
| - name: Upload coverage summary | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: code-coverage-results | ||
| path: code-coverage-results.md | ||
| post-comment: | ||
| runs-on: ubuntu-latest | ||
| needs: [get-pr-number, create-md-comment] | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - name: Download coverage report | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: code-coverage-results | ||
| - name: Add Coverage PR Comment | ||
| uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.3 | ||
| with: | ||
| recreate: true | ||
| path: code-coverage-results.md | ||
| number: ${{ needs.get-pr-number.outputs.pr_number }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,3 +16,6 @@ venv*/ | |
| *.swp | ||
| *.pyc | ||
| *.egg-info/ | ||
|
|
||
| .coverage* | ||
| coverage.xml | ||
Uh oh!
There was an error while loading. Please reload this page.