Skip to content

Commit

Permalink
.github/workflows/main.yml: Fix coverage upload to Coveralls
Browse files Browse the repository at this point in the history
Signed-off-by: Bernhard Kaindl <[email protected]>
  • Loading branch information
bernhardkaindl committed May 12, 2024
1 parent 4b5b321 commit cf90f36
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ jobs:
python3.8 -m pip install 'virtualenv<20.22' 'tox==4.5.1' tox-gh-actions
tox --workdir .github/workflows/.tox --recreate
- name: Select the coverage file for upload
if: |
( matrix.python-version = '3.6' || matrix.python-version == '3.11' ) &&
( github.event.pull_request.number || github.ref == 'refs/heads/master' ) &&
( !cancelled() && github.actor != 'nektos/act' )
id: coverage
run: >
mv $( ls -t .github/workflows/.tox/*/log/.coverage | head -1 ) .;
mv $( ls -t .github/workflows/.tox/*/log/coverage.xml | head -1 ) .
# The new reliable Codecov upload requires Codecov to query the GitHub API to check
# the repo and the commit. The repo (or organisation) owner needs to login to
Expand All @@ -90,42 +99,45 @@ jobs:
# If CODECOV_TOKEN is not set, use the legacy tokenless Codecov action:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: |
!env.CODECOV_TOKEN && !cancelled() &&
matrix.os == 'ubuntu-20.04' && github.actor != 'nektos/act' &&
( github.event.pull_request.number || github.ref == 'refs/heads/master' )
if: steps.coverage.outcome == 'success' && !env.CODECOV_TOKEN
uses: codecov/codecov-action@v3
with:
directory: .github/workflows/.tox/py38-covcombine-check/log
env_vars: OS,PYTHON
# Use fail_ci_if_error: false as explained the big comment above:
# Not failing this job in this case is ok because the tox CI checks also contain
# a diff-cover check which would fail on changed lines missing coverage.
fail_ci_if_error: false
flags: unittest
name: py27-py38-combined
flags: ${{ matrix.python-version }}
name: Python${{ matrix.python-version }}
verbose: true

- name: Upload coverage reports to Codecov (used when secrets.CODECOV_TOKEN is set)
# If CODECOV_TOKEN is set, use the new Codecov CLI to upload the coverage reports
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: |
env.CODECOV_TOKEN && !cancelled() && github.actor != 'nektos/act' &&
( github.event.pull_request.number || github.ref == 'refs/heads/master' )
if: steps.coverage.outcome == 'success' && env.CODECOV_TOKEN
run: >
set -euxv;
mv .github/workflows/.tox/py38-covcombine-check/log/coverage.xml cov.xml;
curl -O https://cli.codecov.io/latest/linux/codecov; sudo chmod +x codecov;
./codecov upload-process --report-type coverage
--name "CLI Upload for ${{ env.PYTHON_VERSION }}"
--git-service github --fail-on-error --file cov.xml --disable-search
--git-service github --fail-on-error
--flag python${{ env.PYTHON_VERSION }}
continue-on-error: false # Fail the job if the upload with CODECOV_TOKEN fails

- name: Send coverage to Coveralls (parallel)
uses: coverallsapp/github-action@v1
if: steps.coverage.outcome == 'success'
with:
parallel: true

- name: Upload coverage reports to Coveralls
env:
COVERALLS_FLAG_NAME: ${{ format('python{0}', steps.python.outputs.python-version ) }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pip install coveralls && coveralls --service=github && coveralls --finish

finish:
needs: test
if: $
runs-on: ubuntu-latest
steps:
- name: Close parallel build
uses: coverallsapp/github-action@v1
with:
parallel-finished: true

0 comments on commit cf90f36

Please sign in to comment.