@@ -67,39 +67,22 @@ jobs:
6767 allow-prereleases : true
6868
6969 - name : Install coverage
70- if : ${{ !startsWith(matrix.python-version, 'pypy') }}
7170 run : |
72- # Be wary that this does not install typing_extensions in the future
73- pip install coverage
71+ # Be wary that this does not install typing_extensions in the future.
72+ # 'toml' extra is needed to read settings from pyproject.toml on Python <3.11
73+ pip install 'coverage[toml]'
7474
7575 - name : Test typing_extensions with coverage
76- if : ${{ !startsWith(matrix.python-version, 'pypy') }}
7776 run : |
7877 # Be wary of running `pip install` here, since it becomes easy for us to
7978 # accidentally pick up typing_extensions as installed by a dependency
8079 cd src
8180 python --version # just to make sure we're running the right one
8281 # Run tests under coverage
83- export COVERAGE_FILE=.coverage_${{ matrix.python-version }}
8482 python -m coverage run -m unittest test_typing_extensions.py
85- - name : Test typing_extensions no coverage on pypy
86- if : ${{ startsWith(matrix.python-version, 'pypy') }}
87- run : |
88- # Be wary of running `pip install` here, since it becomes easy for us to
89- # accidentally pick up typing_extensions as installed by a dependency
90- cd src
91- python --version # just to make sure we're running the right one
92- python -m unittest test_typing_extensions.py
83+ # Create xml file for Codecov
84+ coverage xml --rcfile=../pyproject.toml --fail-under=0
9385
94- - name : Archive code coverage results
95- id : archive-coverage
96- if : ${{ !startsWith(matrix.python-version, 'pypy') }}
97- uses : actions/upload-artifact@v4
98- with :
99- name : .coverage_${{ matrix.python-version }}
100- path : ./src/.coverage*
101- include-hidden-files : true
102- compression-level : 0 # no compression
10386 - name : Test CPython typing test suite
10487 # Test suite fails on PyPy even without typing_extensions
10588 if : ${{ !startsWith(matrix.python-version, 'pypy') }}
@@ -108,9 +91,16 @@ jobs:
10891 # Run the typing test suite from CPython with typing_extensions installed,
10992 # because we monkeypatch typing under some circumstances.
11093 python -c 'import typing_extensions; import test.__main__' test_typing -v
111- outputs :
112- # report if coverage was uploaded
113- cov_uploaded : ${{ steps.archive-coverage.outputs.artifact-id }}
94+
95+ - name : Upload coverage reports to Codecov
96+ uses : codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7
97+ if : ${{ (github.event_name == 'push' || github.event_name == 'pull_request') }}
98+ with :
99+ token : ${{ secrets.CODECOV_ORG_TOKEN }}
100+ flags : ${{ matrix.python-version }}
101+ directory : src
102+ fail_ci_if_error : true
103+ verbose : true
114104
115105 create-issue-on-failure :
116106 name : Create an issue if daily tests failed
@@ -140,95 +130,3 @@ jobs:
140130 title: `Daily tests failed on ${new Date().toDateString()}`,
141131 body: "Runs listed here: https://github.com/python/typing_extensions/actions/workflows/ci.yml",
142132 })
143-
144- report-coverage :
145- name : Report coverage
146-
147- runs-on : ubuntu-latest
148-
149- needs : [tests]
150-
151- permissions :
152- pull-requests : write
153-
154- # Job will run even if tests failed but only if at least one artifact was uploaded
155- if : ${{ always() && needs.tests.outputs.cov_uploaded != '' }}
156-
157- steps :
158- - uses : actions/checkout@v4
159- with :
160- persist-credentials : false
161- - name : Set up Python
162- uses : actions/setup-python@v5
163- with :
164- python-version : " 3"
165- - name : Download coverage artifacts
166- uses : actions/download-artifact@v4
167- with :
168- pattern : .coverage_*
169- path : .
170- # merge only when files are named differently
171- merge-multiple : true
172- - name : Install dependencies
173- run : pip install coverage
174- - name : Combine coverage results
175- run : |
176- # List the files to see what we have
177- echo "Combining coverage files..."
178- ls -aR .coverage*
179- coverage combine .coverage*
180- echo "Creating coverage report..."
181- # Create xml file for further processing; Create even if below minimum
182- coverage xml --fail-under=0
183- # Write markdown report to job summary
184- coverage report --fail-under=0 --format=markdown -m >> "$GITHUB_STEP_SUMMARY"
185-
186- # For future use in case we want to add a PR comment for 3rd party PRs which requires
187- # a workflow with elevated PR write permissions. Move below steps into a separate job.
188- - name : Archive code coverage report
189- id : cov_xml_upload
190- uses : actions/upload-artifact@v4
191- with :
192- name : coverage
193- path : coverage.xml
194- - name : Code Coverage Report (console)
195- run : |
196- # Create a coverage report (console), respects fail_under in pyproject.toml
197- coverage report
198-
199- - name : Code Coverage Report
200- uses : irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
201- # Create markdown file even if coverage report fails due to fail_under
202- if : ${{ always() && steps.cov_xml_upload.outputs.artifact-id != '' }}
203- with :
204- filename : coverage.xml
205- badge : true
206- fail_below_min : true
207- format : markdown
208- hide_branch_rate : false
209- hide_complexity : true
210- indicators : true
211- output : both # console, file or both
212- # Note: it appears fail below min is one off, use fail_under -1 here
213- thresholds : ' 95 98'
214-
215- - name : Add link to report badge
216- if : ${{ always() && steps.cov_xml_upload.outputs.artifact-id != '' }}
217- run : |
218- run_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}"
219- sed -i "1s|^\(!.*\)$|[\1]($run_url)|" code-coverage-results.md
220-
221- - name : Add Coverage PR Comment
222- uses : marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.3
223- # Create PR comment when the branch is on the repo, otherwise we lack PR write permissions
224- # -> need another workflow with access to secret token
225- if : >-
226- ${{
227- always()
228- && github.event_name == 'pull_request'
229- && github.event.pull_request.head.repo.full_name == github.repository
230- && steps.cov_xml_upload.outputs.artifact-id != ''
231- }}
232- with :
233- hide_and_recreate : true
234- path : code-coverage-results.md
0 commit comments