From 83924f5e2b8370e52b7ffe8d88cab6943db8970f Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Wed, 8 May 2024 18:03:36 -0400 Subject: [PATCH] Coverage: Upload as separate step so it can be restarted without re-running the whole test suite because sometimes Codecov rate limits. --- .github/workflows/test_tox.yml | 4 ++++ .github/workflows/tox.yml | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_tox.yml b/.github/workflows/test_tox.yml index 62fe18c..da8e5bf 100644 --- a/.github/workflows/test_tox.yml +++ b/.github/workflows/test_tox.yml @@ -107,13 +107,17 @@ jobs: test_venv: uses: ./.github/workflows/tox.yml with: + coverage: '' envs: | - linux: pep8 name: style_check pytest: false - linux: py312 + coverage: codecov - macos: py311 + coverage: codecov - windows: py310 + coverage: codecov test_conda: uses: ./.github/workflows/tox.yml diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 85c42a9..9db87b1 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -223,9 +223,35 @@ jobs: with: paths: "**/results.xml" - - name: Upload to Codecov + - name: Upload coverage to artifacts # Even if tox fails, upload coverage if: ${{ (success() || failure()) && contains(matrix.coverage, 'codecov') && matrix.pytest == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: coverage_${{ matrix.toxenv }}.xml + path: coverage.xml + if-no-files-found: error + + upload-codecov: + needs: [tox] + permissions: + contents: none + runs-on: ubuntu-latest + name: Upload Coverage + steps: + + - name: Download coverage artifacts + uses: actions/download-artifact@v4 + with: + path: coverage + pattern: coverage_* + merge-multiple: true + + - name: Upload report to Codecov + if: ${{ hashFiles('coverage/') != '' }} uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} + directory: coverage + fail_ci_if_error: true + verbose: true