|
| 1 | +name: "CI: Test wheels" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + host-platform: |
| 7 | + type: string |
| 8 | + required: true |
| 9 | + python-version: |
| 10 | + type: string |
| 11 | + required: true |
| 12 | + build-ctk-ver: |
| 13 | + type: string |
| 14 | + required: true |
| 15 | + cuda-version: |
| 16 | + type: string |
| 17 | + required: true |
| 18 | + local-ctk: |
| 19 | + type: string |
| 20 | + required: true |
| 21 | + runner: |
| 22 | + type: string |
| 23 | + required: true |
| 24 | + |
| 25 | +jobs: |
| 26 | + test: |
| 27 | + # The build stage could fail but we want the CI to keep moving. |
| 28 | + if: ${{ github.repository_owner == 'nvidia' && !cancelled() }} |
| 29 | + runs-on: ${{ (inputs.runner == 'default' && inputs.host-platform == 'linux-64' && 'linux-amd64-gpu-v100-latest-1') || |
| 30 | + (inputs.runner == 'default' && inputs.host-platform == 'linux-aarch64' && 'linux-arm64-gpu-a100-latest-1') || |
| 31 | + (inputs.runner == 'default' && inputs.host-platform == 'win-64' && 'cuda-python-windows-gpu-github') || |
| 32 | + (inputs.runner == 'H100' && 'linux-amd64-gpu-h100-latest-1') }} |
| 33 | + defaults: |
| 34 | + run: |
| 35 | + shell: bash --noprofile --norc -xeuo pipefail {0} |
| 36 | + steps: |
| 37 | + - name: Ensure GPU is working |
| 38 | + run: nvidia-smi |
| 39 | + |
| 40 | + - name: Checkout ${{ github.event.repository.name }} |
| 41 | + uses: actions/checkout@v4 |
| 42 | + with: |
| 43 | + fetch-depth: 0 |
| 44 | + |
| 45 | + - name: Set environment variables |
| 46 | + run: | |
| 47 | + PYTHON_VERSION_FORMATTED=$(echo '${{ inputs.python-version }}' | tr -d '.') |
| 48 | + if [[ "${{ inputs.host-platform }}" == linux* ]]; then |
| 49 | + REPO_DIR=$(pwd) |
| 50 | + elif [[ "${{ inputs.host-platform }}" == win* ]]; then |
| 51 | + PWD=$(pwd) |
| 52 | + REPO_DIR=$(cygpath -w $PWD) |
| 53 | + fi |
| 54 | +
|
| 55 | + BUILD_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ inputs.build-ctk-ver }})" |
| 56 | + TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ inputs.cuda-version }})" |
| 57 | + if [[ $BUILD_CUDA_MAJOR != $TEST_CUDA_MAJOR ]]; then |
| 58 | + SKIP_CUDA_BINDINGS_TEST=1 |
| 59 | + else |
| 60 | + SKIP_CUDA_BINDINGS_TEST=0 |
| 61 | + fi |
| 62 | +
|
| 63 | + # make outputs from the previous job as env vars |
| 64 | + CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ inputs.host-platform }}" |
| 65 | + echo "PYTHON_VERSION_FORMATTED=${PYTHON_VERSION_FORMATTED}" >> $GITHUB_ENV |
| 66 | + echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV |
| 67 | + echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV |
| 68 | + echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV |
| 69 | + CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.build-ctk-ver }}-${{ inputs.host-platform }}" |
| 70 | + echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV |
| 71 | + echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV |
| 72 | + echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV |
| 73 | + echo "SKIP_CUDA_BINDINGS_TEST=${SKIP_CUDA_BINDINGS_TEST}" >> $GITHUB_ENV |
| 74 | +
|
| 75 | + - name: Install dependencies |
| 76 | + uses: ./.github/actions/install_unix_deps |
| 77 | + continue-on-error: false |
| 78 | + with: |
| 79 | + # gcc for Cython tests, jq/wget for artifact fetching |
| 80 | + dependencies: "build-essential jq wget" |
| 81 | + dependent_exes: "gcc jq wget" |
| 82 | + |
| 83 | + - name: Download cuda-python build artifacts |
| 84 | + if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}} |
| 85 | + uses: actions/download-artifact@v4 |
| 86 | + with: |
| 87 | + name: cuda-python-wheel |
| 88 | + path: . |
| 89 | + |
| 90 | + - name: Download cuda.bindings build artifacts |
| 91 | + if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}} |
| 92 | + uses: actions/download-artifact@v4 |
| 93 | + with: |
| 94 | + name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }} |
| 95 | + path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }} |
| 96 | + |
| 97 | + - name: Download cuda-python & cuda.bindings build artifacts from the prior branch |
| 98 | + if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '1'}} |
| 99 | + env: |
| 100 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 101 | + run: | |
| 102 | + # See https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt. |
| 103 | + # gh is needed for artifact fetching. |
| 104 | + mkdir -p -m 755 /etc/apt/keyrings \ |
| 105 | + && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \ |
| 106 | + && cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \ |
| 107 | + && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ |
| 108 | + && 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 \ |
| 109 | + && apt update \ |
| 110 | + && apt install gh -y |
| 111 | +
|
| 112 | + OLD_BRANCH=$(cat .github/BACKPORT_BRANCH) |
| 113 | + OLD_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda*-${{ inputs.host-platform }}*" |
| 114 | + 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') |
| 115 | + if [[ "$LATEST_PRIOR_RUN_ID" == "" ]]; then |
| 116 | + echo "LATEST_PRIOR_RUN_ID not found!" |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | +
|
| 120 | + gh run download $LATEST_PRIOR_RUN_ID -p ${OLD_BASENAME} -R NVIDIA/cuda-python |
| 121 | + ls -al $OLD_BASENAME |
| 122 | + mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}" |
| 123 | + mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"/ |
| 124 | + rmdir $OLD_BASENAME |
| 125 | +
|
| 126 | + gh run download $LATEST_PRIOR_RUN_ID -p cuda-python-wheel -R NVIDIA/cuda-python |
| 127 | + ls -al cuda-python-wheel |
| 128 | + mv cuda-python-wheel/*.whl . |
| 129 | + rmdir cuda-python-wheel |
| 130 | +
|
| 131 | + - name: Display structure of downloaded cuda-python artifacts |
| 132 | + run: | |
| 133 | + pwd |
| 134 | + ls -lahR . |
| 135 | +
|
| 136 | + - name: Display structure of downloaded cuda.bindings artifacts |
| 137 | + run: | |
| 138 | + pwd |
| 139 | + ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR |
| 140 | +
|
| 141 | + - name: Download cuda.core build artifacts |
| 142 | + uses: actions/download-artifact@v4 |
| 143 | + with: |
| 144 | + name: ${{ env.CUDA_CORE_ARTIFACT_NAME }} |
| 145 | + path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }} |
| 146 | + |
| 147 | + - name: Display structure of downloaded cuda.core build artifacts |
| 148 | + run: | |
| 149 | + pwd |
| 150 | + ls -lahR $CUDA_CORE_ARTIFACTS_DIR |
| 151 | +
|
| 152 | + - name: Set up Python ${{ inputs.python-version }} |
| 153 | + uses: actions/setup-python@v5 |
| 154 | + with: |
| 155 | + python-version: ${{ inputs.python-version }} |
| 156 | + env: |
| 157 | + # we use self-hosted runners on which setup-python behaves weirdly... |
| 158 | + AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache" |
| 159 | + |
| 160 | + - name: Set up mini CTK |
| 161 | + if: ${{ inputs.local-ctk == '1' }} |
| 162 | + uses: ./.github/actions/fetch_ctk |
| 163 | + continue-on-error: false |
| 164 | + with: |
| 165 | + host-platform: ${{ inputs.host-platform }} |
| 166 | + cuda-version: ${{ inputs.cuda-version }} |
| 167 | + |
| 168 | + - name: Run cuda.bindings tests |
| 169 | + if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0' }} |
| 170 | + run: | |
| 171 | + pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}" |
| 172 | + if [[ "${{ inputs.local-ctk }}" == 1 ]]; then |
| 173 | + ls $CUDA_PATH |
| 174 | + pip install *.whl |
| 175 | + else |
| 176 | + pip install $(ls *.whl)[all] |
| 177 | + fi |
| 178 | + popd |
| 179 | +
|
| 180 | + pushd ./cuda_bindings |
| 181 | + pip install -r requirements.txt |
| 182 | + pytest -rxXs tests/ |
| 183 | +
|
| 184 | + # It is a bit convoluted to run the Cython tests against CTK wheels, |
| 185 | + # so let's just skip them. |
| 186 | + if [[ "${{ inputs.local-ctk }}" == 1 ]]; then |
| 187 | + if [[ "${{ inputs.host-platform }}" == linux* ]]; then |
| 188 | + bash tests/cython/build_tests.sh |
| 189 | + elif [[ "${{ inputs.host-platform }}" == win* ]]; then |
| 190 | + # TODO: enable this once win-64 runners are up |
| 191 | + exit 1 |
| 192 | + fi |
| 193 | + pytest -rxXs tests/cython |
| 194 | + popd |
| 195 | + fi |
| 196 | +
|
| 197 | + - name: Run cuda.core tests |
| 198 | + run: | |
| 199 | + # If build/test majors match: cuda.bindings is installed in the previous step. |
| 200 | + # If mismatch: cuda.bindings is installed from the backport branch. |
| 201 | + if [[ "${SKIP_CUDA_BINDINGS_TEST}" == 1 ]]; then |
| 202 | + pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}" |
| 203 | + if [[ "${{ inputs.local-ctk }}" == 1 ]]; then |
| 204 | + pip install *.whl |
| 205 | + else |
| 206 | + pip install $(ls *.whl)[all] |
| 207 | + fi |
| 208 | + popd |
| 209 | + fi |
| 210 | + TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ inputs.cuda-version }})" |
| 211 | + pushd "${CUDA_CORE_ARTIFACTS_DIR}" |
| 212 | + pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}"] |
| 213 | + popd |
| 214 | +
|
| 215 | + pushd ./cuda_core |
| 216 | + pip install -r "tests/requirements-cu${TEST_CUDA_MAJOR}.txt" |
| 217 | + pytest -rxXs tests/ |
| 218 | + popd |
| 219 | +
|
| 220 | + - name: Ensure cuda-python installable |
| 221 | + run: | |
| 222 | + if [[ "${{ inputs.local-ctk }}" == 1 ]]; then |
| 223 | + pip install cuda_python*.whl |
| 224 | + else |
| 225 | + pip install $(ls cuda_python*.whl)[all] |
| 226 | + fi |
0 commit comments