Skip to content

Commit cc62dc8

Browse files
committed
Only run the image builds if we are doing Linux Python builds
1 parent 6b4d414 commit cc62dc8

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

.github/workflows/linux.yml

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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,51 @@ 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+
jq -n '{
145+
"include": [
146+
{"image": "build"},
147+
{"image": "build.cross"},
148+
{"image": "gcc"},
149+
{"image": "xcb"},
150+
{"image": "xcb.cross"}
151+
]
152+
}' > image_matrix.json
153+
else
154+
# Build matrix is empty, create empty image matrix
155+
jq -n '{"include": []}' > image_matrix.json
156+
fi
157+
158+
# Display the image matrix for debugging
159+
echo "Image matrix:"
160+
cat image_matrix.json | jq
161+
162+
# Set both matrices as outputs
163+
echo "build_matrix=$(cat build_matrix.json)" >> $GITHUB_OUTPUT
164+
echo "image_matrix=$(jq -r tojson image_matrix.json)" >> $GITHUB_OUTPUT
165+
166+
142167
build:
143168
needs:
144169
- generate-matrix
145170
- pythonbuild
146171
- image
147172
runs-on: depot-ubuntu-22.04
148173
strategy:
149-
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
174+
matrix: ${{ fromJson(needs.generate-matrix.outputs.build_matrix) }}
150175
fail-fast: false
151176
name: ${{ matrix.target_triple }} / ${{ matrix.python }} / ${{ matrix.build_options }}
152177
steps:

0 commit comments

Comments
 (0)