Skip to content

Commit 0723d62

Browse files
authored
Merge pull request #124 from sandeepd-nv/add_ci_test
Add support for CI testing
2 parents 0ca509e + 7b074f0 commit 0723d62

File tree

15 files changed

+261
-408
lines changed

15 files changed

+261
-408
lines changed

.github/actions/setup/action.yml

+43
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,22 @@ runs:
4747
run: |
4848
env
4949
50+
- name: Set up CTK cache variable
51+
shell: bash --noprofile --norc -xeuo pipefail {0}
52+
run: |
53+
echo "CTK_CACHE_KEY=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}" >> $GITHUB_ENV
54+
echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}.tar.gz" >> $GITHUB_ENV
55+
56+
- name: Download CTK cache
57+
id: ctk-get-cache
58+
uses: actions/cache/restore@v4
59+
continue-on-error: true
60+
with:
61+
key: ${{ env.CTK_CACHE_KEY }}
62+
path: ./${{ env.CTK_CACHE_FILENAME }}
63+
5064
- name: Get CUDA components
65+
if: ${{ steps.ctk-get-cache.outputs.cache-hit != 'true' }}
5166
shell: bash --noprofile --norc -xeuo pipefail {0}
5267
run: |
5368
CUDA_PATH="./cuda_toolkit"
@@ -90,15 +105,43 @@ runs:
90105
}
91106
92107
# Get headers and shared libraries in place
108+
# Note: the existing artifact would need to be manually deleted (ex: through web UI)
109+
# if this list is changed, as the artifact actions do not offer any option for us to
110+
# invalidate the artifact.
93111
populate_cuda_path cuda_nvcc
94112
populate_cuda_path cuda_cudart
95113
populate_cuda_path cuda_nvrtc
96114
populate_cuda_path cuda_profiler_api
115+
populate_cuda_path libnvjitlink
97116
ls -l $CUDA_PATH
98117
118+
# Prepare the cache
119+
# Note: try to escape | and > ...
120+
tar -czvf ${CTK_CACHE_FILENAME} ${CUDA_PATH}
121+
99122
# Note: the headers will be copied into the cibuildwheel manylinux container,
100123
# so setting the CUDA_PATH env var here is meaningless.
101124
125+
- name: Upload CTK cache
126+
if: ${{ always() &&
127+
steps.ctk-get-cache.outputs.cache-hit != 'true' }}
128+
uses: actions/cache/save@v4
129+
with:
130+
key: ${{ env.CTK_CACHE_KEY }}
131+
path: ./${{ env.CTK_CACHE_FILENAME }}
132+
133+
- name: Restore CTK cache
134+
if: ${{ steps.ctk-get-cache.outputs.cache-hit == 'true' }}
135+
shell: bash --noprofile --norc -xeuo pipefail {0}
136+
run: |
137+
ls -l
138+
CUDA_PATH="./cuda_toolkit"
139+
tar -xzvf $CTK_CACHE_FILENAME
140+
ls -l $CUDA_PATH
141+
if [ ! -d "$CUDA_PATH/include" ]; then
142+
exit 1
143+
fi
144+
102145
- name: Set environment variables
103146
shell: bash --noprofile --norc -xeuo pipefail {0}
104147
run: |

