diff --git a/.coveragerc b/.coveragerc index 2e47573f9..f15474e24 100644 --- a/.coveragerc +++ b/.coveragerc @@ -11,6 +11,7 @@ show_missing = true [run] branch = true cover_pylib = false +plugins = Cython.Coverage relative_files = true source = tests diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 544b21c8a..788f89c20 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -77,6 +77,15 @@ jobs: - name: Build sdists and pure-python wheel env: PIP_CONSTRAINT: requirements/cython.txt + YARL_CYTHON_TRACING: >- # Cython line tracing for coverage collection + ${{ + ( + github.event_name == 'push' + && contains(github.ref, 'refs/tags/') + ) + && '0' + || '1' + }} run: python -Im build --config-setting=--pure-python=true - name: Upload built artifacts for testing uses: actions/upload-artifact@v3 @@ -109,6 +118,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 @@ -202,6 +220,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 == 'Y' + && ( + 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 }} diff --git a/.github/workflows/reusable-build-wheel.yml b/.github/workflows/reusable-build-wheel.yml index 588790389..757529097 100644 --- a/.github/workflows/reusable-build-wheel.yml +++ b/.github/workflows/reusable-build-wheel.yml @@ -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 @@ -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 diff --git a/requirements/test.txt b/requirements/test.txt index bffbe96e4..2cadfd3fe 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,3 +1,4 @@ +-r cython.txt idna==3.4 multidict==6.0.4 pytest==7.4.3