From c86cdbdb7ce80ee42e066b85f9c09a2aa8ffade7 Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Wed, 4 Nov 2026 16:40:48 +0800 Subject: [PATCH] ci: capture coverage before pytest imports Signed-off-by: Rui Luo --- .coveragerc | 1 + .github/workflows/coverage.yml | 32 ++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.coveragerc b/.coveragerc index 46993e6abcc..9f5a9807e65 100644 --- a/.coveragerc +++ b/.coveragerc @@ -9,6 +9,7 @@ source = [run] plugins = Cython.Coverage core = ctrace +dynamic_context = test_function branch = False relative_files = True # Cython.Coverage cannot build a FileReporter for .pxd/.pxi (not standalone diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f75ac200b06..a9746b4a75f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -173,19 +173,26 @@ jobs: continue-on-error: true run: | cd $INSTALL_ROOT - $REPO_ROOT/.venv/bin/pytest -v --cov=./cuda --cov-append --cov-context=test --cov-config=$REPO_ROOT/.coveragerc $REPO_ROOT/cuda_pathfinder/tests + "$REPO_ROOT/.venv/bin/python" -m coverage run \ + --append --source=./cuda --rcfile="$REPO_ROOT/.coveragerc" \ + -m pytest -p no:pytest_cov -v "$REPO_ROOT/cuda_pathfinder/tests" - name: Run cuda.bindings tests continue-on-error: true run: | cd $INSTALL_ROOT - $REPO_ROOT/.venv/bin/pytest -v --cov=./cuda --cov-append --cov-context=test --cov-config=$REPO_ROOT/.coveragerc $REPO_ROOT/cuda_bindings_13/tests + "$REPO_ROOT/.venv/bin/python" -m coverage run \ + --append --source=./cuda --rcfile="$REPO_ROOT/.coveragerc" \ + -m pytest -p no:pytest_cov -v "$REPO_ROOT/cuda_bindings_13/tests" - name: Run cuda.core tests continue-on-error: true run: | cd $INSTALL_ROOT - $REPO_ROOT/.venv/bin/pytest -v --cov=./cuda --cov-append --cov-context=test --cov-config=$REPO_ROOT/.coveragerc $REPO_ROOT/cuda_core/tests + # Start tracing before pytest imports warning categories from helpers. + "$REPO_ROOT/.venv/bin/python" -m coverage run \ + --append --source=./cuda --rcfile="$REPO_ROOT/.coveragerc" \ + -m pytest -p no:pytest_cov -v "$REPO_ROOT/cuda_core/tests" - name: Copy Linux coverage file to workspace run: | @@ -427,7 +434,9 @@ jobs: continue-on-error: true run: | cd "${{ steps.install-root.outputs.INSTALL_ROOT }}" - "$GITHUB_WORKSPACE/.venv/Scripts/pytest" -v --cov=./cuda --cov-append --cov-context=test --cov-config="$GITHUB_WORKSPACE/.coveragerc" "$GITHUB_WORKSPACE/cuda_pathfinder/tests" + "$GITHUB_WORKSPACE/.venv/Scripts/python" -m coverage run \ + --append --source=./cuda --rcfile="$GITHUB_WORKSPACE/.coveragerc" \ + -m pytest -p no:pytest_cov -v "$GITHUB_WORKSPACE/cuda_pathfinder/tests" # The patched interpreter provides the larger stack on the main thread # and in child interpreters. Deferred cleanup needs pytest on the main thread. @@ -435,19 +444,18 @@ jobs: continue-on-error: true run: | cd "${{ steps.install-root.outputs.INSTALL_ROOT }}" - "$GITHUB_WORKSPACE/.venv/Scripts/python" -m pytest \ - -v --cov=./cuda --cov-append --cov-context=test \ - --cov-config="$GITHUB_WORKSPACE/.coveragerc" \ - "$GITHUB_WORKSPACE/cuda_bindings_13/tests" + "$GITHUB_WORKSPACE/.venv/Scripts/python" -m coverage run \ + --append --source=./cuda --rcfile="$GITHUB_WORKSPACE/.coveragerc" \ + -m pytest -p no:pytest_cov -v "$GITHUB_WORKSPACE/cuda_bindings_13/tests" - name: Run cuda.core tests continue-on-error: true run: | cd "${{ steps.install-root.outputs.INSTALL_ROOT }}" - "$GITHUB_WORKSPACE/.venv/Scripts/python" -m pytest \ - -v --cov=./cuda --cov-append --cov-context=test \ - --cov-config="$GITHUB_WORKSPACE/.coveragerc" \ - "$GITHUB_WORKSPACE/cuda_core/tests" + # Start tracing before pytest imports warning categories from helpers. + "$GITHUB_WORKSPACE/.venv/Scripts/python" -m coverage run \ + --append --source=./cuda --rcfile="$GITHUB_WORKSPACE/.coveragerc" \ + -m pytest -p no:pytest_cov -v "$GITHUB_WORKSPACE/cuda_core/tests" - name: Copy Windows coverage file to workspace run: |