Skip to content

Commit e52b233

Browse files
committed
Coverage: Implement fail_under
1 parent ac80bb7 commit e52b233

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,26 @@ jobs:
178178
ls -aR .coverage*
179179
coverage combine .coverage*
180180
echo "Creating coverage report..."
181-
# Create a coverage report (console)
182-
coverage report
183-
# Create xml file for further processing
184-
coverage xml
181+
# Create xml file for further processing; Create even if below minimum
182+
coverage xml --fail-under=0
185183
186184
# For future use in case we want to add a PR comment for 3rd party PRs which requires
187185
# a workflow with elevated PR write permissions. Move below steps into a separate job.
188186
- name: Archive code coverage report
187+
id: cov_xml_upload
189188
uses: actions/upload-artifact@v4
190189
with:
191190
name: coverage
192191
path: coverage.xml
192+
- name: Code Coverage Report (console)
193+
run: |
194+
# Create a coverage report (console), respects fail_under in pyproject.toml
195+
coverage report
193196
194197
- name: Code Coverage Report
195198
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
199+
# Create markdown file even if coverage report fails due to fail_under
200+
if: ${{ always() && steps.cov_xml_upload.outputs.artifact-id != '' }}
196201
with:
197202
filename: coverage.xml
198203
badge: true
@@ -202,7 +207,7 @@ jobs:
202207
hide_complexity: true
203208
indicators: true
204209
output: both # console, file or both
205-
thresholds: '90 95'
210+
thresholds: '96 98'
206211

207212
- name: Add Coverage PR Comment
208213
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.3

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ extra-standard-library = ["tomllib"]
122122
known-first-party = ["typing_extensions", "_typed_dict_test_helper"]
123123

124124
[tool.coverage.report]
125+
fail_under = 96
125126
show_missing = true
126127
# Omit files that are created in temporary directories during tests.
127128
# If not explicitly omitted they will result in warnings in the report.

0 commit comments

Comments
 (0)