Skip to content

Commit

Permalink
🧪 Publish MyPy type coverage to Codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Dec 20, 2024
1 parent ca49afe commit b2ce8b2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
name: Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})
# multiple flags is marked as an error in codecov UI, but is actually fine
# https://github.com/codecov/feedback/issues/567
flags: Windows,${{ matrix.python }}
flags: pytest,Windows,${{ matrix.python }}
# this option cannot be set in .codecov.yml
fail_ci_if_error: true

Expand Down Expand Up @@ -141,8 +141,18 @@ jobs:
with:
directory: empty
name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})
flags: Ubuntu,${{ matrix.python }}
flags: pytest,Ubuntu,${{ matrix.python }}
fail_ci_if_error: true
- if: >-
always()
&& matrix.check_formatting == '1'
uses: codecov/codecov-action@v5
with:
disable_search: true
files: empty/mypy-cov-*-py-*/*
flags: MyPy
fail_ci_if_error: true
name: MyPy type coverage
macOS:
name: 'macOS (${{ matrix.python }})'
Expand Down Expand Up @@ -177,7 +187,7 @@ jobs:
with:
directory: empty
name: macOS (${{ matrix.python }})
flags: macOS,${{ matrix.python }}
flags: pytest,macOS,${{ matrix.python }}
fail_ci_if_error: true

# run CI on a musl linux
Expand Down Expand Up @@ -206,7 +216,7 @@ jobs:
with:
directory: empty
name: Alpine
flags: Alpine,${{ steps.get-version.outputs.version }}
flags: pytest,Alpine,${{ steps.get-version.outputs.version }}
fail_ci_if_error: true

Cython:
Expand Down Expand Up @@ -260,7 +270,7 @@ jobs:
uses: codecov/codecov-action@v5
with:
name: Cython
flags: Cython,${{ steps.get-version.outputs.version }}
flags: pytest,Cython,${{ steps.get-version.outputs.version }}
fail_ci_if_error: true

# https://github.com/marketplace/actions/alls-green#why
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
:target: https://anaconda.org/conda-forge/trio
:alt: Latest conda-forge version

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

Trio – a friendly Python library for async concurrency and I/O
Expand Down
12 changes: 6 additions & 6 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ echo "::group::Mypy"
rm -f mypy_annotate.dat
# Pipefail makes these pipelines fail if mypy does, even if mypy_annotate.py succeeds.
set -o pipefail
mypy --show-error-end --python-version=3.13 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
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 \
|| { echo "* Mypy (Linux, Python 3.13) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
# Darwin tests FreeBSD too
mypy --show-error-end --python-version=3.13 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
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 \
|| { echo "* Mypy (Mac, Python 3.13) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
mypy --show-error-end --python-version=3.13 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
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 \
|| { echo "* Mypy (Windows, Python 3.13) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
mypy --show-error-end --python-version=3.8 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
mypy --show-error-end --python-version=3.8 --cobertura-xml-report=mypy-cov-linux-py-3.8 --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
|| { echo "* Mypy (Linux, Python 3.8) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
# Darwin tests FreeBSD too
mypy --show-error-end --python-version=3.8 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
mypy --show-error-end --python-version=3.8 --cobertura-xml-report=mypy-cov-macos-py-3.8 --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
|| { echo "* Mypy (Mac, Python 3.8) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
mypy --show-error-end --python-version=3.8 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
mypy --show-error-end --python-version=3.8 --cobertura-xml-report=mypy-cov-windows-py-3.8 --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
|| { echo "* Mypy (Windows, Python 3.8) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
set +o pipefail
# Re-display errors using Github's syntax, read out of mypy_annotate.dat
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cryptography>=41.0.0 # cryptography<41 segfaults on pypy3.10

# Tools
black; implementation_name == "cpython"
mypy # Would use mypy[faster-cache], but orjson has build issues on pypy
mypy[reports] # Would use mypy[faster-cache], but orjson has build issues on pypy
orjson; implementation_name == "cpython"
ruff >= 0.8.0
astor # code generation
Expand Down
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ jedi==0.19.2 ; implementation_name == 'cpython'
# via -r test-requirements.in
jinja2==3.1.4
# via sphinx
lxml==5.3.0
# via mypy
markupsafe==3.0.2
# via jinja2
mccabe==0.7.0
Expand Down

0 comments on commit b2ce8b2

Please sign in to comment.