Skip to content

Commit 3ac17fe

Browse files
authored
Merge pull request #302 from leofang/ci_refactor
CI refactoring to cover more test support
2 parents 72f8dac + d9c5bb6 commit 3ac17fe

File tree

8 files changed

+350
-412
lines changed

8 files changed

+350
-412
lines changed

.github/actions/build/action.yml

Lines changed: 0 additions & 103 deletions
This file was deleted.
Lines changed: 46 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,63 @@
1-
name: Common setup
1+
name: Fetch mini CTK
2+
3+
description: Fetch (or create) a mini CUDA Toolkit from cache
24

35
inputs:
4-
client-repo:
5-
required: true
6-
type: string
7-
build-type:
8-
required: true
9-
type: string
10-
target-device:
11-
required: true
12-
type: string
136
host-platform:
147
required: true
158
type: string
16-
build-mode:
17-
required: true
18-
type: string
19-
upload-enabled:
20-
required: true
21-
type: boolean
22-
python-version:
23-
required: true
24-
type: string
259
cuda-version:
2610
required: true
2711
type: string
2812

2913
runs:
3014
using: composite
3115
steps:
32-
# WAR: setup-python is not relocatable...
33-
# see https://github.com/actions/setup-python/issues/871
34-
- name: Set up Python ${{ inputs.python-version }}
35-
if: ${{ startsWith(inputs.host-platform, 'linux') }}
36-
id: setup-python
37-
uses: actions/setup-python@v5
38-
with:
39-
python-version: "3.12"
40-
41-
- name: Set up MSVC
42-
if: ${{ startsWith(inputs.host-platform, 'win') }}
43-
uses: ilammy/msvc-dev-cmd@v1
44-
45-
- name: Dump environment
46-
shell: bash --noprofile --norc -xeuo pipefail {0}
47-
run: |
48-
env
49-
5016
- name: Set up CTK cache variable
5117
shell: bash --noprofile --norc -xeuo pipefail {0}
5218
run: |
5319
echo "CTK_CACHE_KEY=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}" >> $GITHUB_ENV
5420
echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}.tar.gz" >> $GITHUB_ENV
5521
22+
- 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[@]}
52+
5653
- name: Download CTK cache
5754
id: ctk-get-cache
5855
uses: actions/cache/restore@v4
5956
continue-on-error: true
6057
with:
6158
key: ${{ env.CTK_CACHE_KEY }}
6259
path: ./${{ env.CTK_CACHE_FILENAME }}
60+
fail-on-cache-miss: false
6361

