Skip to content

Commit 4cbab16

Browse files
authored
Merge pull request #357 from leofang/cache_artifacts
Download build artifacts from the backport branch for testing in the `main` branch
2 parents 61ef224 + 75e37bd commit 4cbab16

File tree

7 files changed

+129
-63
lines changed

7 files changed

+129
-63
lines changed

.github/BACKPORT_BRANCH

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11.8.x

.github/ISSUE_TEMPLATE/release_checklist.yml

Lines changed: 1 addition & 0 deletions
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/actions/fetch_ctk/action.yml

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,11 @@ runs:
2020
echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}.tar.gz" >> $GITHUB_ENV
2121
2222
- name: Install dependencies
23-
shell: bash --noprofile --norc -xeuo pipefail {0}
24-
run: |
25-
dependencies=(zstd curl xz-utils)
26-
dependent_exes=(zstd curl xz)
27-
28-
not_found=0
29-
for dep in ${dependent_exes[@]}; do
30-
if ! (command -v curl 2>&1 >/dev/null); then
31-
not_found=1
32-
break
33-
fi
34-
done
35-
if [[ $not_found == 0 ]]; then
36-
echo "All dependencies are found. Do nothing."
37-
exit 0
38-
fi
39-
if ! (command -v sudo 2>&1 >/dev/null); then
40-
if [[ $EUID == 0 ]]; then
41-
alias SUDO=""
42-
else
43-
echo "The following oprations require root access."
44-
exit 1
45-
fi
46-
else
47-
alias SUDO="sudo"
48-
fi
49-
shopt -s expand_aliases
50-
SUDO apt update
51-
SUDO apt install -y ${dependencies[@]}
23+
uses: ./.github/actions/install_unix_deps
24+
continue-on-error: false
25+
with:
26+
dependencies: "zstd curl xz-utils"
27+
dependent_exes: "zstd curl xz"
5228

5329
- name: Download CTK cache
5430
id: ctk-get-cache
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Install dependencies on Ubuntu
2+
3+
description: Install needed dependencies, regardless if using GitHub- or self- hosted runners, container, sudo or not.
4+
5+
inputs:
6+
dependencies:
7+
required: true
8+
type: string
9+
dependent_exes:
10+
required: true
11+
type: string
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Install dependencies
17+
shell: bash --noprofile --norc -xeuo pipefail {0}
18+
run: |
19+
dependencies=(${{ inputs.dependencies }})
20+
dependent_exes=(${{ inputs.dependent_exes }})
21+
22+
not_found=0
23+
for dep in ${dependent_exes[@]}; do
24+
if ! (command -v $dep 2>&1 >/dev/null); then
25+
not_found=1
26+
break
27+
fi
28+
done
29+
if [[ $not_found == 0 ]]; then
30+
echo "All dependencies are found. Do nothing."
31+
exit 0
32+
fi
33+
if ! (command -v sudo 2>&1 >/dev/null); then
34+
if [[ $EUID == 0 ]]; then
35+
alias SUDO=""
36+
else
37+
echo "The following oprations require root access."
38+
exit 1
39+
fi
40+
else
41+
alias SUDO="sudo"
42+
fi
43+
shopt -s expand_aliases
44+
SUDO apt update
45+
SUDO apt install -y ${dependencies[@]}

.github/workflows/backport.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +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) }}
37+
conflict_resolution: draft_commit_conflicts

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

Lines changed: 61 additions & 30 deletions
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:
@@ -42,6 +43,9 @@ jobs:
4243
# (matrix.host-platform == 'win-64' && 'windows-amd64-cpu8') }}
4344
outputs:
4445
BUILD_CTK_VER: ${{ steps.pass_env.outputs.CUDA_VERSION }}
46+
defaults:
47+
run:
48+
shell: bash --noprofile --norc -xeuo pipefail {0}
4549
steps:
4650
- name: Checkout ${{ github.event.repository.name }}
4751
uses: actions/checkout@v4
@@ -62,7 +66,6 @@ jobs:
6266
uses: ilammy/msvc-dev-cmd@v1
6367