.github/actions/test/action.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: test
2+
3+
description: Run tests in specified project
4+
5+
inputs:
6+
test-options:
7+
required: true
8+
type: string
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Run nvidia-smi to make sure GPU is working
14+
shell: bash --noprofile --norc -xeuo pipefail {0}
15+
run: nvidia-smi
16+
17+
- name: Download bindings build artifacts
18+
uses: actions/download-artifact@v4
19+
with:
20+
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
21+
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
22+
23+
- name: Display structure of downloaded bindings artifacts
24+
shell: bash --noprofile --norc -xeuo pipefail {0}
25+
run: |
26+
pwd
27+
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
28+
29+
- name: Download core build artifacts
30+
uses: actions/download-artifact@v4
31+
with:
32+
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
33+
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
34+
35+
- name: Display structure of downloaded core build artifacts
36+
shell: bash --noprofile --norc -xeuo pipefail {0}
37+
run: |
38+
pwd
39+
ls -lahR $CUDA_CORE_ARTIFACTS_DIR
40+
41+
- name: Set up Python ${{ env.PYTHON_VERSION }}
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: ${{ env.PYTHON_VERSION }}
45+
46+
- name: Set up CTK cache variable
47+
shell: bash --noprofile --norc -xeuo pipefail {0}
48+
run: |
49+
echo "CTK_CACHE_KEY=mini-ctk-${CTK_BUILD_VER}-${HOST_PLATFORM}" >> $GITHUB_ENV
50+
echo "CTK_CACHE_FILENAME=mini-ctk-${CTK_BUILD_VER}-${HOST_PLATFORM}.tar.gz" >> $GITHUB_ENV
51+
52+
- name: Download CTK cache
53+
id: ctk-get-cache
54+
uses: actions/cache/restore@v4
55+
continue-on-error: true
56+
with:
57+
key: ${{ env.CTK_CACHE_KEY }}
58+
path: ./${{ env.CTK_CACHE_FILENAME }}
59+
fail-on-cache-miss: true
60+
61+
- name: Restore CTK cache
62+
shell: bash --noprofile --norc -xeuo pipefail {0}
63+
run: |
64+
ls -l
65+
CUDA_PATH="$(pwd)/cuda_toolkit"
66+
tar -xzvf $CTK_CACHE_FILENAME
67+
ls -l $CUDA_PATH
68+
if [ ! -d "$CUDA_PATH/include" ]; then
69+
exit 1
70+
fi
71+
72+
echo "CUDA_PATH=$CUDA_PATH" >> $GITHUB_ENV
73+
echo "PATH=$PATH:$CUDA_PATH/bin" >> $GITHUB_ENV
74+
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_PATH/lib" >> $GITHUB_ENV
75+
76+
- name: Run test / analysis
77+
shell: bash --noprofile --norc -xeuo pipefail {0}
78+
run: |
79+
REPO_DIR=$(pwd)
80+
81+
cd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
82+
pip install *.whl
83+
84+
cd "${CUDA_CORE_ARTIFACTS_DIR}"
85+
pip install *.whl
86+
87+
cd "${REPO_DIR}/cuda_bindings"
88+
pip install -r requirements.txt
89+
pytest tests/
90+
#pytest tests/cython
91+
92+
cd "${REPO_DIR}/cuda_core"
93+
pytest -rxXs tests/

.github/workflows/ci-gh.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and test
1+
name: "CI"
22

33
concurrency:
44
group: ${{ startsWith(github.ref_name, 'main') && format('unique-{0}', github.run_id) || format('ci-build-and-test-on-{0}-from-{1}', github.event_name, github.ref_name) }}
@@ -11,8 +11,7 @@ on:
1111
- "main"
1212

1313
jobs:
14-
build-and-test:
15-
name: Build and test (${{ matrix.host-platform }}, ${{ matrix.target-device }}, ${{ matrix.build-mode }})
14+
ci:
1615
strategy:
1716
fail-fast: false
1817
matrix:
@@ -35,6 +34,7 @@ jobs:
3534
# Note: this is for build-time only; the test-time matrix needs to be
3635
# defined separately.
3736
- "12.6.2"
37+
name: "CI"
3838
uses:
3939
./.github/workflows/gh-build-and-test.yml
4040
with:

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

+96-17
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,100 @@ on:
2525

