Skip to content

Commit

Permalink
🧪 Collect Cython coverage in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Nov 23, 2023
1 parent 777acc9 commit 8667bf4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ show_missing = true
[run]
branch = true
cover_pylib = false
plugins = Cython.Coverage
relative_files = true
source =
tests
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ jobs:
os: ${{ matrix.os }}
source-tarball-name: ${{ needs.pre-setup.outputs.sdist-name }}
dists-artifact-name: ${{ needs.pre-setup.outputs.dists-artifact-name }}
cython-tracing: >- # Cython line tracing for coverage collection
${{
(
github.event_name == 'push'
&& contains(github.ref, 'refs/tags/')
)
&& '0'
|| '1'
}}
test:
name: Test
Expand Down Expand Up @@ -202,6 +211,17 @@ jobs:
shell: bash
- name: Self-install
run: python -Im pip install '${{ steps.wheel-file.outputs.path }}'
- name: Produce the C-files for the Coverage.py Cython plugin
if: >- # Only works if the dists were built with line tracing
!matrix.no-extensions
&& (
github.event_name != 'push'
|| !contains(github.ref, 'refs/tags/')
)
run: |
set -eEuo pipefail
python -Im cython yarl/*.pyx
shell: bash
- name: Run unittests
env:
YARL_NO_EXTENSIONS: ${{ matrix.no-extensions }}
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/reusable-build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
description: Workflow artifact name containing dists
required: true
type: string
cython-tracing:
description: Whether to build Cython modules with line tracing
default: '0'
required: false
type: string
os:
description: VM OS to use, without version suffix
default: ubuntu
Expand Down Expand Up @@ -64,6 +69,9 @@ jobs:
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
CIBW_ENVIRONMENT: >- # Cython line tracing for coverage collection
PIP_CONSTRAINT="requirements/cython.txt"
YARL_CYTHON_TRACING="${{ inputs.cython-tracing }}"
- name: Upload built artifacts for testing and publishing
uses: actions/upload-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-r cython.txt
idna==3.4
multidict==6.0.4
pytest==7.4.3
Expand Down

0 comments on commit 8667bf4

Please sign in to comment.