Skip to content

Commit 75e37bd

Browse files
committed
implement a custom download-artifact step to simplify the logic
1 parent 499d40c commit 75e37bd

File tree

5 files changed

+43
-205
lines changed

5 files changed

+43
-205
lines changed

.github/BACKPORT_BRANCH

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11.8.x

.github/ISSUE_TEMPLATE/release_checklist.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ body:
1212
label: Tasks for cuda-bindings / cuda-python release
1313
options:
1414
- label: "Push any internal updates for accommodating a new CTK release to the public (**IMPORTANT**: Need to wait for CTK posting!)"
15+
- label: "If it is a major release, create a new branch to backport to and update the branch name [here](../BACKPORT_BRANCH)"
1516
- label: Follow the check list for `cuda-core` below for the remaining steps
1617

1718
- type: checkboxes

.github/workflows/backport.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- uses: actions/checkout@v4
22+
23+
- name: Load branch name
24+
id: get-branch
25+
run: |
26+
OLD_BRANCH=$(cat .github/BACKPORT_BRANCH)
27+
echo "OLD_BRANCH=${OLD_BRANCH}" >> $GITHUB_ENV
28+
2229
- name: Create backport pull requests
2330
uses: korthout/backport-action@v3
2431
with:
2532
copy_assignees: true
2633
copy_labels_pattern: true
2734
copy_requested_reviewers: true
2835
label_pattern: to-be-backported
29-
target_branches: 11.8.x
36+
target_branches: ${{ fromJSON(env.OLD_BRANCH) }}
3037
conflict_resolution: draft_commit_conflicts

.github/workflows/build-and-test.yml

+33-137
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Note: This name is referred to in the test job, so make sure any changes are sync'd up!
12
name: "CI: Build and test"
23

34
concurrency:
@@ -87,26 +88,6 @@ jobs:
8788
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
8889
echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV
8990

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-
11091
- name: Dump environment
11192
run: |
11293
env
@@ -137,37 +118,13 @@ jobs:
137118
twine check ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
138119
139120
- name: Upload cuda.core build artifacts
140-
if: ${{ env.USE_CACHE == '0' }}
141121
uses: actions/upload-artifact@v4
142122
with:
143123
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
144124
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
145125
if-no-files-found: error
146126
overwrite: 'true'
147127

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-
171128
- name: Set up mini CTK
172129
uses: ./.github/actions/fetch_ctk
173130
continue-on-error: false
@@ -207,38 +164,14 @@ jobs:
207164
# run: |
208165
# twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
209166

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-
226167
- name: Upload cuda.bindings build artifacts
227-
if: ${{ env.USE_CACHE == '0' }}
228168
uses: actions/upload-artifact@v4
229169
with:
230170
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
231171
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
232172
if-no-files-found: error
233173
overwrite: 'true'
234174

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-
242175
- name: Pass environment variables to the next runner
243176
id: pass_env
244177
run: |
@@ -322,6 +255,7 @@ jobs:
322255
323256
# make outputs from the previous job as env vars
324257
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}"
258+
echo "PYTHON_VERSION_FORMATTED=${PYTHON_VERSION_FORMATTED}" >> $GITHUB_ENV
325259
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
326260
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
327261
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
@@ -335,86 +269,51 @@ jobs:
335269
uses: ./.github/actions/install_unix_deps
336270
continue-on-error: false
337271
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"
341275

342-
# We'll try GHA Artifacts first, and then fall back to GHA Cache
343276
- name: Download cuda.bindings build artifacts
344-
id: cuda-bindings-download
277+
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}}
345278
uses: actions/download-artifact@v4
346-
continue-on-error: true
347279
with:
348280
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
349281
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
350282

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 }}
363287
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 }}"/
377305
378306
- name: Display structure of downloaded cuda.bindings artifacts
379307
run: |
380308
pwd
381309
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
382310
383311
- name: Download cuda.core build artifacts
384-
id: cuda-core-download
385312
uses: actions/download-artifact@v4
386-
continue-on-error: true
387313
with:
388314
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
389315
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
390316

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-
418317
- name: Display structure of downloaded cuda.core build artifacts
419318
run: |
420319
pwd
@@ -458,16 +357,13 @@ jobs:
458357
459358
- name: Run cuda.core tests
460359
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-
469360
# 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
471367
TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ matrix.cuda-version }})"
472368
pushd "${CUDA_CORE_ARTIFACTS_DIR}"
473369
pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}"]

