Skip to content

Commit a14557b

Browse files
authored
ci: add selective wheel build plumbing (#2464)
1 parent 844124c commit a14557b

1 file changed

Lines changed: 116 additions & 12 deletions

File tree

.github/workflows/build-wheel.yml

Lines changed: 116 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,45 @@ on:
1414
prev-cuda-version:
1515
required: true
1616
type: string
17+
build-pathfinder:
18+
required: false
19+
type: boolean
20+
default: true
21+
build-bindings:
22+
required: false
23+
type: boolean
24+
default: true
25+
build-core:
26+
required: false
27+
type: boolean
28+
default: true
29+
build-python:
30+
required: false
31+
type: boolean
32+
default: true
33+
test-bindings:
34+
required: false
35+
type: boolean
36+
default: true
37+
test-core:
38+
required: false
39+
type: boolean
40+
default: true
41+
baseline-run-id:
42+
required: false
43+
type: string
44+
default: ""
45+
baseline-sha:
46+
required: false
47+
type: string
48+
default: ""
1749

1850
defaults:
1951
run:
2052
shell: bash --noprofile --norc -xeuo pipefail {0}
2153

2254
permissions:
55+
actions: read
2356
contents: read # This is required for actions/checkout
2457

2558
jobs:
@@ -50,14 +83,15 @@ jobs:
5083
filter: blob:none
5184

5285
- name: Install latest rapidsai/sccache
53-
if: ${{ startsWith(inputs.host-platform, 'linux') }}
86+
if: ${{ startsWith(inputs.host-platform, 'linux') && (inputs.build-bindings || inputs.build-core) }}
5487
run: |
5588
curl -fsSL "https://github.com/rapidsai/sccache/releases/latest/download/sccache-$(uname -m)-unknown-linux-musl.tar.gz" \
5689
| sudo tar -C /usr/local/bin -xvzf - --wildcards --strip-components=1 -x '*/sccache'
5790
echo "SCCACHE_PATH=/usr/local/bin/sccache" >> "$GITHUB_ENV"
5891
5992
# xref: https://github.com/orgs/community/discussions/42856#discussioncomment-7678867
6093
- name: Adding addtional GHA cache-related env vars
94+
if: ${{ inputs.build-bindings || inputs.build-core }}
6195
uses: actions/github-script@v9
6296
with:
6397
script: |
@@ -84,13 +118,13 @@ jobs:
84118
python-version: "3.12"
85119

86120
- name: Set up MSVC
87-
if: ${{ startsWith(inputs.host-platform, 'win') }}
121+
if: ${{ startsWith(inputs.host-platform, 'win') && (inputs.build-bindings || inputs.build-core || inputs.test-bindings || inputs.test-core) }}
88122
uses: step-security/msvc-dev-cmd@22c98154b708dbd743e6f27a933cf6ceba3305c4 # v1.13.1
89123

90124
- name: Set up yq
91125
# GitHub made an unprofessional decision to not provide it in their Windows VMs,
92126
# see https://github.com/actions/runner-images/issues/7443.
93-
if: ${{ startsWith(inputs.host-platform, 'win') }}
127+
if: ${{ startsWith(inputs.host-platform, 'win') && inputs.build-core }}
94128
env:
95129
YQ_VERSION: v4.52.5
96130
YQ_SHA256: 47594981f3848a4b4447494adeca9555f908f7cf0a89c4da3fd0243a4631da1c
@@ -128,11 +162,21 @@ jobs:
128162
129163
# To keep the build workflow simple, all matrix jobs will build a wheel for later use within this workflow.
130164
- name: Build and check cuda.pathfinder wheel
165+
if: ${{ inputs.build-pathfinder }}
131166
run: |
132167
pushd cuda_pathfinder
133168
pip wheel -v --no-deps .
134169
popd
135170
171+
- name: Download reusable cuda.pathfinder wheel
172+
if: ${{ !inputs.build-pathfinder }}
173+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
174+
with:
175+
name: cuda-pathfinder-wheel
176+
path: cuda_pathfinder
177+
github-token: ${{ github.token }}
178+
run-id: ${{ inputs.baseline-run-id }}
179+
136180
- name: List the cuda.pathfinder artifacts directory
137181
run: |
138182
if [[ "${{ inputs.host-platform }}" == win* ]]; then
@@ -146,11 +190,12 @@ jobs:
146190
# We only need/want a single pure python wheel, pick linux-64 index 0.
147191
# This is what we will use for testing & releasing.
148192
- name: Check cuda.pathfinder wheel
149-
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
193+
if: ${{ inputs.build-pathfinder && strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
150194
run: |
151195
twine check --strict cuda_pathfinder/*.whl
152196
153197
- name: Constrain builds to the local cuda.pathfinder wheel
198+
if: ${{ inputs.build-bindings }}
154199
run: |
155200
pathfinder_wheels=(cuda_pathfinder/cuda_pathfinder-*.whl)
156201
test "${#pathfinder_wheels[@]}" -eq 1
@@ -172,13 +217,15 @@ jobs:
172217
if-no-files-found: error
173218

174219
- name: Set up mini CTK
220+
if: ${{ inputs.build-bindings || inputs.build-core || inputs.test-bindings || inputs.test-core }}
175221
uses: ./.github/actions/fetch_ctk
176222
continue-on-error: false
177223
with:
178224
host-platform: ${{ inputs.host-platform }}
179225
cuda-version: ${{ inputs.cuda-version }}
180226

181227
- name: Build cuda.bindings wheel
228+
if: ${{ inputs.build-bindings }}
182229
uses: pypa/cibuildwheel@4726cd35bb13f7bde50cf2761f2499ac7b3aa32c # v4.1.1
183230
with:
184231
package-dir: ./cuda_bindings/
@@ -224,13 +271,22 @@ jobs:
224271
echo "ok!"
225272
226273
- name: Report sccache stats (cuda.bindings)
227-
if: ${{ inputs.host-platform != 'win-64' }}
274+
if: ${{ inputs.build-bindings && inputs.host-platform != 'win-64' }}
228275
uses: ./.github/actions/sccache-summary
229276
with:
230277
json-file: sccache_bindings.json
231278
label: "cuda.bindings"
232279
build-step: "Build cuda.bindings wheel"
233280

281+
- name: Download reusable cuda.bindings wheel
282+
if: ${{ !inputs.build-bindings }}
283+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
284+
with:
285+
name: ${{ env.CUDA_BINDINGS_ARTIFACT_BASENAME }}-${{ inputs.baseline-sha }}
286+
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
287+
github-token: ${{ github.token }}
288+
run-id: ${{ inputs.baseline-run-id }}
289+
234290
- name: List the cuda.bindings artifacts directory
235291
run: |
236292
if [[ "${{ inputs.host-platform }}" == win* ]]; then
@@ -242,10 +298,12 @@ jobs:
242298
ls -lahR ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
243299
244300
- name: Check cuda.bindings wheel
301+
if: ${{ inputs.build-bindings }}
245302
run: |
246303
twine check --strict ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
247304
248305
- name: Constrain cuda.core to the local cuda.bindings wheel
306+
if: ${{ inputs.build-core }}
249307
run: |
250308
pathfinder_wheels=(cuda_pathfinder/cuda_pathfinder-*.whl)
251309
bindings_wheels=("${CUDA_BINDINGS_ARTIFACTS_DIR}"/cuda_bindings-"${BUILD_CUDA_MAJOR}".*.whl)
@@ -274,6 +332,7 @@ jobs:
274332
if-no-files-found: error
275333

276334
- name: Build cuda.core wheel
335+
if: ${{ inputs.build-core }}
277336
uses: pypa/cibuildwheel@4726cd35bb13f7bde50cf2761f2499ac7b3aa32c # v4.1.1
278337
with:
279338
package-dir: ./cuda_core/
@@ -321,14 +380,15 @@ jobs:
321380
echo "ok!"
322381
323382
- name: Report sccache stats (cuda.core)
324-
if: ${{ inputs.host-platform != 'win-64' }}
383+
if: ${{ inputs.build-core && inputs.host-platform != 'win-64' }}
325384
uses: ./.github/actions/sccache-summary
326385
with:
327386
json-file: sccache_core.json
328387
label: "cuda.core"
329388
build-step: "Build cuda.core wheel"
330389

331390
- name: List the cuda.core artifacts directory and rename
391+
if: ${{ inputs.build-core }}
332392
run: |
333393
if [[ "${{ inputs.host-platform }}" == win* ]]; then
334394
export CHOWN=chown
@@ -350,15 +410,33 @@ jobs:
350410
351411
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
352412
413+
- name: Download reusable cuda.core wheel
414+
if: ${{ !inputs.build-core }}
415+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
416+
with:
417+
name: ${{ env.CUDA_CORE_ARTIFACT_BASENAME }}-${{ inputs.baseline-sha }}
418+
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
419+
github-token: ${{ github.token }}
420+
run-id: ${{ inputs.baseline-run-id }}
421+
353422
# We only need/want a single pure python wheel, pick linux-64 index 0.
354423
- name: Build and check cuda-python wheel
355-
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
424+
if: ${{ inputs.build-python && strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
356425
run: |
357426
pushd cuda_python
358427
pip wheel -v --no-deps .
359428
twine check --strict *.whl
360429
popd
361430
431+
- name: Download reusable cuda-python wheel
432+
if: ${{ !inputs.build-python && strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
433+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
434+
with:
435+
name: cuda-python-wheel
436+
path: cuda_python
437+
github-token: ${{ github.token }}
438+
run-id: ${{ inputs.baseline-run-id }}
439+
362440
- name: List the cuda-python artifacts directory
363441
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
364442
run: |
@@ -380,23 +458,25 @@ jobs:
380458

381459
- name: Set up Python
382460
id: setup-python2
461+
if: ${{ inputs.test-bindings || inputs.test-core }}
383462
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
384463
with:
385464
python-version: ${{ matrix.python-version }}
386465
# TODO: remove allow-prereleases once 3.15 is officially supported
387466
allow-prereleases: ${{ startsWith(matrix.python-version, '3.15') }}
388467

389468
- name: Enable Scientific Python Nightly Wheels for Python 3.15
390-
if: ${{ startsWith(matrix.python-version, '3.15') }}
469+
if: ${{ (inputs.test-bindings || inputs.test-core) && startsWith(matrix.python-version, '3.15') }}
391470
run: |
392471
echo "PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple" >> "$GITHUB_ENV"
393472
echo "PIP_ONLY_BINARY=numpy" >> "$GITHUB_ENV"
394473
395474
- name: verify free-threaded build
396-
if: endsWith(matrix.python-version, 't')
475+
if: ${{ (inputs.test-bindings || inputs.test-core) && endsWith(matrix.python-version, 't') }}
397476
run: python -c 'import sys; assert not sys._is_gil_enabled()'
398477

399478
- name: Set up Python include paths
479+
if: ${{ inputs.test-bindings || inputs.test-core }}
400480
run: |
401481
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
402482
echo "CPLUS_INCLUDE_PATH=${Python3_ROOT_DIR}/include/python${{ matrix.python-version }}" >> $GITHUB_ENV
@@ -407,38 +487,53 @@ jobs:
407487
echo "PY_EXT_SUFFIX=$(python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")" >> $GITHUB_ENV
408488
409489
- name: Install cuda.pathfinder (required for next step)
490+
if: ${{ inputs.test-bindings || inputs.test-core }}
410491
run: |
411492
pip install cuda_pathfinder/*.whl
412493
413494
- name: Hide GNU link.exe so Meson finds MSVC link.exe
414-
if: ${{ startsWith(inputs.host-platform, 'win') }}
495+
if: ${{ startsWith(inputs.host-platform, 'win') && (inputs.test-bindings || inputs.test-core) }}
415496
run: |
416497
if [ -f "/c/Program Files/Git/usr/bin/link.exe" ]; then
417498
mv "/c/Program Files/Git/usr/bin/link.exe" "/c/Program Files/Git/usr/bin/link.exe.bak"
418499
fi
419500
420501
- name: Build cuda.bindings Cython tests
502+
if: ${{ inputs.test-bindings }}
421503
run: |
422504
pip install ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl --group ./cuda_bindings/pyproject.toml:test
423505
pushd ${{ env.CUDA_BINDINGS_CYTHON_TESTS_DIR }}
424506
bash build_tests.sh
425507
popd
426508
427509
- name: Upload cuda.bindings Cython tests
510+
if: ${{ inputs.test-bindings }}
428511
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
429512
with:
430513
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}-tests
431514
path: ${{ env.CUDA_BINDINGS_CYTHON_TESTS_DIR }}/test_*${{ env.PY_EXT_SUFFIX }}
432515
if-no-files-found: error
433516

434517
- name: Build cuda.core Cython tests
518+
if: ${{ inputs.test-core }}
435519
run: |
436-
pip install ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/"cu${BUILD_CUDA_MAJOR}"/*.whl --group ./cuda_core/pyproject.toml:test
520+
pip install ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
521+
if ${{ inputs.build-core }}; then
522+
core_wheel=$(find "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_CUDA_MAJOR}" -maxdepth 1 -type f -name '*.whl' -print -quit)
523+
else
524+
core_wheel=$(find "${{ env.CUDA_CORE_ARTIFACTS_DIR }}" -maxdepth 1 -type f -name '*.whl' -print -quit)
525+
fi
526+
if [[ -z "${core_wheel}" ]]; then
527+
echo "No cuda.core wheel found" >&2
528+
exit 1
529+
fi
530+
pip install "${core_wheel}" --group ./cuda_core/pyproject.toml:test
437531
pushd ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}
438532
bash build_tests.sh
439533
popd
440534
441535
- name: Upload cuda.core Cython tests
536+
if: ${{ inputs.test-core }}
442537
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
443538
with:
444539
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}-tests
@@ -447,6 +542,7 @@ jobs:
447542

448543
# Note: This overwrites CUDA_PATH etc
449544
- name: Set up mini CTK
545+
if: ${{ inputs.build-core || inputs.test-core }}
450546
uses: ./.github/actions/fetch_ctk
451547
continue-on-error: false
452548
with:
@@ -455,11 +551,13 @@ jobs:
455551
cuda-path: "./cuda_toolkit_prev"
456552

457553
- name: Build cuda.core test binaries
554+
if: ${{ inputs.test-core }}
458555
run: |
459556
nvcc --version
460557
python "${{ env.CUDA_CORE_TEST_BINARIES_DIR }}/build_test_binaries.py"
461558
462559
- name: Upload cuda.core test binaries
560+
if: ${{ inputs.test-core }}
463561
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
464562
with:
465563
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}-test-binaries
@@ -470,6 +568,7 @@ jobs:
470568
if-no-files-found: error
471569

472570
- name: Download cuda.bindings build artifacts from the prior branch
571+
if: ${{ inputs.build-core }}
473572
env:
474573
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
475574
run: |
@@ -498,6 +597,7 @@ jobs:
498597
rmdir $OLD_BASENAME
499598
500599
- name: Constrain previous cuda.core to the downloaded cuda.bindings wheel
600+
if: ${{ inputs.build-core }}
501601
run: |
502602
pathfinder_wheels=(cuda_pathfinder/cuda_pathfinder-*.whl)
503603
bindings_wheels=(cuda_bindings/dist-prev/cuda_bindings-"${BUILD_PREV_CUDA_MAJOR}".*.whl)
@@ -519,6 +619,7 @@ jobs:
519619
} | tee wheel-constraints/cuda-core-prev.txt
520620
521621
- name: Build cuda.core wheel
622+
if: ${{ inputs.build-core }}
522623
uses: pypa/cibuildwheel@4726cd35bb13f7bde50cf2761f2499ac7b3aa32c # v4.1.1
523624
with:
524625
package-dir: ./cuda_core/
@@ -566,14 +667,15 @@ jobs:
566667
echo "ok!"
567668
568669
- name: Report sccache stats (cuda.core prev)
569-
if: ${{ inputs.host-platform != 'win-64' }}
670+
if: ${{ inputs.build-core && inputs.host-platform != 'win-64' }}
570671
uses: ./.github/actions/sccache-summary
571672
with:
572673
json-file: sccache_core_prev.json
573674
label: "cuda.core (prev CTK)"
574675
build-step: "Build cuda.core wheel"
575676

576677
- name: List the cuda.core artifacts directory and rename
678+
if: ${{ inputs.build-core }}
577679
run: |
578680
if [[ "${{ inputs.host-platform }}" == win* ]]; then
579681
export CHOWN=chown
@@ -597,6 +699,7 @@ jobs:
597699
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
598700
599701
- name: Merge cuda.core wheels
702+
if: ${{ inputs.build-core }}
600703
run: |
601704
pip install wheel
602705
python ci/tools/merge_cuda_core_wheels.py \
@@ -605,6 +708,7 @@ jobs:
605708
--output-dir "${{ env.CUDA_CORE_ARTIFACTS_DIR }}"
606709
607710
- name: Check cuda.core wheel
711+
if: ${{ inputs.build-core }}
608712
run: |
609713
twine check --strict ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
610714

0 commit comments

Comments
 (0)