Skip to content

Commit 25c848a

Browse files
add wdws and macos runs to main pushes, simplify
1 parent 77be758 commit 25c848a

1 file changed

Lines changed: 79 additions & 58 deletions

File tree

.github/workflows/cibuildwheel.yml

Lines changed: 79 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,176 +15,196 @@ on:
1515
branches: [ "main" ]
1616

1717
jobs:
18-
test:
19-
name: Test on ${{ matrix.os }} with Python ${{ matrix.python }}
18+
build_wheels:
19+
name: Build cp${{ matrix.python }}-${{ matrix.platform_id }} on ${{ matrix.os }}
2020
runs-on: ${{ matrix.os }}
21-
if: github.event_name == 'push' && contains(github.ref, 'main')
21+
if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'push' && contains(github.ref, 'wheels')) || github.event_name == 'pull_request'
22+
23+
# for conda-incubator/setup-miniconda to work
24+
defaults:
25+
run:
26+
shell: bash -el {0}
27+
2228
strategy:
2329
fail-fast: false
2430
matrix:
2531
include:
26-
# Linux (subset of versions)
27-
- os: ubuntu-latest
28-
python: 311
29-
platform_id: manylinux_x86_64
30-
manylinux_image: manylinux_2_28
32+
# push/PR events (subset, 3 py versions for ubuntu and 1 each for windows and macos)
3133
- os: ubuntu-latest
3234
python: 312
3335
platform_id: manylinux_x86_64
3436
manylinux_image: manylinux_2_28
37+
build_condition: reduced
3538
- os: ubuntu-latest
3639
python: 313
3740
platform_id: manylinux_x86_64
3841
manylinux_image: manylinux_2_28
42+
build_condition: reduced
3943
- os: ubuntu-latest
4044
python: 314
4145
platform_id: manylinux_x86_64
4246
manylinux_image: manylinux_2_28
43-
steps:
44-
- uses: actions/checkout@v4
45-
name: Checkout repository
46-
47-
- name: Setup Python
48-
uses: actions/setup-python@v6
49-
with:
50-
python-version: '3.13'
51-
52-
- name: Free up disk space (Linux)
53-
if: startsWith(matrix.os, 'ubuntu')
54-
run: |
55-
sudo rm -rf /usr/share/dotnet
56-
sudo rm -rf /opt/ghc
57-
sudo rm -rf /usr/local/share/boost
58-
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
59-
sudo apt-get clean || true
60-
df -h
61-
62-
- name: Install cibuildwheel
63-
run: python -m pip install cibuildwheel
64-
- name: Build wheels for CPython (Linux)
65-
run: |
66-
python -m cibuildwheel --output-dir dist
67-
env:
68-
# only build for specific platforms
69-
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
70-
CIBW_SKIP: "*musllinux*"
71-
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
72-
73-
CIBW_BUILD_VERBOSITY: 1
74-
CIBW_BEFORE_BUILD: "pip cache purge"
75-
CIBW_TEST_REQUIRES: pytest pytest-cov
76-
CIBW_TEST_COMMAND: pytest -v {project}
77-
78-
build_wheels:
79-
name: Build cp${{ matrix.python }}-${{ matrix.platform_id }} on ${{ matrix.os }}
80-
runs-on: ${{ matrix.os }}
81-
if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'push' && contains(github.ref, 'wheels')) || github.event_name == 'pull_request'
82-
83-
# for conda-incubator/setup-miniconda to work
84-
defaults:
85-
run:
86-
shell: bash -el {0}
87-
88-
strategy:
89-
fail-fast: false
90-
matrix:
91-
include:
47+
build_condition: reduced
48+
- os: windows-latest
49+
python: 312
50+
platform_id: win_amd64
51+
build_condition: reduced
52+
- os: macos-14
53+
python: 312
54+
platform_id: macosx_arm64
55+
build_condition: reduced
56+
57+
# For releases and PR events (full matrix)
9258
# Linux
9359
- os: ubuntu-latest
9460
python: 39
9561
platform_id: manylinux_x86_64
9662
manylinux_image: manylinux_2_28
63+
build_condition: full
9764
- os: ubuntu-latest
9865
python: 310
9966
platform_id: manylinux_x86_64
10067
manylinux_image: manylinux_2_28
68+
build_condition: full
10169
- os: ubuntu-latest
10270
python: 311
10371
platform_id: manylinux_x86_64
10472
manylinux_image: manylinux_2_28
73+
build_condition: full
10574
- os: ubuntu-latest
10675
python: 312
10776
platform_id: manylinux_x86_64
10877
manylinux_image: manylinux_2_28
78+
build_condition: full
10979
- os: ubuntu-latest
11080
python: 313
11181
platform_id: manylinux_x86_64
11282
manylinux_image: manylinux_2_28
83+
build_condition: full
11384
- os: ubuntu-latest
11485
python: 314
11586
platform_id: manylinux_x86_64
11687
manylinux_image: manylinux_2_28
88+
build_condition: full
11789
# Windows
11890
- os: windows-latest
11991
python: 39
12092
platform_id: win_amd64
93+
build_condition: full
12194
- os: windows-latest
12295
python: 310
12396
platform_id: win_amd64
97+
build_condition: full
12498
- os: windows-latest
12599
python: 311
126100
platform_id: win_amd64
101+
build_condition: full
127102
- os: windows-latest
128103
python: 312
129104
platform_id: win_amd64
105+
build_condition: full
130106
- os: windows-latest
131107
python: 313
132108
platform_id: win_amd64
109+
build_condition: full
133110
- os: windows-latest
134111
python: 314
135112
platform_id: win_amd64
113+
build_condition: full
136114
# macOS x86_64 (py314 not supported due to missing torchvision wheels)
137115
- os: macos-15-intel
138116
python: 39
139117
platform_id: macosx_x86_64
118+
build_condition: full
140119
- os: macos-15-intel
141120
python: 310
142121
platform_id: macosx_x86_64
122+
build_condition: full
143123
- os: macos-15-intel
144124
python: 311
145125
platform_id: macosx_x86_64
126+
build_condition: full
146127
- os: macos-15-intel
147128
python: 312
148129
platform_id: macosx_x86_64
130+
build_condition: full
149131
- os: macos-15-intel
150132
python: 313
151133
platform_id: macosx_x86_64
134+
build_condition: full
152135
# macOS arm64
153136
- os: macos-14
154137
python: 39
155138
platform_id: macosx_arm64
139+
build_condition: full
156140
- os: macos-14
157141
python: 310
158142
platform_id: macosx_arm64
143+
build_condition: full
159144
- os: macos-14
160145
python: 311
161146
platform_id: macosx_arm64
147+
build_condition: full
162148
- os: macos-14
163149
python: 312
164150
platform_id: macosx_arm64
151+
build_condition: full
165152
- os: macos-14
166153
python: 313
167154
platform_id: macosx_arm64
155+
build_condition: full
168156
- os: macos-14
169157
python: 314
170158
platform_id: macosx_arm64
159+
build_condition: full
171160

