Skip to content

Commit 0f270f9

Browse files
authored
Merge pull request #3158 from webknjaz/maintenance/coveragepy-refactor
💄 Refactor the coveragepy config
2 parents 4f66fab + 6212cdf commit 0f270f9

File tree

5 files changed

+50
-5
lines changed

5 files changed

+50
-5
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ codecov:
66
notify:
77
# This number needs to be changed whenever the number of runs in CI is changed.
88
# Another option is codecov-cli: https://github.com/codecov/codecov-cli#send-notifications
9-
after_n_builds: 27
9+
after_n_builds: 31
1010
wait_for_ci: false
1111
notify_error: true # if uploads fail, replace cov comment with a comment with errors.
1212
require_ci_to_pass: false

.github/workflows/ci.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,34 @@ jobs:
234234
cache: pip
235235
# setuptools is needed to get distutils on 3.12, which cythonize requires
236236
- name: install trio and setuptools
237-
run: python -m pip install --upgrade pip . setuptools
237+
run: python -m pip install --upgrade pip . setuptools 'coverage[toml]'
238+
239+
- name: add cython plugin to the coveragepy config
240+
run: >-
241+
sed -i 's#plugins\s=\s\[\]#plugins = ["Cython.Coverage"]#'
242+
pyproject.toml
238243
239244
- name: install cython & compile pyx file
245+
env:
246+
CFLAGS: ${{ env.CFLAGS }} -DCYTHON_TRACE_NOGIL=1
240247
run: |
241248
python -m pip install "cython${{ matrix.cython }}"
242-
cythonize --inplace tests/cython/test_cython.pyx
249+
cythonize --inplace -X linetrace=True tests/cython/test_cython.pyx
243250
244251
- name: import & run module
245-
run: python -c 'import tests.cython.test_cython'
252+
run: coverage run -m tests.cython.run_test_cython
253+
254+
- name: get Python version for codecov flag
255+
id: get-version
256+
run: >-
257+
echo "version=$(python -V | cut -d' ' -f2 | cut -d'.' -f1,2)"
258+
>> "${GITHUB_OUTPUT}"
259+
- if: always()
260+
uses: codecov/codecov-action@v5
261+
with:
262+
name: Cython
263+
flags: Cython,${{ steps.get-version.outputs.version }}
264+
fail_ci_if_error: true
246265

247266
# https://github.com/marketplace/actions/alls-green#why
248267
check: # This job does nothing and is only used for the branch protection

pyproject.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,20 @@ directory = "misc"
268268
name = "Miscellaneous internal changes"
269269
showcontent = true
270270

271+
[tool.coverage.html]
272+
show_contexts = true
273+
skip_covered = false
274+
275+
[tool.coverage.paths]
276+
_site-packages-to-src-mapping = [
277+
"src",
278+
"*/src",
279+
'*\src',
280+
"*/lib/pypy*/site-packages",
281+
"*/lib/python*/site-packages",
282+
'*\Lib\site-packages',
283+
]
284+
271285
[tool.coverage.run]
272286
branch = true
273287
source_pkgs = ["trio"]
@@ -282,10 +296,15 @@ omit = [
282296
# The test suite spawns subprocesses to test some stuff, so make sure
283297
# this doesn't corrupt the coverage files
284298
parallel = true
299+
plugins = []
300+
relative_files = true
301+
source = ["."]
285302

286303
[tool.coverage.report]
287304
precision = 1
288305
skip_covered = true
306+
skip_empty = true
307+
show_missing = true
289308
exclude_lines = [
290309
"pragma: no cover",
291310
"abc.abstractmethod",
@@ -296,6 +315,9 @@ exclude_lines = [
296315
'class .*\bProtocol\b.*\):',
297316
"raise NotImplementedError",
298317
]
318+
exclude_also = [
319+
'^\s*@pytest\.mark\.xfail',
320+
]
299321
partial_branches = [
300322
"pragma: no branch",
301323
"if not TYPE_CHECKING:",

tests/cython/run_test_cython.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .test_cython import invoke_main_entry_point
2+
3+
invoke_main_entry_point()

tests/cython/test_cython.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ async def trio_main() -> None:
1919
nursery.start_soon(foo)
2020
nursery.start_soon(foo)
2121

22-
trio.run(trio_main)
22+
def invoke_main_entry_point():
23+
trio.run(trio_main)

0 commit comments

Comments
 (0)