6468
- name: Set environment variables
65-
shell: bash --noprofile --norc -xeuo pipefail {0}
6669
run: |
6770
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.')
6871
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
@@ -75,14 +78,17 @@ jobs:
7578
fi
7679
7780
echo "PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV
78-
echo "CUDA_CORE_ARTIFACT_NAME=cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}-${{ github.sha }}" >> $GITHUB_ENV
81+
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}"
82+
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
83+
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
7984
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
80-
echo "CUDA_BINDINGS_ARTIFACT_NAME=cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ matrix.cuda-version }}-${{ matrix.host-platform }}-${{ github.sha }}" >> $GITHUB_ENV
85+
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ matrix.cuda-version }}-${{ matrix.host-platform }}"
86+
echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV
87+
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
8188
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
8289
echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV
83-
90+
8491
- name: Dump environment
85-
shell: bash --noprofile --norc -xeuo pipefail {0}
8692
run: |
8793
env
8894
@@ -97,7 +103,6 @@ jobs:
97103
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
98104

99105
- name: List the cuda.core artifacts directory
100-
shell: bash --noprofile --norc -xeuo pipefail {0}
101106
run: |
102107
if [[ "${{ matrix.host-platform }}" == win* ]]; then
103108
export CHOWN=chown
@@ -108,7 +113,6 @@ jobs:
108113
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
109114
110115
- name: Check cuda.core wheel
111-
shell: bash --noprofile --norc -xeuo pipefail {0}
112116
run: |
113117
pip install twine
114118
twine check ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
@@ -146,7 +150,6 @@ jobs:
146150
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
147151

148152
- name: List the cuda.bindings artifacts directory
149-
shell: bash --noprofile --norc -xeuo pipefail {0}
150153
run: |
151154
if [[ "${{ matrix.host-platform }}" == win* ]]; then
152155
export CHOWN=chown
@@ -158,7 +161,6 @@ jobs:
158161
159162
# TODO: enable this after NVIDIA/cuda-python#297 is resolved
160163
# - name: Check cuda.bindings wheel
161-
# shell: bash --noprofile --norc -xeuo pipefail {0}
162164
# run: |
163165
# twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
164166

@@ -205,7 +207,7 @@ jobs:
205207
runner: H100
206208
name: Test (${{ matrix.host-platform }}, Python ${{ matrix.python-version }}, CUDA ${{ matrix.cuda-version }}, Runner ${{ matrix.runner }})
207209
# The build stage could fail but we want the CI to keep moving.
208-
if: ${{ github.repository_owner == 'nvidia' && always() }}
210+
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
209211
permissions:
210212
id-token: write # This is required for configure-aws-credentials
211213
contents: read # This is required for actions/checkout
@@ -221,9 +223,11 @@ jobs:
221223
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
222224
needs:
223225
- build
226+
defaults:
227+
run:
228+
shell: bash --noprofile --norc -xeuo pipefail {0}
224229
steps:
225230
- name: Ensure GPU is working
226-
shell: bash --noprofile --norc -xeuo pipefail {0}
227231
run: nvidia-smi
228232

229233
- name: Checkout ${{ github.event.repository.name }}
@@ -232,7 +236,6 @@ jobs:
232236
fetch-depth: 0
233237

234238
- name: Set environment variables
235-
shell: bash --noprofile --norc -xeuo pipefail {0}
236239
run: |
237240
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.')
238241
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
@@ -251,20 +254,56 @@ jobs:
251254
fi
252255
253256
# make outputs from the previous job as env vars
254-
echo "CUDA_CORE_ARTIFACT_NAME=cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}-${{ github.sha }}" >> $GITHUB_ENV
257+
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}"
258+
echo "PYTHON_VERSION_FORMATTED=${PYTHON_VERSION_FORMATTED}" >> $GITHUB_ENV
259+
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
260+
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
255261
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
256-
echo "CUDA_BINDINGS_ARTIFACT_NAME=cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ needs.build.outputs.BUILD_CTK_VER }}-${{ matrix.host-platform }}-${{ github.sha }}" >> $GITHUB_ENV
262+
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ needs.build.outputs.BUILD_CTK_VER }}-${{ matrix.host-platform }}"
263+
echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV
264+
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
257265
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
258266
echo "SKIP_CUDA_BINDINGS_TEST=${SKIP_CUDA_BINDINGS_TEST}" >> $GITHUB_ENV
259267
268+
- name: Install dependencies
269+
uses: ./.github/actions/install_unix_deps
270+
continue-on-error: false
271+
with:
272+
# gcc for Cython tests, jq/wget for artifact fetching
273+
dependencies: "build-essential jq wget"
274+
dependent_exes: "gcc jq wget"
275+
260276
- name: Download cuda.bindings build artifacts
277+
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}}
261278
uses: actions/download-artifact@v4
262279
with:
263280
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
264281
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
265282

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 }}
287+
run: |
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 }}"/
305+
266306
- name: Display structure of downloaded cuda.bindings artifacts
267-
shell: bash --noprofile --norc -xeuo pipefail {0}
268307
run: |
269308
pwd
270309
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
@@ -276,7 +315,6 @@ jobs:
276315
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
277316

