-
Notifications
You must be signed in to change notification settings - Fork 253
492 lines (418 loc) · 16.1 KB
/
coverage.yml
File metadata and controls
492 lines (418 loc) · 16.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
name: "CI: Coverage"
on:
schedule:
- cron: '0 0 * * *' # This runs the workflow every day at 12:00 AM UTC
workflow_dispatch: {}
env:
PY_VER: "3.14"
CUDA_VER: "13.1.0"
LOCAL_CTK: "1"
GPU: "a100"
DRIVER: "latest"
jobs:
coverage-linux:
name: Coverage (Linux)
runs-on: "linux-amd64-gpu-a100-latest-1"
permissions:
id-token: write
contents: write
defaults:
run:
shell: bash --noprofile --norc -xeuo pipefail {0}
env:
HOST_PLATFORM: "linux-64"
ARCH: "x86_64"
# 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 }}
steps:
- name: Ensure GPU is working
run: nvidia-smi
# We have to install git before checking out the repo (so that we can
# deploy the docs at the end). This means we can't use install_unix_deps
# action so install the git package.
- name: Install git
run: |
apt-get update
apt-get install -y git
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Install dependencies
uses: ./.github/actions/install_unix_deps
continue-on-error: false
with:
dependencies: "tree rsync libsqlite3-0 g++ jq wget libgl1 libegl1"
dependent_exes: "tree rsync libsqlite3-0 g++ jq wget libgl1 libegl1"
- name: Setup proxy cache
uses: nv-gha-runners/setup-proxy-cache@main
continue-on-error: true
- name: Set environment variables
env:
BUILD_CUDA_VER: ${{ env.CUDA_VER }}
CUDA_VER: ${{ env.CUDA_VER }}
HOST_PLATFORM: ${{ env.HOST_PLATFORM }}
LOCAL_CTK: ${{ env.LOCAL_CTK }}
PY_VER: ${{ env.PY_VER }}
SHA: ${{ github.sha }}
run: |
./ci/tools/env-vars test
echo "CUDA_PYTHON_COVERAGE=1" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ env.PY_VER }}
env:
# we use self-hosted runners on which setup-python behaves weirdly...
AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache"
- name: Set up mini CTK
if: ${{ env.LOCAL_CTK == '1' }}
uses: ./.github/actions/fetch_ctk
continue-on-error: false
with:
host-platform: ${{ env.HOST_PLATFORM }}
cuda-version: ${{ env.CUDA_VER }}
- name: Create venv
run: |
python -m venv .venv
- name: Build cuda-pathfinder
run: |
cd cuda_pathfinder
../.venv/bin/pip install -v . --group test
- name: Build cuda-bindings
run: |
cd cuda_bindings
../.venv/bin/pip install -v . --group test
- name: Build cuda-core
run: |
cd cuda_core
../.venv/bin/pip install -v . --group test
- name: Install coverage tools
run: |
.venv/bin/pip install coverage pytest-cov Cython
- name: Set cuda package install root
run: |
echo "INSTALL_ROOT=$(.venv/bin/python -c 'import cuda; import os; print(os.path.dirname(cuda.__path__[0]))')" >> $GITHUB_ENV
echo "REPO_ROOT=$(pwd)" >> $GITHUB_ENV
- name: Run cuda.pathfinder 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_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/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
- name: Copy Linux coverage file to workspace
run: |
cp $INSTALL_ROOT/.coverage $REPO_ROOT/.coverage.linux
echo "Copied .coverage.linux to $REPO_ROOT"
ls -lh $REPO_ROOT/.coverage.linux
- name: Upload Linux coverage data
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: coverage-data-linux
path: .coverage.linux
retention-days: 7
include-hidden-files: true
if-no-files-found: error
- name: Upload cuda source code for coverage mapping
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: cuda-source-linux
path: ${{ env.INSTALL_ROOT }}/cuda/
retention-days: 7
if-no-files-found: error
# Build Windows wheels on GitHub-hosted runner (has VS, no GPU)
build-wheel-windows:
name: Build Wheels (Windows)
runs-on: windows-2022
permissions:
contents: read
defaults:
run:
shell: bash --noprofile --norc -xeuo pipefail {0}
env:
HOST_PLATFORM: "win-64"
CUDA_PYTHON_COVERAGE: "1"
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ env.PY_VER }}
- name: Set up MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Set up mini CTK
uses: ./.github/actions/fetch_ctk
continue-on-error: false
with:
host-platform: win-64
cuda-version: ${{ env.CUDA_VER }}
- name: Create venv
run: |
python -m venv .venv
- name: Build and install cuda.pathfinder
run: |
.venv/Scripts/pip install wheel setuptools Cython
.venv/Scripts/pip wheel -v --no-deps ./cuda_pathfinder -w ./wheels/
- name: Build cuda.bindings wheel
run: |
cd cuda_bindings
../.venv/Scripts/pip wheel -v --no-deps . -w ../wheels/
- name: Build cuda.core wheel
run: |
export PIP_FIND_LINKS="$(pwd)/wheels"
export PIP_PRE=1
cd cuda_core
../.venv/Scripts/pip wheel -v --no-deps . -w ../wheels/
- name: List wheel artifacts
run: |
echo "=== Windows wheel artifacts ==="
ls -lahR ./wheels/
- name: Upload Windows wheel artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: coverage-windows-wheels
path: ./wheels/*.whl
retention-days: 1
if-no-files-found: error
# Run coverage tests on self-hosted GPU runner (no VS needed, installs pre-built wheels)
coverage-windows:
name: Coverage (Windows)
needs: [build-wheel-windows]
runs-on: "windows-amd64-gpu-a100-latest-1"
permissions:
id-token: write
contents: write
env:
HOST_PLATFORM: "win-64"
ARCH: "amd64"
CUDA_PYTHON_COVERAGE: "1"
defaults:
run:
shell: bash --noprofile --norc -xeuo pipefail {0}
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup proxy cache
uses: nv-gha-runners/setup-proxy-cache@main
continue-on-error: true
- name: Update driver
shell: powershell
env:
DRIVER_MODE: "TCC"
GPU_TYPE: "a100"
run: |
ci/tools/install_gpu_driver.ps1
- name: Ensure GPU is working
run: |
nvidia-smi
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ env.PY_VER }}
- name: Set up mini CTK
uses: ./.github/actions/fetch_ctk
continue-on-error: false
with:
host-platform: win-64
cuda-version: ${{ env.CUDA_VER }}
- name: Download Windows wheel artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: coverage-windows-wheels
path: ./wheels/
- name: List downloaded wheel artifacts
run: |
echo "=== Downloaded wheel artifacts ==="
ls -lahR ./wheels/
- name: Create venv
run: |
python -m venv .venv
- name: Install wheels from build job
run: |
.venv/Scripts/pip install ./wheels/cuda_pathfinder*.whl
echo "Installed cuda.pathfinder"
.venv/Scripts/pip install ./wheels/cuda_bindings*.whl
echo "Installed cuda.bindings"
.venv/Scripts/pip install ./wheels/cuda_core*.whl
echo "Installed cuda.core"
- name: Install test dependencies and coverage tools
run: |
.venv/Scripts/pip install -v ./cuda_python_test_helpers
.venv/Scripts/pip install coverage pytest-cov Cython
.venv/Scripts/pip install --group ./cuda_pathfinder/pyproject.toml:test
.venv/Scripts/pip install --group ./cuda_bindings/pyproject.toml:test
.venv/Scripts/pip install --group ./cuda_core/pyproject.toml:test
- name: Get install root
id: install-root
run: |
INSTALL_ROOT=$(.venv/Scripts/python -c 'import cuda; import os; print(os.path.dirname(cuda.__path__[0]))')
echo "INSTALL_ROOT=$INSTALL_ROOT" >> $GITHUB_OUTPUT
echo "Install root: $INSTALL_ROOT"
- name: Run cuda.pathfinder tests
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"
- 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
- name: Run cuda.core tests
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"
- name: Copy Windows coverage file to workspace
run: |
cp "${{ steps.install-root.outputs.INSTALL_ROOT }}/.coverage" "$GITHUB_WORKSPACE/.coverage.windows"
echo "Copied .coverage.windows to $GITHUB_WORKSPACE"
ls -lh "$GITHUB_WORKSPACE/.coverage.windows"
- name: Upload Windows coverage data
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: coverage-data-windows
path: .coverage.windows
retention-days: 7
include-hidden-files: true
if-no-files-found: error
combine-and-deploy:
name: Combine Coverage and Deploy
needs: [coverage-linux, coverage-windows]
runs-on: ubuntu-latest
if: always()
permissions:
id-token: write
contents: write
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ env.PY_VER }}
- name: Install coverage
run: |
# .coveragerc enables Cython.Coverage plugin; ensure it's available here too.
pip install coverage[toml] Cython
- name: Download Linux coverage data
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: coverage-data-linux
path: ./
- name: Download cuda source code
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: cuda-source-linux
path: ./cuda/
- name: Download Windows coverage data
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: coverage-data-windows
path: ./
- name: Combine coverage data
run: |
echo "=== Working directory ==="
pwd
echo ""
echo "=== All files in root ==="
ls -la
echo ""
# Verify both Linux and Windows coverage files exist
echo "=== Checking coverage files ==="
if [ ! -f ".coverage.linux" ]; then
echo "[ERROR] .coverage.linux not found!"
exit 1
fi
echo "[OK] Found .coverage.linux"
if [ ! -f ".coverage.windows" ]; then
echo "[ERROR] .coverage.windows not found!"
exit 1
fi
echo "[OK] Found .coverage.windows"
echo "=== Available coverage files ==="
ls -lh .coverage.*
echo "=== Cuda source structure ==="
find ./cuda -type d || {
echo "[ERROR] No cuda source directory!"
exit 1
}
# Combine all .coverage.* files
echo ""
echo "=== Combining coverage data ==="
coverage combine --rcfile=./.coveragerc --keep .coverage.*
# Generate reports
echo ""
echo "=== Generating HTML, XML, and text reports ==="
coverage html --rcfile=./.coveragerc
coverage xml --rcfile=./.coveragerc -o coverage.xml
coverage report --rcfile=./.coveragerc
# Prepare for upload
mkdir -p ./docs/coverage
mv htmlcov/* ./docs/coverage/
mv coverage.xml ./docs/coverage/
echo ""
echo "[SUCCESS] Coverage reports generated successfully"
- name: Archive combined coverage results
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: coverage-combined
path: docs/coverage/
retention-days: 7
include-hidden-files: true
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
with:
git-config-name: cuda-python-bot
git-config-email: cuda-python-bot@users.noreply.github.com
folder: docs/
target-folder: docs/
commit-message: "Deploy combined coverage (Linux + Windows): ${{ github.sha }}"
clean: false