2626
jobs:
2727
build:
28+
name: Build (${{ inputs.host-platform }}, Python "${{ inputs.python-version }}")
2829
if: ${{ github.repository_owner == 'nvidia' }}
29-
uses:
30-
./.github/workflows/gh-build.yml
31-
with:
32-
client-repo: ${{ github.event.repository.name }}
33-
target-device: ${{ inputs.target-device }}
34-
runs-on: ${{ (inputs.host-platform == 'linux-x64' && 'linux-amd64-cpu8') ||
35-
(inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu8') ||
36-
(inputs.host-platform == 'win-x64' && 'windows-2019') }}
37-
# (inputs.host-platform == 'win-x64' && 'windows-amd64-cpu8') }}
38-
build-type: ${{ inputs.build-type }}
39-
host-platform: ${{ inputs.host-platform }}
40-
build-mode: ${{ inputs.build-mode }}
41-
upload-enabled: ${{ inputs.upload-enabled }}
42-
python-version: ${{ inputs.python-version }}
43-
cuda-version: ${{ inputs.cuda-version }}
44-
dependencies-file: ""
45-
secrets: inherit
30+
permissions:
31+
id-token: write # This is required for configure-aws-credentials
32+
contents: read # This is required for actions/checkout
33+
runs-on: ${{ (inputs.host-platform == 'linux-x64' && 'linux-amd64-cpu8') ||
34+
(inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu8') ||
35+
(inputs.host-platform == 'win-x64' && 'windows-2019') }}
36+
# (inputs.host-platform == 'win-x64' && 'windows-amd64-cpu8') }}
37+
outputs:
38+
CUDA_CORE_ARTIFACT_NAME: ${{ steps.pass_env.outputs.CUDA_CORE_ARTIFACT_NAME }}
39+
CUDA_CORE_ARTIFACTS_DIR: ${{ steps.pass_env.outputs.CUDA_CORE_ARTIFACTS_DIR }}
40+
CUDA_BINDINGS_ARTIFACT_NAME: ${{ steps.pass_env.outputs.CUDA_BINDINGS_ARTIFACT_NAME }}
41+
CUDA_BINDINGS_ARTIFACTS_DIR: ${{ steps.pass_env.outputs.CUDA_BINDINGS_ARTIFACTS_DIR }}
42+
steps:
43+
- name: Checkout ${{ github.event.repository.name }}
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Set up build environment
49+
uses: ./.github/actions/setup
50+
with:
51+
client-repo: ${{ github.event.repository.name }}
52+
build-type: ${{ inputs.build-type }}
53+
target-device: "${{ inputs.target-device }}"
54+
host-platform: ${{ inputs.host-platform }}
55+
build-mode: ${{ inputs.build-mode }}
56+
upload-enabled: ${{ inputs.upload-enabled }}
57+
python-version: ${{ inputs.python-version }}
58+
cuda-version: ${{ inputs.cuda-version }}
59+
60+
- name: Call build action
61+
uses: ./.github/actions/build
62+
with:
63+
build-type: ${{ inputs.build-type }}
64+
target-device: "${{ inputs.target-device }}"
65+
host-platform: ${{ inputs.host-platform }}
66+
upload-enabled: ${{ inputs.upload-enabled }}
67+
68+
- name: Pass environment variables
69+
id: pass_env
70+
run: |
71+
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_NAME}" >> $GITHUB_OUTPUT
72+
echo "CUDA_CORE_ARTIFACTS_DIR=${CUDA_CORE_ARTIFACTS_DIR}" >> $GITHUB_OUTPUT
73+
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_NAME}" >> $GITHUB_OUTPUT
74+
echo "CUDA_BINDINGS_ARTIFACTS_DIR=${CUDA_BINDINGS_ARTIFACTS_DIR}" >> $GITHUB_OUTPUT
75+
76+
test:
77+
# TODO: improve the name once a separate test matrix is defined
78+
name: Test (CUDA ${{ inputs.cuda-version }})
79+
# TODO: enable testing once linux-aarch64 & win-64 GPU runners are up
80+
if: ${{ (github.repository_owner == 'nvidia') &&
81+
startsWith(inputs.host-platform, 'linux-x64') }}
82+
permissions:
83+
id-token: write # This is required for configure-aws-credentials
84+
contents: read # This is required for actions/checkout
85+
runs-on: ${{ (inputs.host-platform == 'linux-x64' && 'linux-amd64-gpu-v100-latest-1') }}
86+
# TODO: use a different (nvidia?) container, or just run on bare image
87+
container:
88+
options: -u root --security-opt seccomp=unconfined --privileged --shm-size 16g
89+
image: condaforge/miniforge3:latest
90+
env:
91+
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
92+
needs:
93+
- build
94+
steps:
95+
- name: Checkout ${{ github.event.repository.name }}
96+
uses: actions/checkout@v4
97+
with:
98+
fetch-depth: 0
99+
100+
# TODO: we probably don't need this?
101+
# - name: Setup
102+
# if: ${{ inputs.has-built != 'true' }}
103+
# uses: ./.github/actions/setup
104+
# with:
105+
# client-repo: ${{ github.event.repository.name }}
106+
# build-type: ${{ inputs.build-type }}
107+
# target-device: "${{ inputs.target-device }}"
108+
# host-platform: ${{ inputs.host-platform }}
109+
# build-mode: ${{ inputs.build-mode }}
110+
# upload-enabled: ${{ inputs.upload-enabled }}
111+
# python-version: ${{ inputs.python-version }}
112+
113+
- name: Call test action
114+
uses: ./.github/actions/test
115+
with:
116+
test-options: ${{ inputs.build-type }}
117+
env:
118+
CUDA_CORE_ARTIFACT_NAME: ${{ needs.build.outputs.CUDA_CORE_ARTIFACT_NAME }}
119+
CUDA_CORE_ARTIFACTS_DIR: ${{ needs.build.outputs.CUDA_CORE_ARTIFACTS_DIR }}
120+
CUDA_BINDINGS_ARTIFACT_NAME: ${{ needs.build.outputs.CUDA_BINDINGS_ARTIFACT_NAME }}
121+
CUDA_BINDINGS_ARTIFACTS_DIR: ${{ needs.build.outputs.CUDA_BINDINGS_ARTIFACTS_DIR }}
122+
PYTHON_VERSION: ${{ inputs.python-version }}
123+
CTK_BUILD_VER: ${{ inputs.cuda-version }}
124+
HOST_PLATFORM: ${{ inputs.host-platform }}

.github/workflows/gh-build.yml

-73
This file was deleted.

0 commit comments

Comments
 (0)