From 1d4da4ce2438fec968a788a74d79983d77b1e188 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Thu, 13 Apr 2023 10:02:57 +0100 Subject: [PATCH] Upload coverage to Codecov in separate job (#5459) GH Actions: upload coverage to Codecov in separate job - Reduces how hard we hit Codecov API - Allows easy re-attempt to upload - remove unnecessary step on MacOS --- .github/workflows/test_fast.yml | 48 +++++++++++++++------------ .github/workflows/test_functional.yml | 27 ++++++++++++--- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test_fast.yml b/.github/workflows/test_fast.yml index 1bbf67b699d..78e1add6d3a 100644 --- a/.github/workflows/test_fast.yml +++ b/.github/workflows/test_fast.yml @@ -35,20 +35,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Brew Install - if: startsWith(matrix.os, 'macos') - run: | - # speed up install (https://docs.brew.sh/Manpage#environment) - export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 - echo "[command]brew update" - brew update - echo "[command]brew install ..." - brew install bash coreutils - # add GNU coreutils and sed to the user PATH - # (see instructions in brew install output) - echo "$(brew --prefix)/opt/coreutils/libexec/gnubin" \ - >> "${GITHUB_PATH}" - - name: Apt-Get Install if: startsWith(matrix.os, 'ubuntu') run: | @@ -93,7 +79,7 @@ jobs: run: | pytest tests/integration - - name: Upload artifact + - name: Upload failed tests artifact if: failure() uses: actions/upload-artifact@v3 with: @@ -105,15 +91,35 @@ jobs: coverage xml coverage report + - name: Upload coverage artifact + uses: actions/upload-artifact@v3 + with: + name: coverage_${{ matrix.os }}_py-${{ matrix.python-version }} + path: coverage.xml + retention-days: 7 + + - name: Linkcheck + if: startsWith(matrix.python-version, '3.10') + run: pytest -m linkcheck --dist=load tests/unit + + codecov: + needs: test + runs-on: ubuntu-latest + timeout-minutes: 2 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Download coverage artifacts + uses: actions/download-artifact@v3 + - name: Codecov upload uses: codecov/codecov-action@v3 with: - name: '${{ github.workflow }} ${{ matrix.os }} py-${{ matrix.python-version }}' + name: ${{ github.workflow }} flags: fast-tests fail_ci_if_error: true verbose: true - token: ${{ secrets.CODECOV_TOKEN }} # Token not required for public repos, but might reduce chance of random 404 error? - - - name: Linkcheck - if: startsWith(matrix.python-version, '3.10') - run: pytest -m linkcheck --dist=load tests/unit + # Token not required for public repos, but avoids upload failure due + # to rate-limiting (but not for PRs opened from forks) + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/test_functional.yml b/.github/workflows/test_functional.yml index 21967c85f76..3514713b7e9 100644 --- a/.github/workflows/test_functional.yml +++ b/.github/workflows/test_functional.yml @@ -248,14 +248,13 @@ jobs: -exec echo '====== {} ======' \; -exec cat '{}' \; - name: Set artifact upload name - if: failure() && steps.test.outcome == 'failure' id: uploadname run: | # artifact name cannot contain '/' characters CID="$(sed 's|/|-|g' <<< "${{ matrix.name || matrix.chunk }}")" echo "uploadname=$CID" >> $GITHUB_OUTPUT - - name: Upload artifact + - name: Upload failed tests artifact if: failure() && steps.test.outcome == 'failure' uses: actions/upload-artifact@v3 with: @@ -294,11 +293,31 @@ jobs: coverage xml coverage report + - name: Upload coverage artifact + uses: actions/upload-artifact@v3 + with: + name: coverage_${{ steps.uploadname.outputs.uploadname }} + path: coverage.xml + retention-days: 7 + + codecov: + needs: test + runs-on: ubuntu-latest + timeout-minutes: 2 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Download coverage artifacts + uses: actions/download-artifact@v3 + - name: Codecov upload uses: codecov/codecov-action@v3 with: - name: '${{ github.workflow }} ${{ matrix.name }} ${{ matrix.chunk }}' + name: ${{ github.workflow }} flags: functional-tests fail_ci_if_error: true verbose: true - token: ${{ secrets.CODECOV_TOKEN }} # Token not required for public repos, but might reduce chance of random 404 error? + # Token not required for public repos, but avoids upload failure due + # to rate-limiting (but not for PRs opened from forks) + token: ${{ secrets.CODECOV_TOKEN }}