Skip to content

Commit c89d166

Browse files
committed
Adjust CI coverage reporting & tox coverage config
Capture tox output to a file and append the coverage summary to the GitHub Actions job summary only for the ubuntu-latest / Python 3.12 matrix. Restrict Codecov uploads to that same matrix for PRs targeting main/master and point the upload at a per-environment coverage XML (coverage.py312.xml). Move coverage settings into tox.ini so tests generate env-specific .coverage files (COVERAGE_FILE) and XML reports ({toxinidir}/.coverage.{envname}.xml) for more reliable CI artifact handling.
1 parent ea476a1 commit c89d166

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

.github/workflows/testing-ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ jobs:
5555
5656
- name: Run tests (exclude hardware) with coverage via tox
5757
run: |
58-
tox -q
58+
tox -q | tee tox-output.log
5959
6060
- name: Append Coverage Summary to Job
61-
if: always()
61+
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
6262
shell: bash
6363
run: |
64-
python -m pip install -U coverage
6564
echo "## Coverage Summary" >> "$GITHUB_STEP_SUMMARY"
66-
echo "" >> "$GITHUB_STEP_SUMMARY"
6765
echo '```text' >> "$GITHUB_STEP_SUMMARY"
68-
python -m coverage report -m >> "$GITHUB_STEP_SUMMARY" || true
66+
# Pull the coverage table from tox output:
67+
sed -n '/^Name\s\+Stmts\s\+Miss\s\+Cover/,$p' tox-output.txt >> "$GITHUB_STEP_SUMMARY" || true
6968
echo '```' >> "$GITHUB_STEP_SUMMARY"
7069
70+
7171
- name: Upload coverage to Codecov
72-
if: github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'master')
72+
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' && github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'master')
7373
uses: codecov/codecov-action@v5
7474
with:
75-
files: ./coverage.xml
75+
files: ./coverage.py312.xml
7676
fail_ci_if_error: true

tox.ini

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ description = Unit + smoke tests (exclude hardware) with coverage
1111
package = wheel
1212
extras = test
1313

14-
# Keep behavior aligned with your GitHub Actions job:
15-
commands =
16-
pytest -m "not hardware" --maxfail=1 --disable-warnings \
17-
--cov=dlclivegui --cov-report=xml --cov-report=term-missing {posargs}
1814

1915
# Helpful defaults for headless CI runs (Qt/OpenCV):
2016
setenv =
@@ -23,6 +19,15 @@ setenv =
2319
QT_OPENGL = software
2420
# Can help avoid some Windows/OpenCV capture backend flakiness when tests touch video I/O:
2521
OPENCV_VIDEOIO_PRIORITY_MSMF = 0
22+
COVERAGE_FILE = {toxinidir}/.coverage.{envname}
23+
24+
# Keep behavior aligned with your GitHub Actions job:
25+
commands =
26+
pytest -m "not hardware" --maxfail=1 --disable-warnings \
27+
--cov=dlclivegui
28+
--cov-report=xml:{toxinidir}/.coverage.{envname}.xml
29+
--cov-report=term-missing
30+
{posargs}
2631

2732
# Let CI variables pass through (useful for debugging and some GUI/headless setups):
2833
passenv =

0 commit comments

Comments
 (0)