-
Notifications
You must be signed in to change notification settings - Fork 5
325 lines (300 loc) · 15.5 KB
/
Copy pathnightly-health.yml
File metadata and controls
325 lines (300 loc) · 15.5 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
name: Nightly Health
# Run the full test suite (including tutorials) on the GPU runner every night.
#
# Schedule: 07:00 UTC daily ≈ 02:00 EST / 03:00 EDT
#
# Outputs:
# - GitHub Actions job summary (visible in the Actions UI after each run)
# - Artifact "health-dashboard": index.html + status.json (90-day retention)
# - Artifact "health-test-results": JUnit XML + coverage reports (90-day retention)
#
# The suite runs as two pytest invocations, core and tutorials, so that an
# overrunning tutorial cannot destroy the core suite's results.
#
# The dashboard is NOT deployed to GitHub Pages to avoid overwriting the
# documentation site published by docs.yml. Use the workflow status badge
# for a live pass/fail indicator in README:
#
# [](https://github.com/Project-MONAI/physiotwin4d/actions/workflows/nightly-health.yml)
on:
schedule:
- cron: '0 7 * * *' # 07:00 UTC = ~02:00 EST / 03:00 EDT
workflow_dispatch:
inputs:
reason:
description: 'Reason for manual trigger'
required: false
default: 'Manual health check'
# Branch selection is handled by the standard GitHub UI branch picker —
# no free-text ref input, so arbitrary non-default refs cannot be used
# to produce a misleading public artifact or dashboard.
permissions:
contents: read
jobs:
# ──────────────────────────────────────────────────────────────────────────
# 1. Run the full test suite on the GPU Windows runner
# ──────────────────────────────────────────────────────────────────────────
health-tests:
name: Health Tests (GPU)
runs-on: [self-hosted, Windows, X64, gpu]
timeout-minutes: 360
outputs:
# Captures the pytest steps' combined outcome (success / failure) for
# the dashboard. The job itself is failed by the gate step at the end,
# after the artifacts have been uploaded.
test-outcome: ${{ (steps.run-core-tests.outcome == 'success' && steps.run-tutorial-tests.outcome == 'success') && 'success' || 'failure' }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
lfs: true
- name: Check GPU availability
run: nvidia-smi
- name: Check nvcc availability
# torch-scatter compiles CUDA kernels from source when no matching
# pre-built wheel exists. Without nvcc on PATH the build silently falls
# back to a CPU-only extension that only fails later, at test time, with
# an opaque scatter error. Fail here instead.
run: |
$nvcc = Get-Command nvcc -ErrorAction SilentlyContinue
if (-not $nvcc) {
Write-Error "nvcc not found on PATH; torch-scatter would build CPU-only"
exit 1
}
Write-Output "nvcc found at $($nvcc.Source)"
nvcc --version
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Create venv in RUNNER_TEMP
# The newest interpreter the project supports, so this job is the one
# that catches a dependency shipping no wheel for it. ci.yml runs the
# floor (3.11) for the opposite reason. Both are on the runner.
run: |
& "C:\actions-runner\python\WPy64-3.13.12.0\python\python.exe" -m venv "$env:RUNNER_TEMP\physiotwin4d-venv"
echo "$env:RUNNER_TEMP\physiotwin4d-venv\Scripts" >> $env:GITHUB_PATH
- name: Cache uv packages
uses: actions/cache@v4
with:
path: ~\AppData\Local\uv\cache
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Cache test data
uses: actions/cache@v4
with:
path: |
tests/data/
tests/results/
key: test-data-${{ hashFiles('tests/test_*.py') }}-v2
restore-keys: |
test-data-
- name: Install uv and package
# Invoke via python -m uv so uv targets the active venv interpreter.
# The [physicsnemo] extra is required for --run-physicsnemo (Tutorial 9
# and any tests marked requires_physicsnemo).
#
# torch-scatter compiles against torch and imports it at build time, but
# declares neither torch nor setuptools as a build dependency. Its build
# therefore runs with isolation disabled (--no-build-isolation-package,
# passed explicitly rather than relying on uv discovering
# no-build-isolation-package in pyproject.toml), which makes the venv
# itself the build environment: setuptools, wheel, and torch must all be
# installed before the physicsnemo extra is resolved.
#
# torch, torchvision, and torchaudio are all pinned to the pytorch-cu130
# index here because the uv pip interface ignores tool.uv.sources.
# Pinning torch alone is not enough: the [cuda13] extra leaves the other
# two unconstrained, so they would resolve from PyPI and be built
# against a different CUDA runtime than torch. Installing all three up
# front means [cuda13] finds them already satisfied. --index-url (not
# --index) replaces PyPI for this command and matches the flag used in
# .readthedocs.yaml; the pytorch index also serves the transitive deps.
#
# PowerShell does not abort a multi-line run block when a native command
# exits non-zero, so each install is checked explicitly. Otherwise a
# failed prerequisite install is masked by the error it causes later.
run: |
python -m pip install --upgrade pip uv
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
python -m uv pip install setuptools wheel
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
python -m uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
python -c "import torch; print(f'build-time torch {torch.__version__} (CUDA {torch.version.cuda})')"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
python -m uv pip install -e ".[cuda13]"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
python -m uv pip install -e ".[test,docs,cuda13,dev,physicsnemo]" --no-build-isolation-package torch-scatter
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Assert CUDA is accessible
run: |
python -c "
import sys, torch, cupy
print(f'PyTorch {torch.__version__} | CUDA toolkit {torch.version.cuda} | CuPy {cupy.__version__}')
if not torch.cuda.is_available():
print('ERROR: torch.cuda.is_available() returned False', file=sys.stderr)
sys.exit(1)
n = torch.cuda.device_count()
if n == 0:
print('ERROR: torch.cuda.device_count() == 0', file=sys.stderr)
sys.exit(1)
cn = cupy.cuda.runtime.getDeviceCount()
if cn == 0:
print('ERROR: cupy.cuda.runtime.getDeviceCount() == 0', file=sys.stderr)
sys.exit(1)
print(f'OK: {n} GPU(s) visible to PyTorch and CuPy')
"
# The suite runs in two invocations rather than one. pytest-timeout on
# Windows can only kill the whole process, so a single overrunning
# tutorial used to take the JUnit XML, the coverage and every other
# test's result with it, leaving the dashboard nothing to render.
# Splitting the runs bounds that blast radius to one of them, and the
# tutorial run additionally isolates each test in an xdist worker.
#
# --max-test-seconds fails a test that finishes but took too long, so the
# overrun is reported with its duration and the rest of the suite still
# runs. --timeout is the pytest-timeout backstop above it, left to catch
# a genuine hang and nothing else. Both steps are continue-on-error so
# the artifacts are always uploaded; the gate step at the end fails the
# job.
- name: Run core test suite
id: run-core-tests
continue-on-error: true
run: |
pytest tests/ --ignore=tests/test_tutorials.py -v `
--run-all --require-tutorial-data `
--max-test-seconds=400 `
--timeout=900 `
--cov=physiotwin4d `
--junitxml=test-results-core.xml
env:
CUDA_VISIBLE_DEVICES: 0
# The datasets, the results and the trained networks live on the
# runner's own disk rather than in the checkout, which
# actions/checkout wipes every run. Each root has a "test" subtree
# that this suite reads and writes, so a nightly run never touches a
# full run's files, and the downsampled subsets the fixtures build
# under <input>/test survive between runs instead of being rebuilt.
# Unset, each falls back to its in-repo default; see data/README.md.
PHYSIOTWIN_INPUT_DATA_DIR: D:\PhysioTwin4D\nightly-runner\data
PHYSIOTWIN_OUTPUT_DATA_DIR: D:\PhysioTwin4D\nightly-runner\output
PHYSIOTWIN_WEIGHTS_DIR: D:\PhysioTwin4D\nightly-runner\network_weights
- name: Run tutorial test suite
id: run-tutorial-tests
continue-on-error: true
# -n 1 keeps the tutorials strictly serial -- they share one GPU, one
# "test" output subtree, and several bootstrap their prerequisite
# tutorial inline -- while running them in an xdist worker process.
# pytest-timeout then kills the worker rather than the session: xdist
# reports that test as crashed, starts a fresh worker and carries on,
# so an overrun costs one tutorial instead of the whole run.
#
# --cov-append adds to the core run's data, and the reports are written
# here so that they cover both runs.
#
# --timeout sits well above --max-test-seconds on purpose. Killing a
# worker discards everything the tutorial had printed, which is exactly
# the record needed to see where its time went, so the backstop must
# only catch a tutorial that will never finish. An overrun that does
# finish is reported by --max-test-seconds instead, with its duration
# and its output intact.
run: |
pytest tests/test_tutorials.py -v `
--run-all --require-tutorial-data `
-n 1 --max-worker-restart=40 `
--max-test-seconds=600 `
--timeout=2400 `
--cov=physiotwin4d `
--cov-append `
--cov-report=xml `
--cov-report=json `
--junitxml=test-results-tutorials.xml
env:
CUDA_VISIBLE_DEVICES: 0
# The datasets, the results and the trained networks live on the
# runner's own disk rather than in the checkout, which
# actions/checkout wipes every run. Each root has a "test" subtree
# that this suite reads and writes, so a nightly run never touches a
# full run's files, and the downsampled subsets the fixtures build
# under <input>/test survive between runs instead of being rebuilt.
# Unset, each falls back to its in-repo default; see data/README.md.
PHYSIOTWIN_INPUT_DATA_DIR: D:\PhysioTwin4D\nightly-runner\data
PHYSIOTWIN_OUTPUT_DATA_DIR: D:\PhysioTwin4D\nightly-runner\output
PHYSIOTWIN_WEIGHTS_DIR: D:\PhysioTwin4D\nightly-runner\network_weights
- name: Upload test results
uses: actions/upload-artifact@v6
if: always()
with:
name: health-test-results
path: |
test-results-core.xml
test-results-tutorials.xml
coverage.xml
coverage.json
retention-days: 90
- name: Fail the job if the test suite did not pass
# The pytest step is continue-on-error so that the artifacts and the
# dashboard are produced whatever happened. Without this gate the job
# would report success even when tests failed or the step timed out,
# and the workflow status badge would say green while nothing passed.
# build-dashboard runs on if: always(), so it still gets its inputs.
if: steps.run-core-tests.outcome != 'success' || steps.run-tutorial-tests.outcome != 'success'
run: |
Write-Output "Core suite outcome: ${{ steps.run-core-tests.outcome }}"
Write-Output "Tutorial suite outcome: ${{ steps.run-tutorial-tests.outcome }}"
Write-Output "See the health-test-results artifact for the JUnit XML."
exit 1
# ──────────────────────────────────────────────────────────────────────────
# 2. Build the HTML dashboard from test results (runs even if tests failed)
# ──────────────────────────────────────────────────────────────────────────
build-dashboard:
name: Build Dashboard
runs-on: ubuntu-latest
needs: health-tests
if: always()
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download test results
uses: actions/download-artifact@v6
with:
name: health-test-results
path: results/
# Artifact may be absent if health-tests was cancelled before upload.
continue-on-error: true
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Build dashboard
run: |
python .github/scripts/build_dashboard.py \
--results-dir results/ \
--output-dir dashboard/ \
--run-url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--timestamp "$(python -c 'from datetime import datetime, timezone; print(datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"))')" \
--health-outcome "${{ needs.health-tests.outputs.test-outcome }}"
- name: Write GitHub Actions job summary
run: cat dashboard/summary.md >> "$GITHUB_STEP_SUMMARY"
- name: Upload dashboard artifact
uses: actions/upload-artifact@v6
with:
name: health-dashboard
path: dashboard/
retention-days: 90
- name: Push status.json to nightly-status branch
# Force-push a single-file orphan branch so docs.yml can fetch
# status.json via the GitHub API and include it in the Pages bundle.
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
cp dashboard/status.json /tmp/status.json
git checkout --orphan nightly-status-tmp
git rm -rf . --quiet || true
cp /tmp/status.json status.json
git add status.json
git commit -m "chore: update nightly status [skip ci]"
git push origin HEAD:nightly-status --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}