1+ name : Coverage
2+ on :
3+ pull_request : {}
4+ workflow_dispatch : {}
5+ env :
6+ UV_PYTHON_PREFERENCE : only-system
7+ UV_NO_SYNC : " 1"
8+ PKCS11_TOKEN_LABEL : " TEST"
9+ PKCS11_TOKEN_PIN : " 1234"
10+ PKCS11_TOKEN_SO_PIN : " 5678"
11+ jobs :
12+ # For now, we run the coverage as a separate job.
13+ # At the time of writing, the latest version of Cython's line tracing
14+ # seems to lead to segfaults in Python 3.13 -> TODO: investigate
15+ pytest-coverage :
16+ runs-on : ubuntu-latest
17+ steps :
18+ - name : Acquire sources
19+ uses : actions/checkout@v4
20+
21+ - name : Setup Python
22+ uses : actions/setup-python@v5
23+ with :
24+ python-version : 3.12
25+ - uses : ./.github/actions/install-softhsm
26+ id : softhsm
27+ with :
28+ os : ubuntu-latest
29+ token-label : ${{ env.PKCS11_TOKEN_LABEL }}
30+ token-so-pin : ${{ env.PKCS11_TOKEN_SO_PIN }}
31+ token-user-pin : ${{ env.PKCS11_TOKEN_PIN }}
32+ - uses : ./.github/actions/install-opencryptoki
33+ # only run opencryptoki tests on ubuntu
34+ # (macos and windows don't seem to be supported)
35+ id : opencryptoki
36+ with :
37+ os : ubuntu-latest
38+ token-label : ${{ env.PKCS11_TOKEN_LABEL }}
39+ token-so-pin : ${{ env.PKCS11_TOKEN_SO_PIN }}
40+ token-user-pin : ${{ env.PKCS11_TOKEN_PIN }}
41+ - name : Install uv
42+ uses : astral-sh/setup-uv@v4
43+ with :
44+ enable-cache : true
45+ python-version : 3.12
46+ - name : Install testing dependencies
47+ run : uv sync --no-dev --exact --group coverage
48+ env :
49+ CFLAGS : " -DCYTHON_TRACE_NOGIL=1"
50+ EXT_BUILD_DEBUG : " 1"
51+ - name : Run tests with SoftHSM
52+ run : uv run pytest -v --cov=pkcs11 --cov-branch --cov-report=xml:python-softhsm-coverage.xml
53+ env :
54+ PKCS11_MODULE : ${{ steps.softhsm.outputs.module }}
55+ - name : Run tests with opencryptoki
56+ run : uv run pytest -v --cov=pkcs11 --cov-branch --cov-report=xml:python-opencryptoki-coverage.xml
57+ env :
58+ PKCS11_MODULE : ${{ steps.opencryptoki.outputs.module }}
59+ # For testing logic around swapping PKCS#11 libs
60+ PKCS11_MODULE2 : ${{ steps.softhsm.outputs.module }}
61+ - name : Stash coverage report
62+ uses : actions/upload-artifact@v4
63+ with :
64+ name : coverage
65+ path : " *-coverage.xml"
66+ codecov-upload :
67+ permissions :
68+ actions : write
69+ contents : read
70+ runs-on : ubuntu-latest
71+ needs : [pytest-coverage]
72+ steps :
73+ # checkout necessary to ensure the uploaded report contains the correct paths
74+ - uses : actions/checkout@v4
75+ - name : Retrieve coverage reports
76+ uses : actions/download-artifact@v4
77+ with :
78+ name : coverage
79+ path : ./reports/
80+ - name : Upload all coverage reports to Codecov
81+ uses : codecov/codecov-action@v5
82+ with :
83+ token : ${{ secrets.CODECOV_TOKEN }}
84+ directory : ./reports/
85+ flags : unittests
86+ env_vars : OS,PYTHON
87+ name : codecov-umbrella
0 commit comments