Skip to content

Commit 5c0e919

Browse files
committed
Generate CI matrix at runtime
1 parent 12eeb3e commit 5c0e919

File tree

5 files changed

+1139
-1374
lines changed

5 files changed

+1139
-1374
lines changed

.github/workflows/apple.yml

Lines changed: 36 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -40,214 +40,49 @@ jobs:
4040
name: pythonbuild
4141
path: target/release/pythonbuild
4242

43-
build:
44-
strategy:
45-
fail-fast: false
46-
matrix:
47-
build:
48-
- target_triple: 'aarch64-apple-darwin'
49-
runner: macos-14
50-
py: 'cpython-3.9'
51-
options: 'debug'
52-
- target_triple: 'aarch64-apple-darwin'
53-
runner: macos-14
54-
py: 'cpython-3.9'
55-
options: 'pgo'
56-
- target_triple: 'aarch64-apple-darwin'
57-
runner: macos-14
58-
py: 'cpython-3.9'
59-
options: 'pgo+lto'
60-
61-
- target_triple: 'aarch64-apple-darwin'
62-
runner: macos-14
63-
py: 'cpython-3.10'
64-
options: 'debug'
65-
- target_triple: 'aarch64-apple-darwin'
66-
runner: macos-14
67-
py: 'cpython-3.10'
68-
options: 'pgo'
69-
- target_triple: 'aarch64-apple-darwin'
70-
runner: macos-14
71-
py: 'cpython-3.10'
72-
options: 'pgo+lto'
73-
74-
- target_triple: 'aarch64-apple-darwin'
75-
runner: macos-14
76-
py: 'cpython-3.11'
77-
options: 'debug'
78-
- target_triple: 'aarch64-apple-darwin'
79-
runner: macos-14
80-
py: 'cpython-3.11'
81-
options: 'pgo'
82-
- target_triple: 'aarch64-apple-darwin'
83-
runner: macos-14
84-
py: 'cpython-3.11'
85-
options: 'pgo+lto'
86-
87-
- target_triple: 'aarch64-apple-darwin'
88-
runner: macos-14
89-
py: 'cpython-3.12'
90-
options: 'debug'
91-
- target_triple: 'aarch64-apple-darwin'
92-
runner: macos-14
93-
py: 'cpython-3.12'
94-
options: 'pgo'
95-
- target_triple: 'aarch64-apple-darwin'
96-
runner: macos-14
97-
py: 'cpython-3.12'
98-
options: 'pgo+lto'
99-
100-
- target_triple: 'aarch64-apple-darwin'
101-
runner: macos-14
102-
py: 'cpython-3.13'
103-
options: 'debug'
104-
- target_triple: 'aarch64-apple-darwin'
105-
runner: macos-14
106-
py: 'cpython-3.13'
107-
options: 'pgo'
108-
- target_triple: 'aarch64-apple-darwin'
109-
runner: macos-14
110-
py: 'cpython-3.13'
111-
options: 'pgo+lto'
112-
113-
- target_triple: 'aarch64-apple-darwin'
114-
runner: macos-14
115-
py: 'cpython-3.13'
116-
options: 'freethreaded+debug'
117-
- target_triple: 'aarch64-apple-darwin'
118-
runner: macos-14
119-
py: 'cpython-3.13'
120-
options: 'freethreaded+pgo'
121-
- target_triple: 'aarch64-apple-darwin'
122-
runner: macos-14
123-
py: 'cpython-3.13'
124-
options: 'freethreaded+pgo+lto'
125-
126-
# macOS on Intel hardware. This is pretty straightforward. We exclude
127-
# noopt because it doesn't provide any compelling advantages over PGO
128-
# or LTO builds.
129-
- target_triple: 'x86_64-apple-darwin'
130-
runner: macos-13
131-
py: 'cpython-3.9'
132-
options: 'debug'
133-
- target_triple: 'x86_64-apple-darwin'
134-
runner: macos-13
135-
py: 'cpython-3.9'
136-
options: 'pgo'
137-
- target_triple: 'x86_64-apple-darwin'
138-
runner: macos-13
139-
py: 'cpython-3.9'
140-
options: 'pgo+lto'
141-
142-
- target_triple: 'x86_64-apple-darwin'
143-
runner: macos-13
144-
py: 'cpython-3.10'
145-
options: 'debug'
146-
- target_triple: 'x86_64-apple-darwin'
147-
runner: macos-13
148-
py: 'cpython-3.10'
149-
options: 'pgo'
150-
- target_triple: 'x86_64-apple-darwin'
151-
runner: macos-13
152-
py: 'cpython-3.10'
153-
options: 'pgo+lto'
154-
155-
- target_triple: 'x86_64-apple-darwin'
156-
runner: macos-13
157-
py: 'cpython-3.11'
158-
options: 'debug'
159-
- target_triple: 'x86_64-apple-darwin'
160-
runner: macos-13
161-
py: 'cpython-3.11'
162-
options: 'pgo'
163-
- target_triple: 'x86_64-apple-darwin'
164-
runner: macos-13
165-
py: 'cpython-3.11'
166-
options: 'pgo+lto'
43+
generate-matrix:
44+
runs-on: ubuntu-latest
45+
outputs:
46+
matrix: ${{ steps.set-matrix.outputs.matrix }}
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Set up Python
51+
uses: astral-sh/setup-uv@v4
16752

