File tree 1 file changed +17
-3
lines changed 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -87,16 +87,30 @@ jobs:
87
87
with :
88
88
name : coverage-data
89
89
90
- - name : Fetch main for coverage diff
90
+ - name : Determine base branch for comparison
91
+ id : base-branch
91
92
run : |
92
- git fetch --no-tags --prune origin main
93
+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
94
+ # For PRs, use the remote tracking branch
95
+ COMPARE_BRANCH="origin/${{ github.base_ref }}"
96
+ echo "COMPARE_BRANCH=$COMPARE_BRANCH" >> $GITHUB_ENV
97
+ else
98
+ # For push events, compare against the parent commit
99
+ COMPARE_BRANCH="${{ github.event.before }}"
100
+ echo "COMPARE_BRANCH=$COMPARE_BRANCH" >> $GITHUB_ENV
101
+ fi
102
+ echo "Using $COMPARE_BRANCH for coverage comparison"
103
+
104
+ - name : Fetch base branch for coverage diff
105
+ run : |
106
+ git fetch --no-tags --prune origin ${COMPARE_BRANCH#origin/}
93
107
94
108
- name : Combine coverage & fail if it's <100%.
95
109
run : |
96
110
python -m coverage combine
97
111
python -m coverage html --skip-covered --skip-empty
98
112
python -m coverage xml
99
- diff-cover coverage.xml --markdown-report=coverage.md --fail-under=100 || (cat coverage.md >> $GITHUB_STEP_SUMMARY && exit 1)
113
+ diff-cover coverage.xml --compare-branch=$COMPARE_BRANCH -- markdown-report=coverage.md --fail-under=100 || (cat coverage.md >> $GITHUB_STEP_SUMMARY && exit 1)
100
114
101
115
- name : Upload HTML report if check failed.
102
116
uses : actions/upload-artifact@v4
You can’t perform that action at this time.
0 commit comments