From 0581b26926972c0ded9620a10a67d4abfd387e60 Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Mon, 17 Jun 2024 11:47:20 -0300 Subject: [PATCH] Move push to codecov to its own job in Actions Remove the push to codecov step from the `test` job into a new job that depends on the test job. Upload the coverage reports as artifacts after testing, and reuse the artifacts in the new job. Upload all coverage reports in a single push to Codecov to minimize the number of hits. --- .github/workflows/test.yml | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 253b8cf5c..99ef4a350 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ defaults: jobs: ############################################################################# - # Run tests and upload to codecov + # Run tests test: name: ${{ matrix.os }} python=${{ matrix.python }} dependencies=${{ matrix.dependencies }} runs-on: ${{ matrix.os }}-latest @@ -150,11 +150,38 @@ jobs: - name: Convert coverage report to XML for codecov run: coverage xml - - name: Upload coverage to Codecov + - name: Upload coverage report as an artifact + uses: actions/upload-artifact@v4 + with: + name: coverage_${{ matrix.os }}_${{ matrix.dependencies }} + path: ./coverage.xml + + + ############################################################################# + # Upload coverage report to codecov + codecov-upload: + runs-on: ubuntu-latest + needs: test + + steps: + + - name: Download coverage report artifacts + # Download coverage reports from every runner. + # Maximum coverage is achieved by combining reports from every runner. + # Each coverage file will live in its own folder with the same name as + # the artifact. + uses: actions/download-artifact@v4 + with: + pattern: coverage_* + + - name: List all downloaded artifacts + run: ls -l -R . + + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: - file: ./coverage.xml - env_vars: OS,PYTHON,DEPENDENCIES + # Upload all coverage report files + files: ./coverage_*/coverage.xml # Fail the job so we know coverage isn't being updated. Otherwise it # can silently drop and we won't know. fail_ci_if_error: true