From 0e88b87756560a2323bbfce9843e0f94e24e8e4c Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Tue, 8 Apr 2025 22:24:02 +0300 Subject: [PATCH 01/10] Add JUnit test report upload to Codecov for improved test result visibility --- .github/workflows/test.yml | 4 ++-- changelog/12689.improvement.rst | 1 + tox.ini | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelog/12689.improvement.rst diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 44c9d68c03d..e4dc14b5e7a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -260,12 +260,12 @@ jobs: if: "matrix.use_coverage" run: python -m coverage xml - - name: Upload coverage to Codecov + - name: Upload coverage and test results to Codecov if: "matrix.use_coverage" uses: codecov/codecov-action@v5 with: fail_ci_if_error: false - files: ./coverage.xml + files: ./coverage.xml,./report.xml verbose: true check: # This job does nothing and is only used for the branch protection diff --git a/changelog/12689.improvement.rst b/changelog/12689.improvement.rst new file mode 100644 index 00000000000..837bdab9140 --- /dev/null +++ b/changelog/12689.improvement.rst @@ -0,0 +1 @@ +Upload JUnit test reports to Codecov to enable test result visibility in the Codecov UI. diff --git a/tox.ini b/tox.ini index 850def411cb..7dfed4a3d57 100644 --- a/tox.ini +++ b/tox.ini @@ -62,6 +62,7 @@ setenv = coverage: _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess coverage: COVERAGE_FILE={toxinidir}/.coverage coverage: COVERAGE_PROCESS_START={toxinidir}/.coveragerc + coverage: PYTEST_ADDOPTS=--junitxml=report.xml doctesting: _PYTEST_TOX_POSARGS_DOCTESTING=doc/en From cbd7a7809080dbfb87e3c4e303dcca2bb8abeda2 Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Thu, 10 Apr 2025 18:11:20 +0300 Subject: [PATCH 02/10] Add report type configuration for test results in CI workflow --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4dc14b5e7a..c887f5f4e17 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -267,6 +267,7 @@ jobs: fail_ci_if_error: false files: ./coverage.xml,./report.xml verbose: true + report_type: "test_results" check: # This job does nothing and is only used for the branch protection if: always() From f4e05612cdc1d13ead515c387facf934deeba1e7 Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Thu, 10 Apr 2025 19:15:01 +0300 Subject: [PATCH 03/10] Refactor Codecov upload steps in CI workflow for clarity and separation --- .github/workflows/test.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c887f5f4e17..708777a69a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -260,12 +260,20 @@ jobs: if: "matrix.use_coverage" run: python -m coverage xml - - name: Upload coverage and test results to Codecov + - name: Upload coverage to Codecov if: "matrix.use_coverage" uses: codecov/codecov-action@v5 with: fail_ci_if_error: false - files: ./coverage.xml,./report.xml + files: ./coverage.xml + verbose: true + + - name: Upload test results to Codecov + if: "matrix.use_coverage" + uses: codecov/codecov-action@v5 + with: + fail_ci_if_error: false + files: ./report.xml verbose: true report_type: "test_results" From 0a30a88889e6fd43072b012192839d345b720978 Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Fri, 11 Apr 2025 13:26:10 +0300 Subject: [PATCH 04/10] Rename improvement documentation and update test result upload configuration in CI workflow Rename improvement documentation and update test result upload configuration in CI workflow --- .github/workflows/test.yml | 7 +++---- changelog/{12689.improvement.rst => 12689.contrib.rst} | 0 tox.ini | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) rename changelog/{12689.improvement.rst => 12689.contrib.rst} (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 708777a69a6..fa6bc722055 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -269,13 +269,12 @@ jobs: verbose: true - name: Upload test results to Codecov - if: "matrix.use_coverage" - uses: codecov/codecov-action@v5 + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 with: fail_ci_if_error: false - files: ./report.xml + files: ./junit.xml verbose: true - report_type: "test_results" check: # This job does nothing and is only used for the branch protection if: always() diff --git a/changelog/12689.improvement.rst b/changelog/12689.contrib.rst similarity index 100% rename from changelog/12689.improvement.rst rename to changelog/12689.contrib.rst diff --git a/tox.ini b/tox.ini index 7dfed4a3d57..d7e37a4bade 100644 --- a/tox.ini +++ b/tox.ini @@ -62,7 +62,7 @@ setenv = coverage: _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess coverage: COVERAGE_FILE={toxinidir}/.coverage coverage: COVERAGE_PROCESS_START={toxinidir}/.coveragerc - coverage: PYTEST_ADDOPTS=--junitxml=report.xml + coverage: PYTEST_ADDOPTS=--junitxml=junit.xml -o junit_family=legacy doctesting: _PYTEST_TOX_POSARGS_DOCTESTING=doc/en From 49fad269bbb4450200ac151c31327bc94000be22 Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Fri, 11 Apr 2025 14:57:01 +0300 Subject: [PATCH 05/10] Update test_config.py to include junit_family option in override settings --- testing/test_config.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/testing/test_config.py b/testing/test_config.py index bb08c40fef4..a9e6a705bb9 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -2021,8 +2021,12 @@ def test_override_ini_does_not_contain_paths( ) -> None: """Check that -o no longer swallows all options after it (#3103)""" config = _config_for_test - config._preparse(["-o", "cache_dir=/cache", "/some/test/path"]) - assert config._override_ini == ["cache_dir=/cache"] + config._preparse( + ["-o", "cache_dir=/cache", "junit_family=legacy", "/some/test/path"] + ) + assert sorted(set(config._override_ini)) == sorted( + ["cache_dir=/cache", "junit_family=legacy"] + ) def test_multiple_override_ini_options(self, pytester: Pytester) -> None: """Ensure a file path following a '-o' option does not generate an error (#3103)""" From 6e56d7dcfc17d1dee79b39996a5fe57868851f71 Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Fri, 11 Apr 2025 15:43:01 +0300 Subject: [PATCH 06/10] Fix option parsing in test_config.py to correctly handle multiple -o flags --- testing/test_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/test_config.py b/testing/test_config.py index a9e6a705bb9..c6b6b1e3632 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -2022,7 +2022,7 @@ def test_override_ini_does_not_contain_paths( """Check that -o no longer swallows all options after it (#3103)""" config = _config_for_test config._preparse( - ["-o", "cache_dir=/cache", "junit_family=legacy", "/some/test/path"] + ["-o", "cache_dir=/cache", "-o", "junit_family=legacy", "/some/test/path"] ) assert sorted(set(config._override_ini)) == sorted( ["cache_dir=/cache", "junit_family=legacy"] From baa9d886af1a0c8b44aed30d5c4a4d6c622663fe Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Sat, 12 Apr 2025 15:20:25 +0300 Subject: [PATCH 07/10] Add JUnit test result file to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index c4557b33a1c..5dda7079ab8 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,6 @@ pip-wheel-metadata/ # pytest debug logs generated via --debug pytestdebug.log + +# JUnit test result file +junit.xml From 8c4dfdda9aeffdfacb44d20f43d31266a36d1dbb Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Sun, 20 Apr 2025 12:09:54 +0300 Subject: [PATCH 08/10] Update test configuration to enable JUnit XML output and adjust pytest options --- .github/workflows/test.yml | 4 ++++ .gitignore | 3 --- tox.ini | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa6bc722055..4e362bbfe6e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -260,6 +260,10 @@ jobs: if: "matrix.use_coverage" run: python -m coverage xml + - name: Test with pytest + run: | + pytest --cov --junitxml=junit.xml -o junit_family=legacy + - name: Upload coverage to Codecov if: "matrix.use_coverage" uses: codecov/codecov-action@v5 diff --git a/.gitignore b/.gitignore index 5dda7079ab8..c4557b33a1c 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,3 @@ pip-wheel-metadata/ # pytest debug logs generated via --debug pytestdebug.log - -# JUnit test result file -junit.xml diff --git a/tox.ini b/tox.ini index d7e37a4bade..850def411cb 100644 --- a/tox.ini +++ b/tox.ini @@ -62,7 +62,6 @@ setenv = coverage: _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess coverage: COVERAGE_FILE={toxinidir}/.coverage coverage: COVERAGE_PROCESS_START={toxinidir}/.coveragerc - coverage: PYTEST_ADDOPTS=--junitxml=junit.xml -o junit_family=legacy doctesting: _PYTEST_TOX_POSARGS_DOCTESTING=doc/en From b3df0a1829caf1e58de72198e02c941f944c9bcd Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Sun, 20 Apr 2025 12:41:12 +0300 Subject: [PATCH 09/10] Replace pytest command with tox in test configuration for JUnit XML output --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e362bbfe6e..59327d676c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -262,7 +262,7 @@ jobs: - name: Test with pytest run: | - pytest --cov --junitxml=junit.xml -o junit_family=legacy + tox -- --junitxml=junit.xml -o junit_family=legacy - name: Upload coverage to Codecov if: "matrix.use_coverage" From 9a7a37a5db8d67da54e49e88596ebbeaaa296b47 Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Sun, 20 Apr 2025 13:01:12 +0300 Subject: [PATCH 10/10] Update CI configuration to use tox for testing and add conditional execution --- .github/workflows/test.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59327d676c1..19fde709184 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -260,9 +260,13 @@ jobs: if: "matrix.use_coverage" run: python -m coverage xml - - name: Test with pytest + - name: Test with tox (in CI) run: | - tox -- --junitxml=junit.xml -o junit_family=legacy + if [ "$CI" = "true" ]; then + tox -- --junitxml=junit.xml -o junit_family=legacy + else + tox + fi - name: Upload coverage to Codecov if: "matrix.use_coverage"