File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Coverage
2+ on :
3+ push :
4+ branches : ["**"]
5+ pull_request : {}
6+ workflow_dispatch : {}
7+ env :
8+ UV_PYTHON_PREFERENCE : only-system
9+ UV_NO_SYNC : " 1"
10+ jobs :
11+ # For now, we run the coverage as a separate job.
12+ # At the time of writing, the latest version of Cython's line tracing
13+ # seems to lead to segfaults in Python 3.13 -> TODO: investigate
14+ pytest-coverage :
15+ runs-on : ubuntu-latest
16+ steps :
17+ - name : Acquire sources
18+ uses : actions/checkout@v4
19+
20+ - name : Setup Python
21+ uses : actions/setup-python@v5
22+ with :
23+ python-version : 3.12
24+ - uses : ./.github/actions/install-softhsm
25+ with :
26+ os : ubuntu-latest
27+ - name : Install uv
28+ uses : astral-sh/setup-uv@v4
29+ with :
30+ enable-cache : true
31+ python-version : 3.12
32+ - name : Install testing dependencies
33+ run : uv sync --no-dev --exact --group coverage
34+ env :
35+ CFLAGS : " -DCYTHON_TRACE_NOGIL=1"
36+ EXT_BUILD_DEBUG : " 1"
37+ - name : Run tests
38+ run : uv run pytest -v --cov=pkcs11 --cov-branch --cov-report=xml:python-coverage.xml
39+ - name : Stash coverage report
40+ uses : actions/upload-artifact@v4
41+ with :
42+ name : coverage
43+ path : " *-coverage.xml"
44+ codecov-upload :
45+ permissions :
46+ actions : write
47+ contents : read
48+ runs-on : ubuntu-latest
49+ needs : [pytest-coverage]
50+ steps :
51+ # checkout necessary to ensure the uploaded report contains the correct paths
52+ - uses : actions/checkout@v4
53+ - name : Retrieve coverage reports
54+ uses : actions/download-artifact@v4
55+ with :
56+ name : coverage
57+ path : ./reports/
58+ - name : Upload all coverage reports to Codecov
59+ uses : codecov/codecov-action@v5
60+ with :
61+ token : ${{ secrets.CODECOV_TOKEN }}
62+ directory : ./reports/
63+ flags : unittests
64+ env_vars : OS,PYTHON
65+ name : codecov-umbrella
Original file line number Diff line number Diff line change @@ -6,4 +6,7 @@ __pycache__
66/dist /
77/docs /_build
88/python_pkcs11.egg-info /
9- /.eggs /
9+ /.eggs /
10+ .coverage
11+ * coverage.xml
12+ * .html
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ Definitions imported from PKCS11 C headers.
44
55from cython.view cimport array
66
7- from pkcs11.defaults import *
87from pkcs11.exceptions import *
98
109cdef extern from ' ../extern/cryptoki.h' :
Original file line number Diff line number Diff line change 11#!python
22#cython: language_level=3
3+ #cython: linetrace=True
34"""
45High-level Python PKCS#11 Wrapper.
56
Original file line number Diff line number Diff line change @@ -67,12 +67,35 @@ archs = ["universal2"]
6767[tool .setuptools .packages .find ]
6868include = [" pkcs11*" ]
6969
70+ [tool .coverage .run ]
71+ plugins = [" Cython.Coverage" ]
72+
73+ [tool .coverage .report ]
74+ exclude_lines = [
75+ " pragma: no cover" ,
76+ " pragma: nocover" ,
77+ " raise AssertionError" ,
78+ " raise NotImplementedError" ,
79+ " raise MemoryError" ,
80+ " raise TypeError" ,
81+ " TYPE_CHECKING" ,
82+ " ^\\ s*\\ .\\ .\\ ." ,
83+ " noqa"
84+ ]
85+ precision = 2
86+
7087[dependency-groups ]
7188testing = [
7289 " cryptography>=44.0.0" ,
7390 " parameterized>=0.9.0" ,
7491 " pytest>=8.3.4" ,
7592]
93+ coverage = [
94+ { include-group = " testing" },
95+ " coverage>=7.9.1" ,
96+ " pytest-cov>=4.0,<6.3" ,
97+ " cython" ,
98+ ]
7699docs = [
77100 " sphinx>=7.4.7" ,
78101 " sphinx-rtd-theme>=3.0.2" ,
You can’t perform that action at this time.
0 commit comments