Skip to content

Commit 0f6b290

Browse files
committed
ci: preserve pytest-cov while tracing core imports
Signed-off-by: Rui Luo <[email protected]>
1 parent ddfc213 commit 0f6b290

2 files changed

Lines changed: 26 additions & 17 deletions

File tree

‎.coveragerc‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ source =
99
[run]
1010
plugins = Cython.Coverage
1111
core = ctrace
12-
dynamic_context = test_function
1312
branch = False
1413
relative_files = True
1514
# Cython.Coverage cannot build a FileReporter for .pxd/.pxi (not standalone

‎.github/workflows/coverage.yml‎

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,26 +173,28 @@ jobs:
173173
continue-on-error: true
174174
run: |
175175
cd $INSTALL_ROOT
176-
"$REPO_ROOT/.venv/bin/python" -m coverage run \
177-
--append --source=./cuda --rcfile="$REPO_ROOT/.coveragerc" \
178-
-m pytest -p no:pytest_cov -v "$REPO_ROOT/cuda_pathfinder/tests"
176+
$REPO_ROOT/.venv/bin/pytest -v --cov=./cuda --cov-append --cov-context=test --cov-config=$REPO_ROOT/.coveragerc $REPO_ROOT/cuda_pathfinder/tests
179177
180178
- name: Run cuda.bindings tests
181179
continue-on-error: true
182180
run: |
183181
cd $INSTALL_ROOT
182+
$REPO_ROOT/.venv/bin/pytest -v --cov=./cuda --cov-append --cov-context=test --cov-config=$REPO_ROOT/.coveragerc $REPO_ROOT/cuda_bindings_13/tests
183+
184+
- name: Trace cuda.core imports
185+
continue-on-error: true
186+
run: |
187+
cd $INSTALL_ROOT
188+
# Trace collection-time imports before the regular pytest-cov run.
184189
"$REPO_ROOT/.venv/bin/python" -m coverage run \
185190
--append --source=./cuda --rcfile="$REPO_ROOT/.coveragerc" \
186-
-m pytest -p no:pytest_cov -v "$REPO_ROOT/cuda_bindings_13/tests"
191+
-m pytest -p no:pytest_cov --collect-only -qq "$REPO_ROOT/cuda_core/tests"
187192
188193
- name: Run cuda.core tests
189194
continue-on-error: true
190195
run: |
191196
cd $INSTALL_ROOT
192-
# Start tracing before pytest imports warning categories from helpers.
193-
"$REPO_ROOT/.venv/bin/python" -m coverage run \
194-
--append --source=./cuda --rcfile="$REPO_ROOT/.coveragerc" \
195-
-m pytest -p no:pytest_cov -v "$REPO_ROOT/cuda_core/tests"
197+
$REPO_ROOT/.venv/bin/pytest -v --cov=./cuda --cov-append --cov-context=test --cov-config=$REPO_ROOT/.coveragerc $REPO_ROOT/cuda_core/tests
196198
197199
- name: Copy Linux coverage file to workspace
198200
run: |
@@ -434,28 +436,36 @@ jobs:
434436
continue-on-error: true
435437
run: |
436438
cd "${{ steps.install-root.outputs.INSTALL_ROOT }}"
437-
"$GITHUB_WORKSPACE/.venv/Scripts/python" -m coverage run \
438-
--append --source=./cuda --rcfile="$GITHUB_WORKSPACE/.coveragerc" \
439-
-m pytest -p no:pytest_cov -v "$GITHUB_WORKSPACE/cuda_pathfinder/tests"
439+
"$GITHUB_WORKSPACE/.venv/Scripts/pytest" -v --cov=./cuda --cov-append --cov-context=test --cov-config="$GITHUB_WORKSPACE/.coveragerc" "$GITHUB_WORKSPACE/cuda_pathfinder/tests"
440440
441441
# The patched interpreter provides the larger stack on the main thread
442442
# and in child interpreters. Deferred cleanup needs pytest on the main thread.
443443
- name: Run cuda.bindings tests
444444
continue-on-error: true
445445
run: |
446446
cd "${{ steps.install-root.outputs.INSTALL_ROOT }}"
447+
"$GITHUB_WORKSPACE/.venv/Scripts/python" -m pytest \
448+
-v --cov=./cuda --cov-append --cov-context=test \
449+
--cov-config="$GITHUB_WORKSPACE/.coveragerc" \
450+
"$GITHUB_WORKSPACE/cuda_bindings_13/tests"
451+
452+
- name: Trace cuda.core imports
453+
continue-on-error: true
454+
run: |
455+
cd "${{ steps.install-root.outputs.INSTALL_ROOT }}"
456+
# Use a separate process so pytest-cov retains lifecycle contexts.
447457
"$GITHUB_WORKSPACE/.venv/Scripts/python" -m coverage run \
448458
--append --source=./cuda --rcfile="$GITHUB_WORKSPACE/.coveragerc" \
449-
-m pytest -p no:pytest_cov -v "$GITHUB_WORKSPACE/cuda_bindings_13/tests"
459+
-m pytest -p no:pytest_cov --collect-only -qq "$GITHUB_WORKSPACE/cuda_core/tests"
450460
451461
- name: Run cuda.core tests
452462
continue-on-error: true
453463
run: |
454464
cd "${{ steps.install-root.outputs.INSTALL_ROOT }}"
455-
# Start tracing before pytest imports warning categories from helpers.
456-
"$GITHUB_WORKSPACE/.venv/Scripts/python" -m coverage run \
457-
--append --source=./cuda --rcfile="$GITHUB_WORKSPACE/.coveragerc" \
458-
-m pytest -p no:pytest_cov -v "$GITHUB_WORKSPACE/cuda_core/tests"
465+
"$GITHUB_WORKSPACE/.venv/Scripts/python" -m pytest \
466+
-v --cov=./cuda --cov-append --cov-context=test \
467+
--cov-config="$GITHUB_WORKSPACE/.coveragerc" \
468+
"$GITHUB_WORKSPACE/cuda_core/tests"
459469
460470
- name: Copy Windows coverage file to workspace
461471
run: |

0 commit comments

Comments
 (0)