6462
- name: Get CUDA components
6563
if: ${{ steps.ctk-get-cache.outputs.cache-hit != 'true' }}
@@ -72,15 +70,15 @@ runs:
7270
CTK_BASE_URL="https://developer.download.nvidia.com/compute/cuda/redist/"
7371
CTK_JSON_URL="$CTK_BASE_URL/redistrib_${{ inputs.cuda-version }}.json"
7472
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
75-
if [[ "${{ inputs.host-platform }}" == "linux-x64" ]]; then
73+
if [[ "${{ inputs.host-platform }}" == "linux-64" ]]; then
7674
CTK_SUBDIR="linux-x86_64"
7775
elif [[ "${{ inputs.host-platform }}" == "linux-aarch64" ]]; then
7876
CTK_SUBDIR="linux-sbsa"
7977
fi
8078
function extract() {
8179
tar -xvf $1 -C $CUDA_PATH --strip-components=1
8280
}
83-
elif [[ "${{ inputs.host-platform }}" == "win-x64" ]]; then
81+
elif [[ "${{ inputs.host-platform }}" == "win-64" ]]; then
8482
CTK_SUBDIR="windows-x86_64"
8583
function extract() {
8684
_TEMP_DIR_=$(mktemp -d)
@@ -112,16 +110,16 @@ runs:
112110
populate_cuda_path cuda_cudart
113111
populate_cuda_path cuda_nvrtc
114112
populate_cuda_path cuda_profiler_api
115-
populate_cuda_path libnvjitlink
113+
populate_cuda_path cuda_cccl
114+
if [[ "$(cut -d '.' -f 1 <<< ${{ inputs.cuda-version }})" -ge 12 ]]; then
115+
populate_cuda_path libnvjitlink
116+
fi
116117
ls -l $CUDA_PATH
117118
118119
# Prepare the cache
119120
# Note: try to escape | and > ...
120121
tar -czvf ${CTK_CACHE_FILENAME} ${CUDA_PATH}
121122
122-
# Note: the headers will be copied into the cibuildwheel manylinux container,
123-
# so setting the CUDA_PATH env var here is meaningless.
124-
125123
- name: Upload CTK cache
126124
if: ${{ always() &&
127125
steps.ctk-get-cache.outputs.cache-hit != 'true' }}
@@ -142,44 +140,10 @@ runs:
142140
exit 1
143141
fi
144142
145-
- name: Set environment variables
143+
- name: Set output environment variables
146144
shell: bash --noprofile --norc -xeuo pipefail {0}
147145
run: |
148-
# TODO: just align host-platform names with TARGET_PLATFORM...
149-
if [[ "${{ inputs.host-platform }}" == "linux-x64" ]]; then
150-
TARGET_PLATFORM='linux-64'
151-
elif [[ "${{ inputs.host-platform }}" == "linux-aarch64" ]]; then
152-
TARGET_PLATFORM='linux-aarch64'
153-
elif [[ "${{ inputs.host-platform }}" == "win-x64" ]]; then
154-
TARGET_PLATFORM='win-64'
155-
fi
156-
157-
PYTHON_VERSION_FORMATTED=$(echo '${{ inputs.python-version }}' | tr -d '.')
158-
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
159-
CIBW_BUILD="cp${PYTHON_VERSION_FORMATTED}-manylinux*"
160-
REPO_DIR=$(pwd)
161-
elif [[ "${{ inputs.host-platform }}" == win* ]]; then
162-
CIBW_BUILD="cp${PYTHON_VERSION_FORMATTED}-win_amd64"
163-
PWD=$(pwd)
164-
REPO_DIR=$(cygpath -w $PWD)
165-
fi
166-
167-
BUILD_MODE="${{ inputs.build-mode }}"
168-
if [[ ("${BUILD_MODE}" == "") || ("${BUILD_MODE}" == "release") ]]; then
169-
# We upload release versions in the default folder.
170-
PKG_DIR="${TARGET_PLATFORM}"
171-
else
172-
PKG_DIR="${BUILD_MODE}/${TARGET_PLATFORM}"
173-
fi
174-
175-
echo "PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV
176-
echo "REPO_DIR=$REPO_DIR" >> $GITHUB_ENV
177-
echo "PKG_DIR=${PKG_DIR}" >> $GITHUB_ENV
178-
echo "CUDA_CORE_ARTIFACT_NAME=cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ inputs.host-platform }}-${{ inputs.build-type }}-${{ github.sha }}" >> $GITHUB_ENV
179-
echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV
180-
echo "CUDA_BINDINGS_ARTIFACT_NAME=cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.cuda-version }}-${{ inputs.host-platform }}-${{ inputs.build-type }}-${{ github.sha }}" >> $GITHUB_ENV
181-
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
182-
echo "UPLOAD_ENABLED=${{ (inputs.upload-enabled == 'true' && 'ON') || 'OFF' }}" >> $GITHUB_ENV
183-
echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
184-
echo "TARGET_PLATFORM=${TARGET_PLATFORM}" >> $GITHUB_ENV
185-
echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV
146+
CUDA_PATH=$(realpath "./cuda_toolkit")
147+
echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV
148+
echo "${CUDA_PATH}/bin" >> $GITHUB_PATH
149+
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:${CUDA_PATH}/lib" >> $GITHUB_ENV

.github/actions/test/action.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)