Skip to content

Commit 7ef8036

Browse files
authored
Enable junit.xml reporting to codecov.io (#486)
1 parent 4fc4eec commit 7ef8036

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ htmlcov/
4545
.nox/
4646
.coverage
4747
.cache
48+
junit.xml
4849
nosetests.xml
4950
coverage.xml
5051
*.cover

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ filterwarnings = [
357357
# https://github.com/ansible/ansible/issues/81906
358358
"ignore:'importlib.abc.TraversableResources' is deprecated and slated for removal in Python 3.14:DeprecationWarning"
359359
]
360+
junit_family = "legacy" # see https://docs.codecov.com/docs/test-analytics
360361
testpaths = ["test"]
361362

362363
[tool.ruff]

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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ commands =
5050
sh -c "ansible --version | head -n 1"
5151
# We add coverage options but not making them mandatory as we do not want to force
5252
# pytest users to run coverage when they just want to run a single test with `pytest -k test`
53-
coverage run -m pytest {posargs:}
53+
coverage run -m pytest {posargs:--junitxml=./junit.xml}
54+
commands_post =
5455
# needed for upload to codecov.io
55-
{py,py310,py311,py312,py313}: sh -c "coverage combine -q --data-file={envdir}/.coverage {envdir}/.coverage.* && coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --ignore-errors --fail-under=0 && COVERAGE_FILE={envdir}/.coverage coverage lcov --fail-under=0 --ignore-errors -q && COVERAGE_FILE={envdir}/.coverage coverage report --fail-under=0 --ignore-errors"
56-
# lcov needed for vscode integration due to https://github.com/ryanluker/vscode-coverage-gutters/issues/403
57-
56+
{py,py310,py311,py312,py313}: ./tools/report-coverage
5857
passenv =
5958
CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437
6059
FORCE_COLOR
@@ -85,6 +84,7 @@ allowlist_externals =
8584
ansible
8685
git
8786
sh
87+
./tools/report-coverage
8888
# https://tox.wiki/en/latest/upgrading.html#editable-mode
8989
package = editable
9090
uv_seed = true

0 commit comments

Comments
 (0)