Fix the combined coverage report - #238
Conversation
e352897 to
579c0b1
Compare
579c0b1 to
95272c2
Compare
|
When using the matrix execution we can not collect the combined coverage from each python version. |
|
https://hynek.me/articles/ditch-codecov-python/ has a suggestion of how to do this |
3eeac16 to
9730e11
Compare
|
FYI, the file |
619000e to
338da05
Compare
Build job: - add upload artifact step after each test in the matrix. - update coveralls step to upload partial data. Converage job (new): - complete the coveralls in the coverage job. - add step to download all uploaded artifacts - add step to combine coverage data, create report and fail if not enough - add step to upload html report if coverage is not enough
338da05 to
f3704f2
Compare
Thank you @dataflake for the reminder. Yes, I know that this should not be changed directly. I will convert this PR to a draft to avoid confusion. |
|
I think this approach presented here is promising. It requires some changes in I currently do not have the time and energy to push |
The `coverage` tox environment now combines the coverage data of all
supported Python versions instead of measuring a single one, and enforces
100% coverage.
Previously the `combined-coverage` environment was supposed to do this, but
it depended on the `coverage` environment and both wrote to `.coverage`, so
its `coverage erase` threw away the data it was meant to combine -- including
the Sphinx doctest coverage, which was measured nowhere else. It also omitted
`py315` from `depends` and hard-coded `--fail-under=100` on the command line,
contradicting the `fail_under` in `pyproject.toml`.
Changes:
- Turn `[testenv:coverage]` into the combining environment via the existing
`coverage-command` / `coverage-additional` zope.meta options, and drop
`[testenv:combined-coverage]`. No template changes were needed.
- Add `py315` to `depends`. `depends` orders environments in sequential runs
too, not just under `tox -p`, so `coverage` runs last regardless of its
position in the envlist.
- Disable the coverage threshold for the per-version environments: a single
Python version cannot reach 100%, only the combination can.
- Set `fail_under` to 100 and reach it:
- add the missing test for an `ast.Expression` body in
`compile_restricted_function` (`compile.py` lines 179-181),
- exclude the `typing.overload` stubs in `Limits.py` and the
`typing.Protocol` stub in `Eval.py`, whose bodies never execute at
runtime by design.
- Add `relative_files = true` so the data stays portable across machines.
Combined coverage is now 100.00% over py310-py315 plus py311-datetime; a
single version reaches only 99.76%.
CI still measures a single Python version -- moving it to the combined report
needs new zope.meta template support and follows separately.
Based on the analysis in PR #238 by Rudá Porto Filgueiras.
Reworked on top of current
master.The original 2022 branch could not be rebased: it targeted Python 3.6–3.11,
[coverage:run]sections that have since moved intopyproject.toml,actions/*@v2, and a pip-based CI that has since moved touv. The analysisin the original PR was correct and is what this implements — credit to
@rudaporto.
The bug
combined-coveragedepended on thecoverageenvironment and both wrote to.coverage, so itscoverage erasedestroyed the data it was meant tocombine — including the Sphinx doctest coverage, which was measured nowhere
else. It also omitted
py315fromdependsand hard-coded--fail-under=100on the command line, contradictingfail_under = 97.1inpyproject.toml. On top of that, thecoverageenvironment re-ran the wholetest suite that the per-version environments had just run.
What changed
[testenv:coverage]is now the combining environment, and[testenv:combined-coverage]is gone. This needed no zope.meta templatechanges — the existing
coverage-commandandcoverage-additionaloptions already produce exactly the required environment.
py315added todepends. Note thatdependsorders environments insequential runs too, not only under
tox -p, socoverageruns lastregardless of its position in the envlist.
(
--cov-fail-under=0): a single Python version cannot reach 100 %, only thecombination can. The threshold is enforced once, on the combined report.
fail_underraised to 100 and actually met:ast.Expressionbody incompile_restricted_function(compile.pylines 179–181 were untested),typing.overloadstubs inLimits.pyand thetyping.Protocolstub inEval.py, whose bodies never execute at runtimeby design.
relative_files = trueso the data stays portable across machines.Result
Combined coverage is 100.00 % over py310–py315 plus py311-datetime.
A single version reaches only 99.76 %, which is the whole point: the
version-conditional code (
_types.py, the t-string andexcept*tests) canonly be covered by the union.
Verified locally:
tox -e lint,docs,py310,py311,py312,py313,py314,py315,py311-datetime,coverageand
release-checkall pass, sequentially and undertox -p auto. Combiningfrom a single version's data correctly fails the gate at 99.76 %.
Scope
CI still measures a single Python version. Moving CI onto the combined report
requires new zope.meta template support (there is no hook to add a step after
Test, nor to add a job), so it follows separately — see the issue filedagainst
zopefoundation/meta.— Comment created by Claude