Skip to content

Commit e9a5587

Browse files
authored
Enable junit.xml reporting to codecov.io (#569)
1 parent f7d0c3b commit e9a5587

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ htmlcov/
4646
.coverage
4747
.coverage.*
4848
.cache
49-
nosetests.xml
49+
coverage.lcov
5050
coverage.xml
51+
junit.xml
52+
nosetests.xml
5153
*.cover
5254
*.py,cover
5355
.hypothesis/

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ fail-on = [
327327
[tool.pytest.ini_options]
328328
addopts = "-ra --showlocals --durations=10 -p no:pytest-ansible"
329329
cache_dir = "./.cache/.pytest"
330+
junit_family = "legacy" # see https://docs.codecov.com/docs/test-analytics
330331
log_cli = true
331332
log_cli_level = "WARNING"
332333
testpaths = "tests"

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
@@ -59,12 +59,11 @@ commands_pre =
5959
commands =
6060
devel: sh -c "pip freeze | grep '@'"
6161
python -c 'import pathlib; pathlib.Path("{env_site_packages_dir}/cov.pth").write_text("import coverage; coverage.process_startup()")'
62-
coverage run -m pytest {posargs:-n auto}
63-
coverage combine -q --data-file={env:COVERAGE_COMBINED}
64-
coverage xml --data-file={env:COVERAGE_COMBINED} -o {envdir}/coverage.xml --fail-under=0
65-
coverage lcov --data-file={env:COVERAGE_COMBINED} -o {toxinidir}/.cache/.coverage/lcov.info --fail-under=0
66-
coverage report --data-file={env:COVERAGE_COMBINED}
62+
coverage run -m pytest {posargs:-n auto --junitxml=./junit.xml}
63+
commands_post =
64+
devel, py{,310,311,312,313}: ./tools/report-coverage
6765
allowlist_externals =
66+
./tools/report-coverage
6867
git
6968
rm
7069
sh

0 commit comments

Comments
 (0)