Skip to content

Commit cbb34a9

Browse files
authored
Merge pull request #154 from MarcoGorelli/ci-coverage
CI: add a coverage job that reports line and branch coverage (#87)
2 parents dd8a6d8 + f95ad6e commit cbb34a9

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,46 @@ jobs:
117117
python -m pytest --pyargs benchx -ra
118118
uv pip install "$(ls "$GITHUB_WORKSPACE"/dist/*.whl)[parquet,test]"
119119
python -m pytest --pyargs benchx -ra
120+
121+
# Line and branch coverage of the suite (#87), as a starting point for finding dead code:
122+
# the table is in the job summary, the HTML report in the coverage-html artifact. Nothing
123+
# fails on the number. pyproject.toml ([tool.coverage]) says what is measured, and why a
124+
# few files look less covered than they are.
125+
coverage:
126+
name: coverage / py3.13
127+
runs-on: ubuntu-latest
128+
steps:
129+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
130+
131+
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
132+
with:
133+
enable-cache: true
134+
cache-dependency-glob: uv.lock
135+
136+
- name: Install Python 3.13
137+
run: uv python install 3.13
138+
139+
- name: Install package and test dependencies
140+
run: uv sync --extra parquet --extra test --python 3.13
141+
142+
- name: Run tests under coverage
143+
run: uv run --extra parquet --extra test --with coverage --python 3.13 coverage run -m pytest tests -ra
144+
145+
- name: Report
146+
if: always()
147+
run: |
148+
uv run --extra parquet --extra test --with coverage --python 3.13 coverage report
149+
{
150+
echo "## Coverage"
151+
echo
152+
uv run --extra parquet --extra test --with coverage --python 3.13 coverage report --format=markdown
153+
} >> "$GITHUB_STEP_SUMMARY"
154+
uv run --extra parquet --extra test --with coverage --python 3.13 coverage html
155+
156+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
157+
if: always()
158+
with:
159+
name: coverage-html
160+
path: htmlcov/
161+
if-no-files-found: warn
162+
retention-days: 14

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ dist/
1111
# generated by tools/gen_docs.py
1212
docs/index.md
1313
docs/schemas/
14+
.coverage
15+
.coverage.*
16+
htmlcov/

‎pyproject.toml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,17 @@ packages = ["src/benchx"]
4646
# package is the source directory, and the checkout has tests/.
4747
[tool.hatch.build.targets.wheel.force-include]
4848
"tests" = "benchx/tests"
49+
50+
# `coverage run -m pytest tests`, then `coverage report`; CI runs it in the coverage job of
51+
# tests.yml. Only the test process is measured: the subprocesses the tests start (`bx`, the
52+
# harness workers) mostly run code the tests also reach in-process, and measuring them too
53+
# (`patch = ["subprocess"]`) barely moves any file's number while slowing the run a lot.
54+
# asv_runtime.py and benchx_params.py are run as copies beside each case's driver, so
55+
# coverage cannot see what the workers run of them: their misses are not dead code.
56+
[tool.coverage.run]
57+
source_pkgs = ["benchx"]
58+
branch = true
59+
60+
[tool.coverage.report]
61+
skip_covered = true
62+
sort = "cover"

0 commit comments

Comments
 (0)