Skip to content

Commit c86cdbd

Browse files
committed
ci: capture coverage before pytest imports
Signed-off-by: Rui Luo <ruluo@nvidia.com>
1 parent 677fb9a commit c86cdbd

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

‎.coveragerc‎

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

‎.github/workflows/coverage.yml‎

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,26 @@ jobs:
173173
continue-on-error: true
174174
run: |
175175
cd $INSTALL_ROOT
176-
$REPO_ROOT/.venv/bin/pytest -v --cov=./cuda --cov-append --cov-context=test --cov-config=$REPO_ROOT/.coveragerc $REPO_ROOT/cuda_pathfinder/tests
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"
177179
178180
- name: Run cuda.bindings tests
179181
continue-on-error: true
180182
run: |
181183
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
184+
"$REPO_ROOT/.venv/bin/python" -m coverage run \
185+
--append --source=./cuda --rcfile="$REPO_ROOT/.coveragerc" \
186+
-m pytest -p no:pytest_cov -v "$REPO_ROOT/cuda_bindings_13/tests"
183187
184188
- name: Run cuda.core tests
185189
continue-on-error: true
186190
run: |
187191
cd $INSTALL_ROOT
188-
$REPO_ROOT/.venv/bin/pytest -v --cov=./cuda --cov-append --cov-context=test --cov-config=$REPO_ROOT/.coveragerc $REPO_ROOT/cuda_core/tests
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"
189196
190197
- name: Copy Linux coverage file to workspace
191198
run: |
@@ -427,27 +434,28 @@ jobs:
427434
continue-on-error: true
428435
run: |
429436
cd "${{ steps.install-root.outputs.INSTALL_ROOT }}"
430-
"$GITHUB_WORKSPACE/.venv/Scripts/pytest" -v --cov=./cuda --cov-append --cov-context=test --cov-config="$GITHUB_WORKSPACE/.coveragerc" "$GITHUB_WORKSPACE/cuda_pathfinder/tests"
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"
431440
432441
# The patched interpreter provides the larger stack on the main thread
433442
# and in child interpreters. Deferred cleanup needs pytest on the main thread.
434443
- name: Run cuda.bindings tests
435444
continue-on-error: true
436445
run: |
437446
cd "${{ steps.install-root.outputs.INSTALL_ROOT }}"
438-
"$GITHUB_WORKSPACE/.venv/Scripts/python" -m pytest \
439-
-v --cov=./cuda --cov-append --cov-context=test \
440-
--cov-config="$GITHUB_WORKSPACE/.coveragerc" \
441-
"$GITHUB_WORKSPACE/cuda_bindings_13/tests"
447+
"$GITHUB_WORKSPACE/.venv/Scripts/python" -m coverage run \
448+
--append --source=./cuda --rcfile="$GITHUB_WORKSPACE/.coveragerc" \
449+
-m pytest -p no:pytest_cov -v "$GITHUB_WORKSPACE/cuda_bindings_13/tests"
442450
443451
- name: Run cuda.core tests
444452
continue-on-error: true
445453
run: |
446454
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_core/tests"
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"
451459
452460
- name: Copy Windows coverage file to workspace
453461
run: |

0 commit comments

Comments
 (0)