Skip to content

Commit e591aaa

Browse files
authored
Generate HTML coverage report only on failure (#3564)
1 parent 56b0e6f commit e591aaa

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

.github/workflows/test.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,17 +505,24 @@ jobs:
505505
merge-multiple: true
506506
- name: Combine and report coverage
507507
id: coverage
508-
run: tox run -e coverage --skip-uv-sync --skip-pkg-install
508+
run: |
509+
.tox/coverage/bin/coverage combine
510+
.tox/coverage/bin/coverage xml -o .tox/coverage.xml
511+
.tox/coverage/bin/diff-cover --compare-branch "${DIFF_AGAINST:-origin/main}" .tox/coverage.xml
512+
.tox/coverage/bin/coverage report --fail-under=100 --skip-covered --show-missing
509513
continue-on-error: true
510514
env:
511-
UV_PYTHON_PREFERENCE: only-managed
515+
COVERAGE_FILE: .tox/.coverage
512516
- name: Show uncovered lines on failure
513517
if: steps.coverage.outcome == 'failure'
514518
run: |
515519
echo "::error::Coverage check failed. Lines not covered:"
516520
COVERAGE_FILE=.tox/.coverage .tox/coverage/bin/coverage report --show-missing --fail-under=0 | grep -v "100%"
521+
- name: Generate HTML report on failure
522+
if: steps.coverage.outcome == 'failure'
523+
run: COVERAGE_FILE=.tox/.coverage .tox/coverage/bin/coverage html --fail-under=0 -d .tox/htmlcov
517524
- name: Upload HTML report
518-
if: always()
525+
if: steps.coverage.outcome == 'failure'
519526
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
520527
with:
521528
name: html-report

0 commit comments

Comments
 (0)