@@ -73,10 +73,16 @@ jobs:
7373 python3.8 -m pip install 'virtualenv<20.22' 'tox==4.5.1' tox-gh-actions
7474 tox --workdir .github/workflows/.tox --recreate
7575
76+ - name : Select the coverage file for upload
77+ if : |
78+ ( matrix.python-version == '3.6' || matrix.python-version == '3.11' ) &&
79+ ( !cancelled() && github.actor != 'nektos/act' )
80+ id : coverage
81+ run : mv $( ls -t .github/workflows/.tox/*/log/.coverage | head -1 ) .coverage
7682
7783 # The new reliable Codecov upload requires Codecov to query the GitHub API to check
7884 # the repo and the commit. The repo (or organisation) owner needs to login to
79- # codev , generated the CODECOV_TOKEN and save it as a secret in the ORG or the repo:
85+ # codecov , generated the CODECOV_TOKEN and save it as a secret in the ORG or the repo:
8086 # https://docs.codecov.com/docs/adding-the-codecov-token
8187
8288 # Links to get and set the token:
9096 # If CODECOV_TOKEN is not set, use the legacy tokenless Codecov action:
9197 env :
9298 CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
99+ # To reduce chances of GitHub's API throttling to hit this upload, only run the
100+ # upload for the py38-covcombine-check job running on Ubuntu-20.04, which is the
101+ # one we need. And only run it for PRs and the master branch, not for pushes.
102+ # This reduces the number of uploads and the chance of hitting the rate limit
103+ # by a factor of 6.
93104 if : |
105+ steps.coverage.outcome == 'success' &&
94106 !env.CODECOV_TOKEN && !cancelled() &&
95107 matrix.os == 'ubuntu-20.04' && github.actor != 'nektos/act' &&
96108 ( github.event.pull_request.number || github.ref == 'refs/heads/master' )
@@ -101,6 +113,8 @@ jobs:
101113 # Use fail_ci_if_error: false as explained the big comment above:
102114 # Not failing this job in this case is ok because the tox CI checks also contain
103115 # a diff-cover check which would fail on changed lines missing coverage.
116+ # The Codecov CLI is more reliable and should be used if the CODECOV_TOKEN is set.
117+ # The Codecov CLI is used in the next step when CODECOV_TOKEN is set.
104118 fail_ci_if_error : false
105119 flags : unittest
106120 name : py27-py38-combined
@@ -112,7 +126,7 @@ jobs:
112126 CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
113127 if : |
114128 env.CODECOV_TOKEN && !cancelled() && github.actor != 'nektos/act' &&
115- ( github.event.pull_request.number || github.ref == 'refs/heads/master' )
129+ steps.coverage.outcome == 'success' && matrix.os == 'ubuntu-20.04'
116130 run : >
117131 set -euxv;
118132 mv .github/workflows/.tox/py38-covcombine-check/log/coverage.xml cov.xml;
@@ -123,9 +137,23 @@ jobs:
123137 --flag python${{ env.PYTHON_VERSION }}
124138 continue-on-error : false # Fail the job if the upload with CODECOV_TOKEN fails
125139
126-
127- - name : Upload coverage reports to Coveralls
140+ - if : steps.coverage.outcome == 'success'
141+ name : Upload coverage reports to Coveralls
128142 env :
143+ COVERALLS_PARALLEL : true
129144 COVERALLS_FLAG_NAME : ${{ format('python{0}', steps.python.outputs.python-version ) }}
130145 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
131- run : pip install coveralls && coveralls --service=github && coveralls --finish
146+ run : pip install coveralls && coveralls --service=github
147+
148+ # For combined coverage of 2.7, 3.8 and 3.11 we upload to Coveralls in parallel mode.
149+ # To view the Coveralls results from the PR, click on the "Details" link to the right
150+ # of the Coveralls Logo in the Checks section of the PR.
151+ finish-coverage-upload :
152+ if : github.actor != 'nektos/act'
153+ needs : test
154+ runs-on : ubuntu-latest
155+ steps :
156+ - name : Finish the coverage upload to Coveralls
157+ uses : coverallsapp/github-action@v1
158+ with :
159+ parallel-finished : true
0 commit comments