Skip to content

Commit

Permalink
Upload coverage to Codecov in separate job (cylc#5459)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MetRonnie authored Apr 13, 2023
1 parent 9989bb8 commit 1d4da4c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 25 deletions.
48 changes: 27 additions & 21 deletions .github/workflows/test_fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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:
Expand All @@ -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 }}
27 changes: 23 additions & 4 deletions .github/workflows/test_functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}

0 comments on commit 1d4da4c

Please sign in to comment.