@@ -36,11 +36,11 @@ jobs:
3636 os : ubuntu-22.04
3737 runs-on : ${{ matrix.os }}
3838 steps :
39- - uses : actions/checkout@v3
39+ - uses : actions/checkout@v4
4040 with :
4141 fetch-depth : 0 # Needed by diff-cover to get the changed lines: origin/master..HEAD
4242 - name : Set up Python ${{ matrix.python-version }}
43- uses : actions/setup-python@v4
43+ uses : actions/setup-python@v5
4444 with :
4545 python-version : ${{ matrix.python-version }}
4646
@@ -73,13 +73,59 @@ 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 : Upload coverage reports to Codecov
77- if : ${{ matrix.os == 'ubuntu-20.04' && github.actor != 'nektos/act'}}
76+
77+ # The new reliable Codecov upload requires Codecov to query the GitHub API to check
78+ # 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:
80+ # https://docs.codecov.com/docs/adding-the-codecov-token
81+
82+ # Links to get and set the token:
83+ # Get the CODECOV_TOKEN: https://app.codecov.io/gh/xenserver/python-libs/settings
84+ # Set the CODE_COV_TOKEN: https://github.com/xenserver/python-libs/settings/secrets/actions
85+
86+ # Without it, the API calls are rate-limited by GitHub, and the upload may fail:
87+ # https://github.com/codecov/feedback/issues/126#issuecomment-1932658904
88+ #
89+ - name : Upload coverage reports to Codecov (fallback, legacy Node.js 16 action)
90+ # If CODECOV_TOKEN is not set, use the legacy tokenless Codecov action:
91+ env :
92+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
93+ if : |
94+ !env.CODECOV_TOKEN && !cancelled() &&
95+ matrix.os == 'ubuntu-20.04' && github.actor != 'nektos/act' &&
96+ ( github.event.pull_request.number || github.ref == 'refs/heads/master' )
7897 uses : codecov/codecov-action@v3
7998 with :
8099 directory : .github/workflows/.tox/py38-covcombine-check/log
81100 env_vars : OS,PYTHON
82- fail_ci_if_error : true
101+ # Use fail_ci_if_error: false as explained the big comment above:
102+ # Not failing this job in this case is ok because the tox CI checks also contain
103+ # a diff-cover check which would fail on changed lines missing coverage.
104+ fail_ci_if_error : false
83105 flags : unittest
84106 name : py27-py38-combined
85107 verbose : true
108+
109+ - name : Upload coverage reports to Codecov (used when secrets.CODECOV_TOKEN is set)
110+ # If CODECOV_TOKEN is set, use the new Codecov CLI to upload the coverage reports
111+ env :
112+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
113+ if : |
114+ env.CODECOV_TOKEN && !cancelled() && github.actor != 'nektos/act' &&
115+ ( github.event.pull_request.number || github.ref == 'refs/heads/master' )
116+ run : >
117+ set -euxv;
118+ mv .github/workflows/.tox/py38-covcombine-check/log/coverage.xml cov.xml;
119+ curl -O https://cli.codecov.io/latest/linux/codecov; sudo chmod +x codecov;
120+ ./codecov upload-process --report-type coverage
121+ --name "CLI Upload for ${{ env.PYTHON_VERSION }}"
122+ --git-service github --fail-on-error --file cov.xml --disable-search
123+ --flag python${{ env.PYTHON_VERSION }}
124+ continue-on-error : false # Fail the job if the upload with CODECOV_TOKEN fails
125+
126+
127+ - name : Upload coverage reports to Coveralls
128+ env :
129+ COVERALLS_FLAG_NAME : ${{ format('python{0}', steps.python.outputs.python-version ) }}
130+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
131+ run : pip install coveralls && coveralls --service=github && coveralls --finish
0 commit comments