From 90a014635218a67c1ecc4252b5aa05f44efa7431 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 18 Dec 2024 10:33:31 -0600 Subject: [PATCH] Only run the image builds if we are doing Linux Python builds --- .github/workflows/linux.yml | 55 +++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5864d93a..52a825ee 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -46,15 +46,11 @@ jobs: path: target/release/pythonbuild image: + needs: + - generate-matrix strategy: + matrix: ${{ fromJson(needs.generate-matrix.outputs.image_matrix) }} fail-fast: false - matrix: - image: - - build - - build.cross - - gcc - - xcb - - xcb.cross runs-on: depot-ubuntu-22.04 permissions: packages: write @@ -121,7 +117,7 @@ jobs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - uses: actions/checkout@v4 - + - name: Set up Python uses: astral-sh/setup-uv@v4 @@ -131,14 +127,43 @@ jobs: # Convert GitHub labels array to comma-separated string LABELS=$(echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | jq -r 'join(",")') echo "labels=$LABELS" >> $GITHUB_OUTPUT - - - name: Generate build matrix + + - name: Generate matrix id: set-matrix run: | - uv run ci-matrix.py --platform linux --labels "${{ steps.get-labels.outputs.labels }}" > matrix.json && echo "matrix=$(cat matrix.json)" >> $GITHUB_OUTPUT - # Display the matrix for debugging too - cat matrix.json | jq - + # Generate the build matrix + uv run ci-matrix.py --platform linux --labels "${{ steps.get-labels.outputs.labels }}" > build_matrix.json + + # Display the build matrix for debugging + echo "Build matrix:" + cat build_matrix.json | jq + + # Check if build matrix is empty and generate image matrix accordingly + if jq -e '.include | length > 0' build_matrix.json > /dev/null; then + # Build matrix has entries, generate the image matrix + jq -n '{ + "include": [ + {"image": "build"}, + {"image": "build.cross"}, + {"image": "gcc"}, + {"image": "xcb"}, + {"image": "xcb.cross"} + ] + }' > image_matrix.json + else + # Build matrix is empty, create empty image matrix + jq -n '{"include": []}' > image_matrix.json + fi + + # Display the image matrix for debugging + echo "Image matrix:" + cat image_matrix.json | jq + + # Set both matrices as outputs + echo "build_matrix=$(cat build_matrix.json)" >> $GITHUB_OUTPUT + echo "image_matrix=$(jq -c '.' image_matrix.json)" >> $GITHUB_OUTPUT + + build: needs: - generate-matrix @@ -146,7 +171,7 @@ jobs: - image runs-on: depot-ubuntu-22.04 strategy: - matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} + matrix: ${{ fromJson(needs.generate-matrix.outputs.build_matrix) }} fail-fast: false name: ${{ matrix.target_triple }} / ${{ matrix.python }} / ${{ matrix.build_options }} steps: