Skip to content

Commit b758f6e

Browse files
authored
Enable junit.xml reporting to codecov.io (#326)
1 parent f57a025 commit b758f6e

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ htmlcov/
4343
.coverage
4444
.coverage.*
4545
.cache
46+
junit.xml
4647
nosetests.xml
4748
coverage.xml
4849
*.cover
50+
*.lcov
4951
*.py,cover
5052
.hypothesis/
5153
.pytest_cache/

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ fail-on = [
318318
[tool.pytest.ini_options]
319319
addopts = "-ra --showlocals --durations=10"
320320
cache_dir = "./.cache/.pytest"
321+
junit_family = "legacy" # see https://docs.codecov.com/docs/test-analytics
321322
testpaths = "tests"
322323
tmp_path_retention_policy = "failed"
323324
verbosity_assertions = 2

tools/report-coverage

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
coverage combine -q "--data-file=${TOX_ENV_DIR}/.coverage" "${TOX_ENV_DIR}"/.coverage.*
4+
coverage xml "--data-file=${TOX_ENV_DIR}/.coverage" -o "${TOX_ENV_DIR}/coverage.xml" --ignore-errors --fail-under=0
5+
COVERAGE_FILE="${TOX_ENV_DIR}/.coverage" coverage lcov --fail-under=0 --ignore-errors -q
6+
COVERAGE_FILE="${TOX_ENV_DIR}/.coverage" coverage report --fail-under=0 --ignore-errors

tox.ini

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ commands_pre =
4747
sh -c "rm -f {envdir}/.coverage* 2>/dev/null || true"
4848
commands =
4949
python -c 'import pathlib; pathlib.Path("{env_site_packages_dir}/cov.pth").write_text("import coverage; coverage.process_startup()")'
50-
coverage run -m pytest {posargs:-n auto}
51-
coverage combine -q --data-file={env:COVERAGE_COMBINED}
52-
coverage xml --data-file={env:COVERAGE_COMBINED} -o {envdir}/coverage.xml --fail-under=0
53-
coverage lcov --data-file={env:COVERAGE_COMBINED} -o {toxinidir}/.cache/.coverage/lcov.info --fail-under=0
54-
coverage report --data-file={env:COVERAGE_COMBINED}
50+
coverage run -m pytest {posargs:-n auto --junitxml=./junit.xml}
51+
commands_post =
52+
{py,py310,py311,py312,py313}: ./tools/report-coverage
5553
allowlist_externals =
54+
./tools/report-coverage
5655
git
5756
rm
5857
sh

0 commit comments

Comments
 (0)