1313 FORCE_COLOR : 1
1414
1515jobs :
16- pythonbuild :
17- if : ${{ needs.generate-matrix.outputs.pythonbuild_changed == 'true' || needs.generate-matrix.outputs.any_builds == 'true' || github.ref == 'refs/heads/main' }}
16+ crate-build :
1817 needs :
1918 - generate-matrix
20- runs-on : depot-ubuntu-22.04
19+ runs-on : ${{ matrix.runner }}
20+ strategy :
21+ matrix : ${{ fromJson(needs.generate-matrix.outputs.crate-build-matrix) }}
22+ fail-fast : false
23+ name : crate / ${{ matrix.arch }}
2124 steps :
2225 - name : Install System Dependencies
2326 run : |
4548 - name : Upload pythonbuild Executable
4649 uses : actions/upload-artifact@v4
4750 with :
48- name : pythonbuild
51+ name : ${{ matrix.crate_artifact_name }}
4952 path : target/release/pythonbuild
5053
5154 image :
5558 strategy :
5659 fail-fast : false
5760 matrix : ${{ fromJson(needs.generate-matrix.outputs.docker-build-matrix) }}
58- name : ${{ matrix.name }}
61+ name : image / ${{ matrix.name }}
5962 runs-on : ${{ matrix.runner }}
6063 permissions :
6164 packages : write
@@ -122,8 +125,8 @@ jobs:
122125 python-build-matrix-0 : ${{ steps.set-matrix.outputs.python-build-matrix-0 }}
123126 python-build-matrix-1 : ${{ steps.set-matrix.outputs.python-build-matrix-1 }}
124127 docker-build-matrix : ${{ steps.set-matrix.outputs.docker-build-matrix }}
128+ crate-build-matrix : ${{ steps.set-matrix.outputs.crate-build-matrix }}
125129 any_builds : ${{ steps.set-matrix.outputs.any_builds }}
126- pythonbuild_changed : ${{ steps.check-pythonbuild.outputs.changed }}
127130 steps :
128131 - uses : actions/checkout@v4
129132 with :
@@ -139,18 +142,32 @@ jobs:
139142 LABELS=$(echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | jq -r 'join(",")')
140143 echo "labels=$LABELS" >> $GITHUB_OUTPUT
141144
145+ - name : Check if the `pythonbuild` crate changed
146+ id : check-pythonbuild
147+ env :
148+ BASE_REF : ${{ github.event.pull_request.base.ref || 'main' }}
149+ run : |
150+ merge_base=$(git merge-base HEAD "origin/${BASE_REF}")
151+ if git diff --quiet "${merge_base}...HEAD" -- ':src/*.rs'; then
152+ echo "changed=false" >> "$GITHUB_OUTPUT"
153+ else
154+ echo "changed=true" >> "$GITHUB_OUTPUT"
155+ fi
156+
142157 - name : Generate build matrix
143158 id : set-matrix
144159 run : |
145160 uv run ci-matrix.py \
146161 --platform linux \
147162 --labels '${{ steps.get-labels.outputs.labels }}' \
148163 --max-shards 2 \
164+ ${{ (steps.check-pythonbuild.outputs.changed == 'true' || github.ref == 'refs/heads/main') && '--force-crate-build' || '' }} \
149165 > matrix.json
150166
151167 echo "python-build-matrix-0=$(jq -c '."python-build"["0"]' matrix.json)" >> $GITHUB_OUTPUT
152168 echo "python-build-matrix-1=$(jq -c '."python-build"["1"]' matrix.json)" >> $GITHUB_OUTPUT
153169 echo "docker-build-matrix=$(jq -c '."docker-build"' matrix.json)" >> $GITHUB_OUTPUT
170+ echo "crate-build-matrix=$(jq -c '."crate-build"' matrix.json)" >> $GITHUB_OUTPUT
154171
155172 # Display the matrix for debugging too
156173 cat matrix.json | jq
@@ -163,22 +180,10 @@ jobs:
163180 echo "any_builds=false" >> $GITHUB_OUTPUT
164181 fi
165182
166- - name : Check if the `pythonbuild` crate changed
167- id : check-pythonbuild
168- env :
169- BASE_REF : ${{ github.event.pull_request.base.ref || 'main' }}
170- run : |
171- merge_base=$(git merge-base HEAD "origin/${BASE_REF}")
172- if git diff --quiet "${merge_base}...HEAD" -- ':src/*.rs'; then
173- echo "changed=false" >> "$GITHUB_OUTPUT"
174- else
175- echo "changed=true" >> "$GITHUB_OUTPUT"
176- fi
177-
178183 build-0 :
179184 needs :
180185 - generate-matrix
181- - pythonbuild
186+ - crate-build
182187 - image
183188 # Permissions used for actions/attest-build-provenance
184189 permissions :
@@ -202,7 +207,7 @@ jobs:
202207 - name : Download pythonbuild
203208 uses : actions/download-artifact@v4
204209 with :
205- name : pythonbuild
210+ name : ${{ matrix.crate_artifact_name }}
206211 path : build
207212
208213 - name : Download images
@@ -278,7 +283,7 @@ jobs:
278283 build-1 :
279284 needs :
280285 - generate-matrix
281- - pythonbuild
286+ - crate-build
282287 - image
283288 # Permissions used for actions/attest-build-provenance
284289 permissions :
@@ -302,7 +307,7 @@ jobs:
302307 - name : Download pythonbuild
303308 uses : actions/download-artifact@v4
304309 with :
305- name : pythonbuild
310+ name : ${{ matrix.crate_artifact_name }}
306311 path : build
307312
308313 - name : Download images
0 commit comments