Skip to content

Commit

Permalink
CI: Ensure code coverage is always uploaded
Browse files Browse the repository at this point in the history
If code coverage is not uploaded on failure, then overall coverage can
suffer mysteriously (e.g., if a mac system failed, then it would appear
as if `backend_macosx.py` was not tested). Codecov would then show
several "indirect changes" that are spurious.

On GitHub Actions, if you don't have any status check function in the
`if` entry, then it is treated as `success() && (whatever else you
had)`, so put in an explicit check.

Azure also had no condition, so defaulted to only-on-success.

Cygwin is only run on `main` and sometimes on PRs, so disable code
coverage reporting from it. That would cause random "reductions" in
coverage for all PRs that don't run it (which is most of them.)

Also, fix the image-cleanup script, which would only run on success
instead of failure, where it would be useful.
  • Loading branch information
QuLogic committed May 8, 2024
1 parent ce15014 commit 25847dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,4 @@ jobs:
run: |
xvfb-run pytest-3.${{ matrix.python-minor-version }} -rfEsXR -n auto \
--maxfail=50 --timeout=300 --durations=25 \
--cov-report=xml --cov=lib --log-level=DEBUG --color=yes
- name: Upload code coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
--cov-report=term --cov=lib --log-level=DEBUG --color=yes
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ jobs:
--cov-report=xml --cov=lib --log-level=DEBUG --color=yes
- name: Cleanup non-failed image files
if: failure()
run: |
function remove_files() {
local extension=$1
Expand Down Expand Up @@ -349,6 +350,7 @@ jobs:
fi
- name: Filter C coverage
if: ${{ !cancelled() && github.event_name != 'schedule' }}
run: |
if [[ "${{ runner.os }}" != 'macOS' ]]; then
lcov --rc lcov_branch_coverage=1 --capture --directory . \
Expand All @@ -364,7 +366,7 @@ jobs:
-instr-profile default.profdata > info.lcov
fi
- name: Upload code coverage
if: ${{ github.event_name != 'schedule' }}
if: ${{ !cancelled() && github.event_name != 'schedule' }}
uses: codecov/codecov-action@v4
with:
name: "${{ matrix.python-version }} ${{ matrix.os }} ${{ matrix.name-suffix }}"
Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,13 @@ stages:
;;
esac
displayName: 'Filter C coverage'
condition: succeededOrFailed()
- bash: |
bash <(curl -s https://codecov.io/bash) \
-n "$PYTHON_VERSION $AGENT_OS" \
-f 'coverage.xml' -f 'extensions.xml'
displayName: 'Upload to codecov.io'
condition: succeededOrFailed()
- task: PublishTestResults@2
inputs:
Expand Down

0 comments on commit 25847dd

Please sign in to comment.