From b73a09ac640a5d8882566ca415c355d1571460e9 Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Mon, 30 Mar 2026 16:33:51 +0800 Subject: [PATCH 1/5] coverage: add git safe.directory for linux builds --- .github/workflows/coverage.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3c0d4fa7009..ee5e6d50b2a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -67,6 +67,9 @@ jobs: with: fetch-depth: 0 + - name: Mark workspace as safe for git + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Install dependencies uses: ./.github/actions/install_unix_deps continue-on-error: false From 326a960b739d62a2a6f9928feeeaac95d8a35bed Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Wed, 1 Apr 2026 10:47:21 +0800 Subject: [PATCH 2/5] coverage: run coverage for linux without root --- .github/workflows/coverage.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ee5e6d50b2a..a3141de3f82 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -46,7 +46,6 @@ jobs: # Our self-hosted runners require a container # TODO: use a different (nvidia?) container container: - options: -u root --security-opt seccomp=unconfined --shm-size 16g image: ubuntu:22.04 env: NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }} @@ -67,9 +66,6 @@ jobs: with: fetch-depth: 0 - - name: Mark workspace as safe for git - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - - name: Install dependencies uses: ./.github/actions/install_unix_deps continue-on-error: false From ecf269f7e16e6c5e0330a29088c4032861f0c4b6 Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Tue, 7 Apr 2026 09:06:35 +0800 Subject: [PATCH 3/5] coverage: change github workspace owner for Linux coverage --- .github/workflows/coverage.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1884d79fa98..504a62b4311 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -46,6 +46,7 @@ jobs: # Our self-hosted runners require a container # TODO: use a different (nvidia?) container container: + options: -u root --security-opt seccomp=unconfined --shm-size 16g image: ubuntu:22.04 env: NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }} @@ -66,6 +67,10 @@ jobs: with: fetch-depth: 0 + - name: Fix workspace ownership + run: | + chown -R $(id -u):$(id -g) "$GITHUB_WORKSPACE" + - name: Install dependencies uses: ./.github/actions/install_unix_deps continue-on-error: false From ed96375114c7bce701a3906877dac5fe2d520340 Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Wed, 8 Apr 2026 16:26:52 +0800 Subject: [PATCH 4/5] coverage: run cuda core tests in coverage using 8M thread --- .github/workflows/coverage.yml | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 504a62b4311..f440e5f240c 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -380,11 +380,40 @@ jobs: sys.exit(result['code']) PYTEST_EOF - - name: Run cuda.core tests + # Same 8MB stack thread as bindings: Cython linetrace under coverage on Windows + # can need a larger stack than the default thread size. + - name: Run cuda.core tests (with 8MB stack) 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_core/tests" + "$GITHUB_WORKSPACE/.venv/Scripts/python" << PYTEST_EOF + import os + import sys + import threading + import pytest + + os.chdir(r'${{ steps.install-root.outputs.INSTALL_ROOT }}') + threading.stack_size(8 * 1024 * 1024) + result = {'code': 1} + + def _run(): + workspace = os.environ['GITHUB_WORKSPACE'] + result['code'] = pytest.main([ + '-v', + '--cov=./cuda', + '--cov-append', + '--cov-context=test', + f'--cov-config={workspace}/.coveragerc', + f'{workspace}/cuda_core/tests' + ]) + + t = threading.Thread(target=_run) + t.start() + t.join() + + print(f'cuda.core tests exit code: {result["code"]}') + sys.exit(result['code']) + PYTEST_EOF - name: Copy Windows coverage file to workspace run: | From d9ac8c6066c93d0a496c002002da075677e89b02 Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Wed, 15 Apr 2026 16:29:55 +0800 Subject: [PATCH 5/5] Add coverage test helper to run pytest using larger stack --- .github/workflows/coverage.yml | 76 ++++++------------------------- ci/tools/run_pytest_with_stack.py | 54 ++++++++++++++++++++++ 2 files changed, 67 insertions(+), 63 deletions(-) create mode 100644 ci/tools/run_pytest_with_stack.py diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ea301c0a4cc..95deb813f04 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -346,75 +346,25 @@ jobs: 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" + # Cython linetrace under coverage on Windows needs more stack than the + # default 1 MB thread size. The helper runs pytest on an 8 MB thread. - name: Run cuda.bindings tests (with 8MB stack) continue-on-error: true run: | - cd "${{ steps.install-root.outputs.INSTALL_ROOT }}" - # Run pytest in 8MB stack thread (Cython linetrace requirement) - "$GITHUB_WORKSPACE/.venv/Scripts/python" << PYTEST_EOF - import os - import sys - import threading - import pytest - - os.chdir(r'${{ steps.install-root.outputs.INSTALL_ROOT }}') - threading.stack_size(8 * 1024 * 1024) - result = {'code': 1} - - def _run(): - workspace = os.environ['GITHUB_WORKSPACE'] - result['code'] = pytest.main([ - '-v', - '--cov=./cuda', - '--cov-append', - '--cov-context=test', - f'--cov-config={workspace}/.coveragerc', - f'{workspace}/cuda_bindings/tests' - ]) - - t = threading.Thread(target=_run) - t.start() - t.join() - - print(f'Bindings tests exit code: {result["code"]}') - # Exit with actual code (continue-on-error handles it) - sys.exit(result['code']) - PYTEST_EOF - - # Same 8MB stack thread as bindings: Cython linetrace under coverage on Windows - # can need a larger stack than the default thread size. + "$GITHUB_WORKSPACE/.venv/Scripts/python" "$GITHUB_WORKSPACE/ci/tools/run_pytest_with_stack.py" \ + --cwd "${{ steps.install-root.outputs.INSTALL_ROOT }}" \ + -v --cov=./cuda --cov-append --cov-context=test \ + --cov-config="$GITHUB_WORKSPACE/.coveragerc" \ + "$GITHUB_WORKSPACE/cuda_bindings/tests" + - name: Run cuda.core tests (with 8MB stack) continue-on-error: true run: | - cd "${{ steps.install-root.outputs.INSTALL_ROOT }}" - "$GITHUB_WORKSPACE/.venv/Scripts/python" << PYTEST_EOF - import os - import sys - import threading - import pytest - - os.chdir(r'${{ steps.install-root.outputs.INSTALL_ROOT }}') - threading.stack_size(8 * 1024 * 1024) - result = {'code': 1} - - def _run(): - workspace = os.environ['GITHUB_WORKSPACE'] - result['code'] = pytest.main([ - '-v', - '--cov=./cuda', - '--cov-append', - '--cov-context=test', - f'--cov-config={workspace}/.coveragerc', - f'{workspace}/cuda_core/tests' - ]) - - t = threading.Thread(target=_run) - t.start() - t.join() - - print(f'cuda.core tests exit code: {result["code"]}') - sys.exit(result['code']) - PYTEST_EOF + "$GITHUB_WORKSPACE/.venv/Scripts/python" "$GITHUB_WORKSPACE/ci/tools/run_pytest_with_stack.py" \ + --cwd "${{ steps.install-root.outputs.INSTALL_ROOT }}" \ + -v --cov=./cuda --cov-append --cov-context=test \ + --cov-config="$GITHUB_WORKSPACE/.coveragerc" \ + "$GITHUB_WORKSPACE/cuda_core/tests" - name: Copy Windows coverage file to workspace run: | diff --git a/ci/tools/run_pytest_with_stack.py b/ci/tools/run_pytest_with_stack.py new file mode 100644 index 00000000000..e1e1f782ba1 --- /dev/null +++ b/ci/tools/run_pytest_with_stack.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +"""Run pytest on a thread with a larger stack size. + +Cython linetrace instrumentation under coverage on Windows can exceed the +default 1 MB thread stack. This helper spawns a single worker thread with +a configurable stack (default 8 MB) so the rest of the CI workflow stays +readable. + +Usage: + python run_pytest_with_stack.py [--stack-mb N] [--cwd DIR] [pytest args ...] +""" + +import argparse +import concurrent.futures +import os +import sys +import threading + +import pytest + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--stack-mb", + type=int, + default=8, + help="Thread stack size in megabytes (default: 8)", + ) + parser.add_argument( + "--cwd", + default=None, + help="Working directory for the test run", + ) + args, pytest_args = parser.parse_known_args() + + if args.cwd: + os.chdir(args.cwd) + + threading.stack_size(args.stack_mb * 1024 * 1024) + + with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool: + code = pool.submit(pytest.main, pytest_args).result() + + sys.exit(code) + + +if __name__ == "__main__": + main()