@@ -46,15 +46,11 @@ jobs:
4646 path : target/release/pythonbuild
4747
4848 image :
49+ needs :
50+ - generate-matrix
4951 strategy :
52+ matrix : ${{ fromJson(needs.generate-matrix.outputs.image_matrix) }}
5053 fail-fast : false
51- matrix :
52- image :
53- - build
54- - build.cross
55- - gcc
56- - xcb
57- - xcb.cross
5854 runs-on : depot-ubuntu-22.04
5955 permissions :
6056 packages : write
@@ -121,7 +117,7 @@ jobs:
121117 matrix : ${{ steps.set-matrix.outputs.matrix }}
122118 steps :
123119 - uses : actions/checkout@v4
124-
120+
125121 - name : Set up Python
126122 uses : astral-sh/setup-uv@v4
127123
@@ -131,22 +127,52 @@ jobs:
131127 # Convert GitHub labels array to comma-separated string
132128 LABELS=$(echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | jq -r 'join(",")')
133129 echo "labels=$LABELS" >> $GITHUB_OUTPUT
134-
135- - name : Generate build matrix
130+
131+ - name : Generate matrix
136132 id : set-matrix
137133 run : |
138- uv run ci-matrix.py --platform linux --labels "${{ steps.get-labels.outputs.labels }}" > matrix.json && echo "matrix=$(cat matrix.json)" >> $GITHUB_OUTPUT
139- # Display the matrix for debugging too
140- cat matrix.json | jq
141-
134+ # Generate the build matrix
135+ uv run ci-matrix.py --platform linux --labels "${{ steps.get-labels.outputs.labels }}" > build_matrix.json
136+
137+ # Display the build matrix for debugging
138+ echo "Build matrix:"
139+ cat build_matrix.json | jq
140+
141+ # Check if build matrix is empty and generate image matrix accordingly
142+ if jq -e '.include | length > 0' build_matrix.json > /dev/null; then
143+ # Build matrix has entries, generate the image matrix
144+ cat > image_matrix.json << EOL
145+ {
146+ "include": [
147+ {"image": "build"},
148+ {"image": "build.cross"},
149+ {"image": "gcc"},
150+ {"image": "xcb"},
151+ {"image": "xcb.cross"}
152+ ]
153+ }
154+ EOL
155+ else
156+ # Build matrix is empty, create empty image matrix
157+ jq -n '{"include": []}' > image_matrix.json
158+ fi
159+
160+ # Set both matrices as outputs
161+ echo "build_matrix=$(cat build_matrix.json)" >> $GITHUB_OUTPUT
162+ echo "image_matrix=$(jq -c '.' image_matrix.json)" >> $GITHUB_OUTPUT
163+
164+ # Display the image matrix for debugging
165+ echo "Image matrix:"
166+ cat image_matrix.json | jq
167+
142168 build :
143169 needs :
144170 - generate-matrix
145171 - pythonbuild
146172 - image
147173 runs-on : depot-ubuntu-22.04
148174 strategy :
149- matrix : ${{ fromJson(needs.generate-matrix.outputs.matrix ) }}
175+ matrix : ${{ fromJson(needs.generate-matrix.outputs.build_matrix ) }}
150176 fail-fast : false
151177 name : ${{ matrix.target_triple }} / ${{ matrix.python }} / ${{ matrix.build_options }}
152178 steps :
0 commit comments