Skip to content

Commit

Permalink
Move push to codecov to its own job in Actions (#74)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
leouieda authored Jun 17, 2024
1 parent 5576f7a commit 77764e3
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defaults:
jobs:

#############################################################################
# Run tests and upload to codecov
# Run tests
test:
name: ${{ matrix.os }} python=${{ matrix.python }} dependencies=${{ matrix.dependencies }} cached=${{ matrix.cached }}
runs-on: ${{ matrix.os }}-latest
Expand Down Expand Up @@ -157,11 +157,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 }}_${{ matrix.cached }}
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
Expand Down

0 comments on commit 77764e3

Please sign in to comment.