Skip to content

Commit c36cb2f

Browse files
authored
Enable junit.xml reporting to codecov.io (#408)
1 parent c5a273e commit c36cb2f

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
@@ -324,6 +324,7 @@ fail-on = [
324324
[tool.pytest.ini_options]
325325
addopts = "-ra --showlocals --durations=10"
326326
cache_dir = "./.cache/.pytest"
327+
junit_family = "legacy" # see https://docs.codecov.com/docs/test-analytics
327328
norecursedirs = "tests/fixtures"
328329
testpaths = "tests"
329330
tmp_path_retention_policy = "failed"

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 --ignore-errors

tox.ini

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ commands_pre =
4040
py{,310,311,312,313}: sh -c "npm add -D @devcontainers/cli"
4141
commands =
4242
python -c 'import pathlib; pathlib.Path("{env_site_packages_dir}/cov.pth").write_text("import coverage; coverage.process_startup()")'
43-
coverage run -m pytest {posargs:-n auto}
44-
coverage combine -q --data-file={env:COVERAGE_COMBINED}
45-
coverage xml --data-file={env:COVERAGE_COMBINED} -o {envdir}/coverage.xml --fail-under=0
46-
coverage lcov --data-file={env:COVERAGE_COMBINED} -o {toxinidir}/.cache/.coverage/lcov.info --fail-under=0
47-
coverage report --data-file={env:COVERAGE_COMBINED}
43+
coverage run -m pytest {posargs:-n auto --junitxml=./junit.xml}
44+
commands_post =
45+
py{,310,311,312,313}: ./tools/report-coverage
4846
allowlist_externals =
47+
./tools/report-coverage
4948
git
5049
rm
5150
sh

0 commit comments

Comments
 (0)