Skip to content

Conversation

@aleguy02
Copy link

@aleguy02 aleguy02 commented Oct 2, 2025

Description

This PR automates 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

Checklist

  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits. Please uncheck this if you prefer to squash the commits yourself.

Additional Notes

I didn't create a changelog since the documented behavior of pytest was not modified.

@bluetech bluetech added the skip news used on prs to opt out of the changelog requirement label Oct 3, 2025
Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a great start! I normally avoid adding --junitxml= (even if the path value is empty) to normal/local invocations. Instead, I like adding the entire CLI flag in the CI definition: https://github.com/cherrypy/cheroot/blob/06a6d67e549ccaefe332cd0539c21e1483031071/.github/workflows/ci-cd.yml#L786.

I've made suggestions below. Let's see if that works..


As for the change note, sometimes it's a good idea to use the contrib type for such changes.

CI
JUNIT_XML_PATH
setenv =
_PYTEST_TOX_DEFAULT_POSARGS={env:_PYTEST_TOX_POSARGS_DOCTESTING:} {env:_PYTEST_TOX_POSARGS_LSOF:} {env:_PYTEST_TOX_POSARGS_XDIST:} {env:_PYTEST_FILES:}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend integrating it here instead

Suggested change
_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:}

if: "! matrix.use_coverage"
shell: bash
env:
JUNIT_XML_PATH: junit-${{ matrix.name }}.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JUNIT_XML_PATH: junit-${{ matrix.name }}.xml
_PYTEST_TOX_POSARGS_JUNIT: --junitxml=junit-${{ matrix.name }}.xml

if: "matrix.use_coverage"
shell: bash
env:
JUNIT_XML_PATH: junit-${{ matrix.name }}.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JUNIT_XML_PATH: junit-${{ matrix.name }}.xml
_PYTEST_TOX_POSARGS_JUNIT: --junitxml=junit-${{ matrix.name }}.xml

Comment on lines +45 to +46
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest {posargs:{env:_PYTEST_TOX_DEFAULT_POSARGS:}} --junitxml={env:JUNIT_XML_PATH}
doctesting: {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules --pyargs _pytest --junitxml={env:JUNIT_XML_PATH}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest {posargs:{env:_PYTEST_TOX_DEFAULT_POSARGS:}} --junitxml={env:JUNIT_XML_PATH}
doctesting: {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules --pyargs _pytest --junitxml={env:JUNIT_XML_PATH}
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest {posargs:{env:_PYTEST_TOX_DEFAULT_POSARGS:}}
doctesting: {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules {env:_PYTEST_TOX_POSARGS_JUNIT:} --pyargs _pytest

TERM
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST
CI
JUNIT_XML_PATH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JUNIT_XML_PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news used on prs to opt out of the changelog requirement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TODO] Upload JUnit reports to Codecov

3 participants