Skip to content

Commit bda18de

Browse files
authored
Upload junit reports codecov (#13778)
Automate uploading JUnit reports to codecov in the test pipeline. An example pipeline run with the changes can be found here (https://github.com/aleguy02/fork-pytest/actions/runs/18184970357). An example of what the codecov UI looks like with these changes can be found here (https://app.codecov.io/gh/aleguy02/fork-pytest/tests). Closes #12689
1 parent e77b9a4 commit bda18de

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,15 @@ jobs:
277277
- name: Test without coverage
278278
if: "! matrix.use_coverage"
279279
shell: bash
280+
env:
281+
_PYTEST_TOX_POSARGS_JUNIT: --junitxml=junit.xml
280282
run: tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`
281283

282284
- name: Test with coverage
283285
if: "matrix.use_coverage"
284286
shell: bash
287+
env:
288+
_PYTEST_TOX_POSARGS_JUNIT: --junitxml=junit.xml
285289
run: tox run -e ${{ matrix.tox_env }}-coverage --installpkg `find dist/*.tar.gz`
286290

287291
- name: Upload coverage to Codecov
@@ -292,6 +296,14 @@ jobs:
292296
files: ./coverage.xml
293297
verbose: true
294298

299+
- name: Upload JUnit report to Codecov
300+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7
301+
with:
302+
fail_ci_if_error: false
303+
files: junit.xml
304+
report_type: test_results
305+
verbose: true
306+
295307
check: # This job does nothing and is only used for the branch protection
296308
if: always()
297309

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Ahn Ki-Wook
1414
Akhilesh Ramakrishnan
1515
Akiomi Kamakura
1616
Alan Velasco
17+
Alejandro Villate
1718
Alessio Izzo
1819
Alex Jones
1920
Alex Lambson

changelog/12689.contrib.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The test reports are now published to Codecov from GitHub Actions.
2+
The test statistics is visible `on the web interface
3+
<https://app.codecov.io/gh/pytest-dev/pytest/tests>`__.
4+
5+
-- by :user:`aleguy02`

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ description =
6262
doctesting: including doctests
6363
commands =
6464
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest {posargs:{env:_PYTEST_TOX_DEFAULT_POSARGS:}}
65-
doctesting: {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules --pyargs _pytest
65+
doctesting: {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules {env:_PYTEST_TOX_POSARGS_JUNIT:} --pyargs _pytest
6666
coverage: coverage combine
6767
coverage: coverage report -m
6868
# Run `coverage xml` only on CI.
@@ -73,7 +73,7 @@ passenv =
7373
TERM
7474
CI
7575
setenv =
76-
_PYTEST_TOX_DEFAULT_POSARGS={env:_PYTEST_TOX_POSARGS_DOCTESTING:} {env:_PYTEST_TOX_POSARGS_LSOF:} {env:_PYTEST_TOX_POSARGS_XDIST:} {env:_PYTEST_FILES:}
76+
_PYTEST_TOX_DEFAULT_POSARGS={env:_PYTEST_TOX_POSARGS_DOCTESTING:} {env:_PYTEST_TOX_POSARGS_JUNIT:} {env:_PYTEST_TOX_POSARGS_LSOF:} {env:_PYTEST_TOX_POSARGS_XDIST:} {env:_PYTEST_FILES:}
7777

7878
# See https://docs.python.org/3/library/io.html#io-encoding-warning
7979
# If we don't enable this, neither can any of our downstream users!

0 commit comments

Comments
 (0)