Skip to content

Commit e11dc15

Browse files
committed
Refactor build workflow to generate dynamic build matrix based on input parameters; enhance compatibility checks for Python and CUDA versions
1 parent 1684844 commit e11dc15

1 file changed

Lines changed: 58 additions & 9 deletions

File tree

.github/workflows/build-windows-wheels.yml

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,65 @@ on:
2828
default: 'true'
2929

3030
jobs:
31+
generate-matrix:
32+
runs-on: ubuntu-latest
33+
outputs:
34+
matrix: ${{ steps.set-matrix.outputs.matrix }}
35+
steps:
36+
- name: Generate build matrix
37+
id: set-matrix
38+
run: |
39+
# Get input parameters or use defaults
40+
python_versions="${{ github.event.inputs.python_versions || '3.8,3.9,3.10,3.11,3.12' }}"
41+
cuda_versions="${{ github.event.inputs.cuda_versions || '11.8,12.1,12.4,12.6,12.8' }}"
42+
platforms="${{ github.event.inputs.platforms || 'windows,linux' }}"
43+
44+
# Convert comma-separated strings to arrays
45+
IFS=',' read -ra PYTHON_ARRAY <<< "$python_versions"
46+
IFS=',' read -ra CUDA_ARRAY <<< "$cuda_versions"
47+
IFS=',' read -ra PLATFORM_ARRAY <<< "$platforms"
48+
49+
# Map platforms to OS
50+
os_array=()
51+
for platform in "${PLATFORM_ARRAY[@]}"; do
52+
case "$platform" in
53+
"windows") os_array+=("windows-2022") ;;
54+
"linux") os_array+=("ubuntu-22.04") ;;
55+
esac
56+
done
57+
58+
# Build matrix JSON
59+
matrix_json="{\"include\":["
60+
first=true
61+
62+
for os in "${os_array[@]}"; do
63+
for python in "${PYTHON_ARRAY[@]}"; do
64+
for cuda in "${CUDA_ARRAY[@]}"; do
65+
# Skip Python 3.12 with CUDA 11.8 for compatibility
66+
if [[ "$python" == "3.12" && "$cuda" == "11.8" ]]; then
67+
continue
68+
fi
69+
70+
if [ "$first" = true ]; then
71+
first=false
72+
else
73+
matrix_json+=","
74+
fi
75+
76+
matrix_json+="{\"os\":\"$os\",\"python-version\":\"$python\",\"cuda-version\":\"$cuda\"}"
77+
done
78+
done
79+
done
80+
81+
matrix_json+="]}"
82+
83+
echo "Generated matrix: $matrix_json"
84+
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
85+
3186
build-wheels:
87+
needs: generate-matrix
3288
strategy:
33-
matrix:
34-
os: [windows-2022, ubuntu-22.04]
35-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
36-
cuda-version: ['11.8', '12.1', '12.4', '12.6', '12.8']
37-
exclude:
38-
# Exclude Python 3.12 with older CUDA versions for compatibility
39-
- python-version: '3.12'
40-
cuda-version: '11.8'
89+
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
4190
fail-fast: false
4291

4392
runs-on: ${{ matrix.os }}
@@ -402,7 +451,7 @@ jobs:
402451
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
403452

404453
test-wheels:
405-
needs: build-wheels
454+
needs: [build-wheels, generate-matrix]
406455
strategy:
407456
matrix:
408457
os: [windows-2022, ubuntu-22.04]

0 commit comments

Comments
 (0)