Skip to content

Commit dbdb9c2

Browse files
committed
🧪 Publish MyPy type coverage to Codecov
1 parent b53cf79 commit dbdb9c2

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

‎.github/workflows/ci.yml

+15-5
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
name: Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})
8989
# multiple flags is marked as an error in codecov UI, but is actually fine
9090
# https://github.com/codecov/feedback/issues/567
91-
flags: Windows,${{ matrix.python }}
91+
flags: pytest,Windows,${{ matrix.python }}
9292
# this option cannot be set in .codecov.yml
9393
fail_ci_if_error: true
9494

@@ -141,8 +141,18 @@ jobs:
141141
with:
142142
directory: empty
143143
name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})
144-
flags: Ubuntu,${{ matrix.python }}
144+
flags: pytest,Ubuntu,${{ matrix.python }}
145145
fail_ci_if_error: true
146+
- if: >-
147+
always()
148+
&& matrix.check_formatting == '1'
149+
uses: codecov/codecov-action@v5
150+
with:
151+
disable_search: true
152+
files: empty/mypy-cov-*-py-*/*
153+
flags: MyPy
154+
fail_ci_if_error: true
155+
name: MyPy type coverage
146156
147157
macOS:
148158
name: 'macOS (${{ matrix.python }})'
@@ -177,7 +187,7 @@ jobs:
177187
with:
178188
directory: empty
179189
name: macOS (${{ matrix.python }})
180-
flags: macOS,${{ matrix.python }}
190+
flags: pytest,macOS,${{ matrix.python }}
181191
fail_ci_if_error: true
182192

183193
# run CI on a musl linux
@@ -206,7 +216,7 @@ jobs:
206216
with:
207217
directory: empty
208218
name: Alpine
209-
flags: Alpine,${{ steps.get-version.outputs.version }}
219+
flags: pytest,Alpine,${{ steps.get-version.outputs.version }}
210220
fail_ci_if_error: true
211221

212222
Cython:
@@ -260,7 +270,7 @@ jobs:
260270
uses: codecov/codecov-action@v5
261271
with:
262272
name: Cython
263-
flags: Cython,${{ steps.get-version.outputs.version }}
273+
flags: pytest,Cython,${{ steps.get-version.outputs.version }}
264274
fail_ci_if_error: true
265275

266276
# https://github.com/marketplace/actions/alls-green#why

‎README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
:target: https://anaconda.org/conda-forge/trio
1919
:alt: Latest conda-forge version
2020

21-
.. image:: https://codecov.io/gh/python-trio/trio/branch/main/graph/badge.svg
22-
:target: https://codecov.io/gh/python-trio/trio
21+
.. image:: https://codecov.io/gh/python-trio/trio/graph/badge.svg?flag=pytest
22+
:target: https://app.codecov.io/gh/python-trio/trio?flags[]=pytest
2323
:alt: Test coverage
2424

2525
Trio – a friendly Python library for async concurrency and I/O

‎check.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ echo "::group::Mypy"
5757
rm -f mypy_annotate.dat
5858
# Pipefail makes these pipelines fail if mypy does, even if mypy_annotate.py succeeds.
5959
set -o pipefail
60-
mypy --show-error-end --python-version=3.13 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
60+
mypy --show-error-end --python-version=3.13 --cobertura-xml-report=mypy-cov-linux-py-3.13 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
6161
|| { echo "* Mypy (Linux, Python 3.13) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
6262
# Darwin tests FreeBSD too
63-
mypy --show-error-end --python-version=3.13 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
63+
mypy --show-error-end --python-version=3.13 --cobertura-xml-report=mypy-cov-macos-py-3.13 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
6464
|| { echo "* Mypy (Mac, Python 3.13) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
65-
mypy --show-error-end --python-version=3.13 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
65+
mypy --show-error-end --python-version=3.13 --cobertura-xml-report=mypy-cov-windows-py-3.13 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
6666
|| { echo "* Mypy (Windows, Python 3.13) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
67-
mypy --show-error-end --python-version=3.9 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
67+
mypy --show-error-end --python-version=3.9 --cobertura-xml-report=mypy-cov-linux-py-3.9 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
6868
|| { echo "* Mypy (Linux, Python 3.9) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
6969
# Darwin tests FreeBSD too
70-
mypy --show-error-end --python-version=3.9 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
70+
mypy --show-error-end --python-version=3.9 --cobertura-xml-report=mypy-cov-macos-py-3.9 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
7171
|| { echo "* Mypy (Mac, Python 3.9) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
72-
mypy --show-error-end --python-version=3.9 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
72+
mypy --show-error-end --python-version=3.9 --cobertura-xml-report=mypy-cov-windows-py-3.9 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
7373
|| { echo "* Mypy (Windows, Python 3.9) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
7474
set +o pipefail
7575
# Re-display errors using Github's syntax, read out of mypy_annotate.dat

‎test-requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cryptography>=41.0.0 # cryptography<41 segfaults on pypy3.10
1111

1212
# Tools
1313
black; implementation_name == "cpython"
14-
mypy # Would use mypy[faster-cache], but orjson has build issues on pypy
14+
mypy[reports] # Would use mypy[faster-cache], but orjson has build issues on pypy
1515
orjson; implementation_name == "cpython"
1616
ruff >= 0.8.0
1717
astor # code generation

‎test-requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ jedi==0.19.2 ; implementation_name == 'cpython'
6767
# via -r test-requirements.in
6868
jinja2==3.1.4
6969
# via sphinx
70+
lxml==5.3.0
71+
# via mypy
7072
markupsafe==3.0.2
7173
# via jinja2
7274
mccabe==0.7.0

0 commit comments

Comments
 (0)