168-
- target_triple: 'x86_64-apple-darwin'
169-
runner: macos-13
170-
py: 'cpython-3.12'
171-
options: 'debug'
172-
- target_triple: 'x86_64-apple-darwin'
173-
runner: macos-13
174-
py: 'cpython-3.12'
175-
options: 'pgo'
176-
- target_triple: 'x86_64-apple-darwin'
177-
runner: macos-13
178-
py: 'cpython-3.12'
179-
options: 'pgo+lto'
53+
- name: Get pull request labels
54+
id: get-labels
55+
run: |
56+
# Convert GitHub labels array to comma-separated string
57+
LABELS=$(echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | jq -r 'join(",")')
58+
echo "labels=$LABELS" >> $GITHUB_OUTPUT
59+
60+
- name: Generate build matrix
61+
id: set-matrix
62+
run: |
63+
uv run ci-matrix.py --platform darwin --labels "${{ steps.get-labels.outputs.labels }}" > matrix.json && echo "matrix=$(cat matrix.json)" >> $GITHUB_OUTPUT
64+
# Display the matrix for debugging too
65+
cat matrix.json | jq
18066
181-
- target_triple: 'x86_64-apple-darwin'
182-
runner: macos-13
183-
py: 'cpython-3.13'
184-
options: 'debug'
185-
- target_triple: 'x86_64-apple-darwin'
186-
runner: macos-13
187-
py: 'cpython-3.13'
188-
options: 'pgo'
189-
- target_triple: 'x86_64-apple-darwin'
190-
runner: macos-13
191-
py: 'cpython-3.13'
192-
options: 'pgo+lto'
193-
- target_triple: 'x86_64-apple-darwin'
194-
runner: macos-13
195-
py: 'cpython-3.13'
196-
options: 'freethreaded+debug'
197-
- target_triple: 'x86_64-apple-darwin'
198-
runner: macos-13
199-
py: 'cpython-3.13'
200-
options: 'freethreaded+pgo'
201-
- target_triple: 'x86_64-apple-darwin'
202-
runner: macos-13
203-
py: 'cpython-3.13'
204-
options: 'freethreaded+pgo+lto'
205-
needs:
67+
build:
68+
needs:
69+
- generate-matrix
20670
- pythonbuild
207-
runs-on: ${{ matrix.build.runner }}
71+
strategy:
72+
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
73+
fail-fast: false
74+
runs-on: macos-14
75+
name: ${{ matrix.python }} / ${{ matrix.target_triple }} / ${{ matrix.build_option }}
20876
steps:
20977
- uses: actions/checkout@v4
21078
with:
21179
fetch-depth: 0
21280

213-
- name: Install Python
214-
uses: actions/setup-python@v5
215-
with:
216-
python-version: '3.11'
217-
218-
- name: Download pythonbuild
219-
uses: actions/download-artifact@v4
220-
with:
221-
name: pythonbuild
222-
path: build
223-
22481
- name: Build
22582
run: |
226-
if [ "${{ matrix.build.target_triple }}" = "aarch64-apple-darwin" ]; then
227-
export APPLE_SDK_PATH=/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
228-
elif [ "${{ matrix.build.target_triple }}" = "x86_64-apple-darwin" ]; then
229-
export APPLE_SDK_PATH=/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
230-
else
231-
echo "unhandled target triple: ${{ matrix.build.target_triple }}"
232-
exit 1
233-
fi
234-
235-
./build-macos.py --target-triple ${{ matrix.build.target_triple }} --python ${{ matrix.build.py }} --options ${{ matrix.build.options }}
236-
237-
- name: Upload Distributions
238-
uses: actions/upload-artifact@v4
239-
with:
240-
name: ${{ matrix.build.py }}-${{ matrix.build.target_triple }}-${{ matrix.build.options }}
241-
path: dist/*
242-
243-
- uses: actions/checkout@v4
244-
with:
245-
repository: 'phracker/MacOSX-SDKs'
246-
ref: master
247-
path: macosx-sdks
248-
249-
- name: Validate Distribution
250-
run: |
251-
chmod +x build/pythonbuild
252-
253-
build/pythonbuild validate-distribution --macos-sdks-path macosx-sdks --run dist/*.tar.zst
83+
echo "Building for:"
84+
echo "OS: ${{ matrix.os }}"
85+
echo "Architecture: ${{ matrix.arch }}"
86+
echo "Python: ${{ matrix.python }}"
87+
echo "Target Triple: ${{ matrix.target_triple }}"
88+
echo "Build Option: ${{ matrix.build_option }}"

0 commit comments

Comments
 (0)