Skip to content

Commit

Permalink
Merge pull request #3158 from webknjaz/maintenance/coveragepy-refactor
Browse files Browse the repository at this point in the history
💄 Refactor the coveragepy config
  • Loading branch information
webknjaz authored Dec 19, 2024
2 parents 4f66fab + 6212cdf commit 0f270f9
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ codecov:
notify:
# This number needs to be changed whenever the number of runs in CI is changed.
# Another option is codecov-cli: https://github.com/codecov/codecov-cli#send-notifications
after_n_builds: 27
after_n_builds: 31
wait_for_ci: false
notify_error: true # if uploads fail, replace cov comment with a comment with errors.
require_ci_to_pass: false
Expand Down
25 changes: 22 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,34 @@ jobs:
cache: pip
# setuptools is needed to get distutils on 3.12, which cythonize requires
- name: install trio and setuptools
run: python -m pip install --upgrade pip . setuptools
run: python -m pip install --upgrade pip . setuptools 'coverage[toml]'

- name: add cython plugin to the coveragepy config
run: >-
sed -i 's#plugins\s=\s\[\]#plugins = ["Cython.Coverage"]#'
pyproject.toml
- name: install cython & compile pyx file
env:
CFLAGS: ${{ env.CFLAGS }} -DCYTHON_TRACE_NOGIL=1
run: |
python -m pip install "cython${{ matrix.cython }}"
cythonize --inplace tests/cython/test_cython.pyx
cythonize --inplace -X linetrace=True tests/cython/test_cython.pyx
- name: import & run module
run: python -c 'import tests.cython.test_cython'
run: coverage run -m tests.cython.run_test_cython

- name: get Python version for codecov flag
id: get-version
run: >-
echo "version=$(python -V | cut -d' ' -f2 | cut -d'.' -f1,2)"
>> "${GITHUB_OUTPUT}"
- if: always()
uses: codecov/codecov-action@v5
with:
name: Cython
flags: Cython,${{ steps.get-version.outputs.version }}
fail_ci_if_error: true

# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection
Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,20 @@ directory = "misc"
name = "Miscellaneous internal changes"
showcontent = true

[tool.coverage.html]
show_contexts = true
skip_covered = false

[tool.coverage.paths]
_site-packages-to-src-mapping = [
"src",
"*/src",
'*\src',
"*/lib/pypy*/site-packages",
"*/lib/python*/site-packages",
'*\Lib\site-packages',
]

[tool.coverage.run]
branch = true
source_pkgs = ["trio"]
Expand All @@ -282,10 +296,15 @@ omit = [
# The test suite spawns subprocesses to test some stuff, so make sure
# this doesn't corrupt the coverage files
parallel = true
plugins = []
relative_files = true
source = ["."]

[tool.coverage.report]
precision = 1
skip_covered = true
skip_empty = true
show_missing = true
exclude_lines = [
"pragma: no cover",
"abc.abstractmethod",
Expand All @@ -296,6 +315,9 @@ exclude_lines = [
'class .*\bProtocol\b.*\):',
"raise NotImplementedError",
]
exclude_also = [
'^\s*@pytest\.mark\.xfail',
]
partial_branches = [
"pragma: no branch",
"if not TYPE_CHECKING:",
Expand Down
3 changes: 3 additions & 0 deletions tests/cython/run_test_cython.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .test_cython import invoke_main_entry_point

invoke_main_entry_point()
3 changes: 2 additions & 1 deletion tests/cython/test_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ async def trio_main() -> None:
nursery.start_soon(foo)
nursery.start_soon(foo)

trio.run(trio_main)
def invoke_main_entry_point():
trio.run(trio_main)

0 comments on commit 0f270f9

Please sign in to comment.