.github/workflows/build-docs.yml

-67
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ jobs:
3131
# TODO: cache conda env to speed up the workflow once conda-incubator/setup-miniconda#267
3232
# is resolved
3333

34-
- name: Install dependencies
35-
uses: ./.github/actions/install_unix_deps
36-
continue-on-error: false
37-
with:
38-
# zstd for GHA Cache
39-
dependencies: "zstd"
40-
dependent_exes: "zstd"
41-
4234
- name: Set up miniforge
4335
uses: conda-incubator/setup-miniconda@v3
4436
with:
@@ -78,82 +70,23 @@ jobs:
7870
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
7971
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
8072
81-
# We'll try GHA Artifacts first, and then fall back to GHA Cache
8273
- name: Download cuda.bindings build artifacts
83-
id: cuda-bindings-download
8474
uses: actions/download-artifact@v4
85-
continue-on-error: true
8675
with:
8776
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
8877
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
8978

90-
- name: Restore cuda.bindings cache
91-
if: ${{ steps.cuda-bindings-download.outcome == 'failure' }}
92-
id: cuda-bindings-cache
93-
uses: actions/cache/restore@v4
94-
with:
95-
key: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
96-
path: ${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}.tar.gz
97-
restore-keys: ${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}
98-
fail-on-cache-miss: true
99-
100-
- name: Report cache restore status
101-
if: ${{ steps.cuda-bindings-cache.outcome != 'skipped' }}
102-
run: |
103-
if [[ "${{ steps.cuda-bindings-cache.outputs.cache-hit }}" == true ]]; then
104-
echo "cache is found"
105-
else
106-
echo "cache is not found"
107-
exit 1
108-
fi
109-
CACHE_DIR="${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
110-
CACHE_ARCHIVE="${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}.tar.gz"
111-
ls -l $CACHE_ARCHIVE
112-
mkdir -p $CACHE_DIR
113-
du -h $CACHE_ARCHIVE &&
114-
tar -x -f $CACHE_ARCHIVE -C $CACHE_DIR &&
115-
rm -f $CACHE_ARCHIVE || exit 1
116-
11779
- name: Display structure of downloaded cuda.bindings artifacts
11880
run: |
11981
pwd
12082
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
12183
12284
- name: Download cuda.core build artifacts
123-
id: cuda-core-download
12485
uses: actions/download-artifact@v4
125-
continue-on-error: true
12686
with:
12787
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
12888
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
12989

130-
- name: Restore cuda.core cache
131-
if: ${{ steps.cuda-core-download.outcome == 'failure' }}
132-
id: cuda-core-cache
133-
uses: actions/cache/restore@v4
134-
with:
135-
key: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
136-
path: ${{ env.CUDA_CORE_ARTIFACT_BASENAME }}.tar.gz
137-
restore-keys: ${{ env.CUDA_CORE_ARTIFACT_BASENAME }}
138-
fail-on-cache-miss: true
139-
140-
- name: Report cache restore status
141-
if: ${{ steps.cuda-core-cache.outcome != 'skipped' }}
142-
run: |
143-
if [[ "${{ steps.cuda-core-cache.outputs.cache-hit }}" == true ]]; then
144-
echo "cache is found"
145-
else
146-
echo "cache is not found"
147-
exit 1
148-
fi
149-
CACHE_DIR="${{ env.CUDA_CORE_ARTIFACTS_DIR }}"
150-
CACHE_ARCHIVE="${{ env.CUDA_CORE_ARTIFACT_BASENAME }}.tar.gz"
151-
ls -l $CACHE_ARCHIVE
152-
mkdir -p $CACHE_DIR
153-
du -h $CACHE_ARCHIVE &&
154-
tar -x -f $CACHE_ARCHIVE -C $CACHE_DIR &&
155-
rm -f $CACHE_ARCHIVE || exit 1
156-
15790
- name: Display structure of downloaded cuda.core build artifacts
15891
run: |
15992
pwd

0 commit comments

Comments
 (0)