From 25847ddd98603df388491f133ee34e58a6dc0a58 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 2 May 2024 23:51:23 -0400 Subject: [PATCH] CI: Ensure code coverage is always uploaded 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. --- .github/workflows/cygwin.yml | 7 +------ .github/workflows/tests.yml | 4 +++- azure-pipelines.yml | 2 ++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index 3e2a6144dece..58c132315b6f 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e6608cff6bc4..d67dfb3a752c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 @@ -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 . \ @@ -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 }}" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2ad9a7821b5c..bf055d0eaa16 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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: