From 96579d53e1da8db32927509a5bdb492c5e811e76 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 15 Aug 2024 08:16:04 +0100 Subject: [PATCH] Enable junit.xml reporting (#253) --- .github/workflows/tox.yml | 12 ++++++++++++ tox.ini | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 37f0fe24..0faca004 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -136,6 +136,7 @@ jobs: ansible_collections/ansible/eda/.tox/**/log/ ansible_collections/ansible/eda/.tox/**/coverage.xml ansible_collections/ansible/eda/tests/output/reports/coverage.xml + ansible_collections/ansible/eda/tests/output/junit/*.xml - name: Report failure if git reports dirty status run: | @@ -148,6 +149,7 @@ jobs: # https://github.com/actions/toolkit/issues/193 check: if: always() + environment: check permissions: id-token: write checks: read @@ -185,6 +187,16 @@ jobs: - name: Check for expected number of coverage reports run: .github/check-coverage.sh + # Single uploads inside check job for codecov to allow use to retry + # it when it fails without running tests again. Fails often enough! + - name: Upload junit xml reports + uses: codecov/test-results-action@v1 + with: + name: ${{ matrix.name }} + files: "*/tests/output/junit/*.xml" + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + - name: Upload coverage data uses: codecov/codecov-action@v4 with: diff --git a/tox.ini b/tox.ini index 64bf0f15..30811e46 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ # Recommended usage of this file is detailed in https://github.com/ansible/eda-partner-testing/blob/main/README.md. # The linter paths can be changed, but may result in false passes. # {posargs} in this case would be the path to collection root relative from the .github/workflows dir (`../..`) -# cspell: ignore TOXPYTHON setenv passenv REQPASS PYTHONPYCACHEPREFIX PYTHONIOENCODING PYTHONBREAKPOINT notest envdir envname toxworkdir +# cspell: ignore TOXPYTHON setenv passenv REQPASS PYTHONPYCACHEPREFIX PYTHONIOENCODING PYTHONBREAKPOINT notest envdir envname toxworkdir junitxml [tox] envlist = lint, darglint, unit, sanity, integration, coverage @@ -76,7 +76,7 @@ commands = # risky: not safe for development it affects user setup ansible-galaxy collection install . # use same coverage location as ansible-test: - coverage run --data-file=tests/output/coverage/integration.coverage -m pytest tests/integration -vvv -s {posargs} + coverage run --data-file=tests/output/coverage/integration.coverage -m pytest tests/integration -vvv -s --junitxml=tests/output/junit/integration.xml {posargs} [testenv:unit,py{39,310,311,312,313}-unit] description = @@ -96,7 +96,7 @@ description = py{39,310,311,312,313}: with {basepython} commands = ansible --version - ansible-test sanity -v --requirements --coverage --truncate 0 {posargs} + ansible-test sanity -v --requirements --coverage --truncate 0 --junit {posargs} [testenv:coverage] description = Produce final coverage report for GHA