1
+ # Note: This name is referred to in the test job, so make sure any changes are sync'd up!
1
2
name : " CI: Build and test"
2
3
3
4
concurrency :
87
88
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
88
89
echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV
89
90
90
- # When the CI is run due to merging to main, we want it to populate GHA Cache not Artifacts,
91
- # so that CI workflows running on every branch have a fallback to use.
92
- if [[ "${{ github.ref_name}}" == main ]]; then
93
- echo "USE_CACHE=1" >> $GITHUB_ENV
94
- else
95
- echo "USE_CACHE=0" >> $GITHUB_ENV
96
- fi
97
-
98
- # TODO: revert me before merging; this is to test the cache restore in the PR
99
- echo "USE_CACHE=1" >> $GITHUB_ENV
100
-
101
- - name : Install dependencies
102
- if : ${{ env.USE_CACHE == '1' }}
103
- uses : ./.github/actions/install_unix_deps
104
- continue-on-error : false
105
- with :
106
- # For GHA Cache
107
- dependencies : " zstd"
108
- dependent_exes : " zstd"
109
-
110
91
- name : Dump environment
111
92
run : |
112
93
env
@@ -137,37 +118,13 @@ jobs:
137
118
twine check ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
138
119
139
120
- name : Upload cuda.core build artifacts
140
- if : ${{ env.USE_CACHE == '0' }}
141
121
uses : actions/upload-artifact@v4
142
122
with :
143
123
name : ${{ env.CUDA_CORE_ARTIFACT_NAME }}
144
124
path : ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
145
125
if-no-files-found : error
146
126
overwrite : ' true'
147
127
148
- - name : Prepare cuda.core cache
149
- if : ${{ env.USE_CACHE == '1' }}
150
- env :
151
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
152
- run : |
153
- if [[ "${{ env.USE_CACHE }}" == 1 ]]; then
154
- # this file is uploaded to GHA Cache
155
- tar -c -f "${{ env.CUDA_CORE_ARTIFACT_BASENAME }}.tar.gz" -C "${{ env.CUDA_CORE_ARTIFACTS_DIR }}" .
156
- du -h "${{ env.CUDA_CORE_ARTIFACT_BASENAME }}.tar.gz"
157
- # check if the previous runs from the same PR have populated the cache, if so need to clean it up
158
- CACHE_KEY=${{ env.CUDA_CORE_ARTIFACT_NAME }}
159
- if [ $(gh cache list | grep $CACHE_KEY | wc -l) == "1" ]; then
160
- gh cache delete $CACHE_KEY
161
- fi
162
- fi
163
-
164
- - name : Cache cuda.core build artifacts
165
- if : ${{ env.USE_CACHE == '1' }}
166
- uses : actions/cache/save@v4
167
- with :
168
- key : ${{ env.CUDA_CORE_ARTIFACT_NAME }}
169
- path : ${{ env.CUDA_CORE_ARTIFACT_BASENAME }}.tar.gz
170
-
171
128
- name : Set up mini CTK
172
129
uses : ./.github/actions/fetch_ctk
173
130
continue-on-error : false
@@ -207,38 +164,14 @@ jobs:
207
164
# run: |
208
165
# twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
209
166
210
- - name : Prepare cuda.bindings cache
211
- if : ${{ env.USE_CACHE == '1' }}
212
- env :
213
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
214
- run : |
215
- if [[ "${{ env.USE_CACHE }}" == 1 ]]; then
216
- # this file is uploaded to GHA Cache
217
- tar -c -f "${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}.tar.gz" -C "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}" .
218
- du -h "${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}.tar.gz"
219
- # check if the previous runs from the same PR have populated the cache, if so need to clean it up
220
- CACHE_KEY=${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
221
- if [ $(gh cache list | grep $CACHE_KEY | wc -l) == "1" ]; then
222
- gh cache delete $CACHE_KEY
223
- fi
224
- fi
225
-
226
167
- name : Upload cuda.bindings build artifacts
227
- if : ${{ env.USE_CACHE == '0' }}
228
168
uses : actions/upload-artifact@v4
229
169
with :
230
170
name : ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
231
171
path : ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
232
172
if-no-files-found : error
233
173
overwrite : ' true'
234
174
235
- - name : Cache cuda.bindings build artifacts
236
- if : ${{ env.USE_CACHE == '1' }}
237
- uses : actions/cache/save@v4
238
- with :
239
- key : ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
240
- path : ${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}.tar.gz
241
-
242
175
- name : Pass environment variables to the next runner
243
176
id : pass_env
244
177
run : |
@@ -322,6 +255,7 @@ jobs:
322
255
323
256
# make outputs from the previous job as env vars
324
257
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}"
258
+ echo "PYTHON_VERSION_FORMATTED=${PYTHON_VERSION_FORMATTED}" >> $GITHUB_ENV
325
259
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
326
260
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
327
261
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
@@ -335,86 +269,51 @@ jobs:
335
269
uses : ./.github/actions/install_unix_deps
336
270
continue-on-error : false
337
271
with :
338
- # zstd for GHA Cache, gcc for Cython tests
339
- dependencies : " zstd build-essential"
340
- dependent_exes : " zstd gcc"
272
+ # gcc for Cython tests, jq/wget for artifact fetching
273
+ dependencies : " build-essential jq wget "
274
+ dependent_exes : " gcc jq wget "
341
275
342
- # We'll try GHA Artifacts first, and then fall back to GHA Cache
343
276
- name : Download cuda.bindings build artifacts
344
- id : cuda-bindings-download
277
+ if : ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}}
345
278
uses : actions/download-artifact@v4
346
- continue-on-error : true
347
279
with :
348
280
name : ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
349
281
path : ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
350
282
351
- - name : Restore cuda.bindings cache
352
- if : ${{ steps.cuda-bindings-download.outcome == 'failure' }}
353
- id : cuda-bindings-cache
354
- uses : actions/cache/restore@v4
355
- with :
356
- key : ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
357
- path : ${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}.tar.gz
358
- restore-keys : ${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}
359
- fail-on-cache-miss : true
360
-
361
- - name : Report cache restore status
362
- if : ${{ steps.cuda-bindings-cache.outcome != 'skipped' }}
283
+ - name : Download cuda.bindings build artifacts from the prior branch
284
+ if : ${{ env.SKIP_CUDA_BINDINGS_TEST == '1'}}
285
+ env :
286
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
363
287
run : |
364
- if [[ "${{ steps.cuda-bindings-cache.outputs.cache-hit }}" == true ]]; then
365
- echo "cache is found"
366
- else
367
- echo "cache is not found"
368
- exit 1
369
- fi
370
- CACHE_DIR="${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
371
- CACHE_ARCHIVE="${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}.tar.gz"
372
- ls -l $CACHE_ARCHIVE
373
- mkdir -p $CACHE_DIR
374
- du -h $CACHE_ARCHIVE &&
375
- tar -x -f $CACHE_ARCHIVE -C $CACHE_DIR &&
376
- rm -f $CACHE_ARCHIVE || exit 1
288
+ # See https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt.
289
+ # gh is needed for artifact fetching.
290
+ mkdir -p -m 755 /etc/apt/keyrings \
291
+ && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
292
+ && cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
293
+ && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
294
+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
295
+ && apt update \
296
+ && apt install gh -y
297
+
298
+ OLD_BRANCH=$(cat .github/BACKPORT_BRANCH)
299
+ OLD_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda*-${{ matrix.host-platform }}*"
300
+ LATEST_PRIOR_RUN_ID=$(gh run list -b ${OLD_BRANCH} -L 1 -w "CI: Build and test" -s completed -R NVIDIA/cuda-python --json databaseId | jq '.[]| .databaseId')
301
+ gh run download $LATEST_PRIOR_RUN_ID -p ${OLD_BASENAME} -R NVIDIA/cuda-python
302
+ ls -al $OLD_BASENAME
303
+ mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
304
+ mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"/
377
305
378
306
- name : Display structure of downloaded cuda.bindings artifacts
379
307
run : |
380
308
pwd
381
309
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
382
310
383
311
- name : Download cuda.core build artifacts
384
- id : cuda-core-download
385
312
uses : actions/download-artifact@v4
386
- continue-on-error : true
387
313
with :
388
314
name : ${{ env.CUDA_CORE_ARTIFACT_NAME }}
389
315
path : ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
390
316
391
- - name : Restore cuda.core cache
392
- if : ${{ steps.cuda-core-download.outcome == 'failure' }}
393
- id : cuda-core-cache
394
- uses : actions/cache/restore@v4
395
- with :
396
- key : ${{ env.CUDA_CORE_ARTIFACT_NAME }}
397
- path : ${{ env.CUDA_CORE_ARTIFACT_BASENAME }}.tar.gz
398
- restore-keys : ${{ env.CUDA_CORE_ARTIFACT_BASENAME }}
399
- fail-on-cache-miss : true
400
-
401
- - name : Report cache restore status
402
- if : ${{ steps.cuda-core-cache.outcome != 'skipped' }}
403
- run : |
404
- if [[ "${{ steps.cuda-core-cache.outputs.cache-hit }}" == true ]]; then
405
- echo "cache is found"
406
- else
407
- echo "cache is not found"
408
- exit 1
409
- fi
410
- CACHE_DIR="${{ env.CUDA_CORE_ARTIFACTS_DIR }}"
411
- CACHE_ARCHIVE="${{ env.CUDA_CORE_ARTIFACT_BASENAME }}.tar.gz"
412
- ls -l $CACHE_ARCHIVE
413
- mkdir -p $CACHE_DIR
414
- du -h $CACHE_ARCHIVE &&
415
- tar -x -f $CACHE_ARCHIVE -C $CACHE_DIR &&
416
- rm -f $CACHE_ARCHIVE || exit 1
417
-
418
317
- name : Display structure of downloaded cuda.core build artifacts
419
318
run : |
420
319
pwd
@@ -458,16 +357,13 @@ jobs:
458
357
459
358
- name : Run cuda.core tests
460
359
run : |
461
- if [[ ${{ matrix.python-version }} == "3.13" ]]; then
462
- # TODO: remove this hack once cuda-python has a cp313 build
463
- if [[ $SKIP_CUDA_BINDINGS_TEST == 1 ]]; then
464
- echo "Python 3.13 + cuda-python ${{ matrix.cuda-version }} is not supported, skipping the test..."
465
- exit 0
466
- fi
467
- fi
468
-
469
360
# If build/test majors match: cuda.bindings is installed in the previous step.
470
- # If mismatch: cuda.bindings is installed from PyPI.
361
+ # If mismatch: cuda.bindings is installed from the backport branch.
362
+ if [[ "${SKIP_CUDA_BINDINGS_TEST}" == 1 ]]; then
363
+ pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
364
+ pip install *.whl
365
+ popd
366
+ fi
471
367
TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ matrix.cuda-version }})"
472
368
pushd "${CUDA_CORE_ARTIFACTS_DIR}"
473
369
pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}"]
0 commit comments