172161
steps:
162+
# skip based on event type and build condition
163+
- name: Skip build check
164+
id: skip_check
165+
run: |
166+
SKIP=false
167+
168+
# run reduced builds for pushes to main
169+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" != *"wheels"* ]]; then
170+
if [[ "${{ matrix.build_condition }}" == "full" ]]; then
171+
SKIP=true
172+
fi
173+
fi
174+
175+
# run full builds for releases and PRs
176+
if [[ ("${{ github.event_name }}" == "release" || "${{ github.event_name }}" == "pull_request") && "${{ matrix.build_condition }}" == "reduced" ]]; then
177+
SKIP=true
178+
fi
179+
180+
# run full builds for pushes to wheels branch
181+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == *"wheels"* && "${{ matrix.build_condition }}" == "reduced" ]]; then
182+
SKIP=true
183+
fi
184+
185+
echo "skip=$SKIP" >> $GITHUB_OUTPUT
186+
if [[ "$SKIP" == "true" ]]; then
187+
echo "Skipping build for ${{ matrix.build_condition }} on ${{ github.event_name }}"
188+
fi
189+
173190
- name: Checkout repository
191+
if: steps.skip_check.outputs.skip != 'true'
174192
uses: actions/checkout@v5
175193

176194
- name: Setup Python
195+
if: steps.skip_check.outputs.skip != 'true'
177196
uses: actions/setup-python@v6
178197
with:
179198
python-version: '3.13'
180199

181200
- name: Setup Miniconda
182201
uses: conda-incubator/setup-miniconda@v3
183-
if: ${{ startsWith(matrix.platform_id, 'macosx') }}
202+
if: ${{ steps.skip_check.outputs.skip != 'true' && startsWith(matrix.platform_id, 'macosx') }}
184203
with:
185204
miniforge-version: latest
186205

187206
- name: Build and test wheels
207+
if: steps.skip_check.outputs.skip != 'true'
188208
run: |
189209
set -ex
190210
# follow approach of scikit-learn: https://github.com/scikit-learn/scikit-learn/blob/7f0900c265936eac9a89bba37eb19ee66208d46a/build_tools/wheels/build_wheels.sh
@@ -219,6 +239,7 @@ jobs:
219239
CIBW_TEST_COMMAND: pytest -v --cov=spotiflow {project}
220240

221241
- name: Upload wheels
242+
if: steps.skip_check.outputs.skip != 'true'
222243
uses: actions/upload-artifact@v5
223244
with:
224245
name: cibw-wheels-cp${{ matrix.python }}-${{ matrix.platform_id }}

0 commit comments

Comments
 (0)