1+ # Note: This name is referred to in the test job, so make sure any changes are sync'd up!
12name : " CI: Build and test"
23
34concurrency :
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
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
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
0 commit comments