From 4c11ce61740721029ceee2eba4052fc9e1d50f1a Mon Sep 17 00:00:00 2001 From: Alejandro Villate <145073504+aleguy02@users.noreply.github.com> Date: Wed, 11 Feb 2026 11:28:01 -0500 Subject: [PATCH] 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 (cherry picked from commit bda18de6ab84023bd08baf620bc2430f41eb4b5c) --- .github/workflows/test.yml | 12 ++++++++++++ AUTHORS | 1 + changelog/12689.contrib.rst | 5 +++++ tox.ini | 4 ++-- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 changelog/12689.contrib.rst diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 394ea9b33d7..b7f0634d08d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -277,11 +277,15 @@ jobs: - name: Test without coverage if: "! matrix.use_coverage" shell: bash + env: + _PYTEST_TOX_POSARGS_JUNIT: --junitxml=junit.xml run: tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz` - name: Test with coverage if: "matrix.use_coverage" shell: bash + env: + _PYTEST_TOX_POSARGS_JUNIT: --junitxml=junit.xml run: tox run -e ${{ matrix.tox_env }}-coverage --installpkg `find dist/*.tar.gz` - name: Generate coverage report @@ -296,6 +300,14 @@ jobs: files: ./coverage.xml verbose: true + - name: Upload JUnit report to Codecov + uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 + with: + fail_ci_if_error: false + files: junit.xml + report_type: test_results + verbose: true + check: # This job does nothing and is only used for the branch protection if: always() diff --git a/AUTHORS b/AUTHORS index 8b307cd5626..fa6bc58c52f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -14,6 +14,7 @@ Ahn Ki-Wook Akhilesh Ramakrishnan Akiomi Kamakura Alan Velasco +Alejandro Villate Alessio Izzo Alex Jones Alex Lambson diff --git a/changelog/12689.contrib.rst b/changelog/12689.contrib.rst new file mode 100644 index 00000000000..81bb5577d97 --- /dev/null +++ b/changelog/12689.contrib.rst @@ -0,0 +1,5 @@ +The test reports are now published to Codecov from GitHub Actions. +The test statistics is visible `on the web interface +`__. + +-- by :user:`aleguy02` diff --git a/tox.ini b/tox.ini index 70b439f7573..e2e09fa8b7f 100644 --- a/tox.ini +++ b/tox.ini @@ -62,7 +62,7 @@ description = doctesting: including doctests commands = {env:_PYTEST_TOX_COVERAGE_RUN:} pytest {posargs:{env:_PYTEST_TOX_DEFAULT_POSARGS:}} - doctesting: {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules --pyargs _pytest + doctesting: {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules {env:_PYTEST_TOX_POSARGS_JUNIT:} --pyargs _pytest coverage: coverage combine coverage: coverage report -m passenv = @@ -71,7 +71,7 @@ passenv = TERM CI setenv = - _PYTEST_TOX_DEFAULT_POSARGS={env:_PYTEST_TOX_POSARGS_DOCTESTING:} {env:_PYTEST_TOX_POSARGS_LSOF:} {env:_PYTEST_TOX_POSARGS_XDIST:} {env:_PYTEST_FILES:} + _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:} # See https://docs.python.org/3/library/io.html#io-encoding-warning # If we don't enable this, neither can any of our downstream users!