File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Schema: https://json.schemastore.org/github-action.json
2+ # This action compares coverage on a PR against a baseline stored on a branch.
3+ # it against the current coverage.xml, posting a comparison comment on the PR.
4+ name : ' Coverage Diff'
5+ description : ' Compare PR coverage against a baseline branch and post a summary comment on the PR'
6+ inputs :
7+ baseline-branch :
8+ description : ' Branch containing the baseline coverage.xml'
9+ default : ' coverage-info'
10+ required : false
11+
12+ runs :
13+ using : " composite"
14+ steps :
15+ - name : Fetch baseline coverage
16+ id : fetch_baseline
17+ shell : bash
18+ run : |
19+ if git fetch origin ${{ inputs.baseline-branch }} 2>/dev/null; then
20+ git show origin/${{ inputs.baseline-branch }}:coverage.xml > /tmp/base-coverage.xml
21+ echo "baseline_found=true" >> $GITHUB_OUTPUT
22+ else
23+ echo "baseline_found=false" >> $GITHUB_OUTPUT
24+ echo "::warning:: Baseline branch '${{ inputs.baseline-branch }}' not found"
25+ fi
26+
27+ - name : Run coverage diff
28+ if : ${{ steps.fetch_baseline.outputs.baseline_found == 'true' }}
29+ shell : bash
30+ env :
31+ GH_TOKEN : ${{ github.token }}
32+ run : |
33+ pip install pycobertura --quiet
34+ DIFF_OUTPUT=$(pycobertura diff /tmp/base-coverage.xml coverage.xml --no-source --format markdown || true)
35+ COMMENT_BODY=$(cat <<EOF
36+ ## 📊 Coverage Diff
37+ ${DIFF_OUTPUT}
38+ Base: \`${{ inputs.baseline-branch }}\` · PR: \`${{ github.head_ref }}\`
39+ EOF
40+ )
41+ echo "$COMMENT_BODY" >> $GITHUB_STEP_SUMMARY
42+ echo "$COMMENT_BODY" > /tmp/coverage-comment.md
43+ gh pr comment ${{ github.event.pull_request.number }} --body-file /tmp/coverage-comment.md
Original file line number Diff line number Diff line change 5252 if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
5353 run : genbadge coverage -i coverage.xml -o coverage-badge.svg
5454
55- <<<<<<< HEAD
5655 - name : Push badge to coverage-info branch
5756 if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
5857 env :
7877
7978 git commit -m "Update coverage badge [skip ci]"
8079 git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" coverage-info
81- =======
82- - name : Push badge and summary to coverage-info branch
83- if : ${{ env.COVERAGE == 'true' && github.event_name != 'pull_request' }}
84- uses : peaceiris/actions-gh-pages@v4
85- with :
86- github_token : ${{ secrets.GITHUB_TOKEN }}
87- publish_branch : coverage-info
88- publish_dir : .
89- include_files : coverage-badge.svg, coverage.xml
90- commit_message : " Update coverage badge [skip ci]"
9180
9281 - name : Coverage diff on PR
93- if : ${{ env.COVERAGE == 'true' && github.event_name == 'pull_request' }}
94- run : echo "TODO"
95- >>>>>>> cd008e2 (Outline steps I think are necessary for coverage diffs)
82+
83+ if : ${{ env.COVERAGE == 'true' && github.event_name == 'pull_request' && github.base_ref == 'main'}}
84+ uses : ./.github/jobs/coverage_diff
85+
You can’t perform that action at this time.
0 commit comments