Skip to content

Commit 5015410

Browse files
committed
make the existing test workflow reusable to set the stage
1 parent 75e37bd commit 5015410

File tree

2 files changed

+194
-161
lines changed

2 files changed

+194
-161
lines changed

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

+9-161
Original file line numberDiff line numberDiff line change
@@ -209,170 +209,18 @@ jobs:
209209
# The build stage could fail but we want the CI to keep moving.
210210
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
211211
permissions:
212-
id-token: write # This is required for configure-aws-credentials
213212
contents: read # This is required for actions/checkout
214-
runs-on: ${{ (matrix.runner == 'default' && matrix.host-platform == 'linux-64' && 'linux-amd64-gpu-v100-latest-1') ||
215-
(matrix.runner == 'default' && matrix.host-platform == 'linux-aarch64' && 'linux-arm64-gpu-a100-latest-1') ||
216-
(matrix.runner == 'H100' && 'linux-amd64-gpu-h100-latest-1-testing') }}
217-
# Our self-hosted runners require a container
218-
# TODO: use a different (nvidia?) container
219-
container:
220-
options: -u root --security-opt seccomp=unconfined --shm-size 16g
221-
image: ubuntu:22.04
222-
env:
223-
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
224213
needs:
225214
- build
226-
defaults:
227-
run:
228-
shell: bash --noprofile --norc -xeuo pipefail {0}
229-
steps:
230-
- name: Ensure GPU is working
231-
run: nvidia-smi
232-
233-
- name: Checkout ${{ github.event.repository.name }}
234-
uses: actions/checkout@v4
235-
with:
236-
fetch-depth: 0
237-
238-
- name: Set environment variables
239-
run: |
240-
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.')
241-
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
242-
REPO_DIR=$(pwd)
243-
elif [[ "${{ matrix.host-platform }}" == win* ]]; then
244-
PWD=$(pwd)
245-
REPO_DIR=$(cygpath -w $PWD)
246-
fi
247-
248-
BUILD_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ needs.build.outputs.BUILD_CTK_VER }})"
249-
TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ matrix.cuda-version }})"
250-
if [[ $BUILD_CUDA_MAJOR != $TEST_CUDA_MAJOR ]]; then
251-
SKIP_CUDA_BINDINGS_TEST=1
252-
else
253-
SKIP_CUDA_BINDINGS_TEST=0
254-
fi
255-
256-
# make outputs from the previous job as env vars
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
261-
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $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
265-
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
266-
echo "SKIP_CUDA_BINDINGS_TEST=${SKIP_CUDA_BINDINGS_TEST}" >> $GITHUB_ENV
267-
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-
276-
- name: Download cuda.bindings build artifacts
277-
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}}
278-
uses: actions/download-artifact@v4
279-
with:
280-
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
281-
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
282-
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-
306-
- name: Display structure of downloaded cuda.bindings artifacts
307-
run: |
308-
pwd
309-
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
310-
311-
- name: Download cuda.core build artifacts
312-
uses: actions/download-artifact@v4
313-
with:
314-
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
315-
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
316-
317-
- name: Display structure of downloaded cuda.core build artifacts
318-
run: |
319-
pwd
320-
ls -lahR $CUDA_CORE_ARTIFACTS_DIR
321-
322-
- name: Set up Python ${{ matrix.python-version }}
323-
uses: actions/setup-python@v5
324-
with:
325-
python-version: ${{ matrix.python-version }}
326-
env:
327-
# we use self-hosted runners on which setup-python behaves weirdly...
328-
AGENT_TOOLSDIRECTORY: "/opt/hostedtoolcache"
329-
330-
- name: Set up mini CTK
331-
uses: ./.github/actions/fetch_ctk
332-
continue-on-error: false
333-
with:
334-
host-platform: ${{ matrix.host-platform }}
335-
cuda-version: ${{ matrix.cuda-version }}
336-
337-
- name: Run cuda.bindings tests
338-
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0' }}
339-
run: |
340-
ls $CUDA_PATH
341-
342-
pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
343-
pip install *.whl
344-
popd
345-
346-
pushd ./cuda_bindings
347-
pip install -r requirements.txt
348-
pytest -rxXs tests/
349-
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
350-
bash tests/cython/build_tests.sh
351-
elif [[ "${{ matrix.host-platform }}" == win* ]]; then
352-
# TODO: enable this once win-64 runners are up
353-
exit 1
354-
fi
355-
pytest -rxXs tests/cython
356-
popd
357-
358-
- name: Run cuda.core tests
359-
run: |
360-
# If build/test majors match: cuda.bindings is installed in the previous step.
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
367-
TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ matrix.cuda-version }})"
368-
pushd "${CUDA_CORE_ARTIFACTS_DIR}"
369-
pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}"]
370-
popd
371-
372-
pushd ./cuda_core
373-
pip install -r "tests/requirements-cu${TEST_CUDA_MAJOR}.txt"
374-
pytest -rxXs tests/
375-
popd
215+
secrets: inherit
216+
uses:
217+
./.github/workflows/test_local_ctk.yml
218+
with:
219+
host-platform: ${{ matrix.host-platform }}
220+
python-version: ${{ matrix.python-version }}
221+
build_ctk_ver: ${{ needs.build.outputs.BUILD_CTK_VER }}
222+
cuda-version: ${{ matrix.cuda-version }}
223+
runner: ${{ matrix.runner }}
376224

377225
doc:
378226
name: Docs

.github/workflows/test_local_ctk.yml

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

0 commit comments

Comments
 (0)