278317
- name: Display structure of downloaded cuda.core build artifacts
279-
shell: bash --noprofile --norc -xeuo pipefail {0}
280318
run: |
281319
pwd
282320
ls -lahR $CUDA_CORE_ARTIFACTS_DIR
@@ -298,7 +336,6 @@ jobs:
298336

299337
- name: Run cuda.bindings tests
300338
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0' }}
301-
shell: bash --noprofile --norc -xeuo pipefail {0}
302339
run: |
303340
ls $CUDA_PATH
304341
@@ -310,8 +347,6 @@ jobs:
310347
pip install -r requirements.txt
311348
pytest -rxXs tests/
312349
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
313-
# cython tests require gcc
314-
apt install -y build-essential
315350
bash tests/cython/build_tests.sh
316351
elif [[ "${{ matrix.host-platform }}" == win* ]]; then
317352
# TODO: enable this once win-64 runners are up
@@ -321,18 +356,14 @@ jobs:
321356
popd
322357
323358
- name: Run cuda.core tests
324-
shell: bash --noprofile --norc -xeuo pipefail {0}
325359
run: |
326-
if [[ ${{ matrix.python-version }} == "3.13" ]]; then
327-
# TODO: remove this hack once cuda-python has a cp313 build
328-
if [[ $SKIP_CUDA_BINDINGS_TEST == 1 ]]; then
329-
echo "Python 3.13 + cuda-python ${{ matrix.cuda-version }} is not supported, skipping the test..."
330-
exit 0
331-
fi
332-
fi
333-
334360
# If build/test majors match: cuda.bindings is installed in the previous step.
335-
# 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
336367
TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ matrix.cuda-version }})"
337368
pushd "${CUDA_CORE_ARTIFACTS_DIR}"
338369
pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}"]
@@ -346,7 +377,7 @@ jobs:
346377
doc:
347378
name: Docs
348379
# The build stage could fail but we want the CI to keep moving.
349-
if: ${{ github.repository_owner == 'nvidia' && always() }}
380+
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
350381
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
351382
permissions:
352383
id-token: write

.github/workflows/build-docs.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
build:
1212
name: Build docs
1313
# The build stage could fail but we want the CI to keep moving.
14-
if: ${{ github.repository_owner == 'nvidia' && always() }}
14+
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
1515
# WAR: Building the doc currently requires a GPU (NVIDIA/cuda-python#326,327)
1616
runs-on: linux-amd64-gpu-t4-latest-1-testing
1717
#runs-on: ubuntu-latest
@@ -61,9 +61,13 @@ jobs:
6161
REPO_DIR=$(pwd)
6262
6363
# make outputs from the previous job as env vars
64-
echo "CUDA_CORE_ARTIFACT_NAME=cuda-core-python${PYTHON_VERSION_FORMATTED}-linux-64-${{ github.sha }}" >> $GITHUB_ENV
64+
CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-linux-64"
65+
echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV
66+
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
6567
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
66-
echo "CUDA_BINDINGS_ARTIFACT_NAME=cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.build_ctk_ver }}-linux-64-${{ github.sha }}" >> $GITHUB_ENV
68+
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.build_ctk_ver }}-linux-64"
69+
echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV
70+
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
6771
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
6872
6973
- name: Download cuda.bindings build artifacts

0 commit comments

Comments
 (0)