Skip to content

Commit 204bda6

Browse files
authored
Update GitHub Actions workflow for test builds
1 parent 59265d3 commit 204bda6

File tree

1 file changed

+58
-24
lines changed

1 file changed

+58
-24
lines changed

.github/workflows/test_build.yml

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Images (Dry Run)
1+
name: Test Build / Dry Run
22

33
on:
44
workflow_dispatch:
@@ -16,32 +16,65 @@ on:
1616
- cpu
1717
- gpu
1818
- rocm
19+
platform:
20+
description: 'Platform (ignored for rocm)'
21+
required: true
22+
type: choice
23+
options:
24+
- all
25+
- amd64
26+
- arm64
27+
dry_run:
28+
description: 'Print build plan only (no actual build)'
29+
required: false
30+
type: boolean
31+
default: true
32+
33+
concurrency:
34+
group: test-build-${{ inputs.branch_name }}
35+
cancel-in-progress: true
1936

2037
jobs:
38+
setup:
39+
runs-on: ubuntu-latest
40+
outputs:
41+
matrix: ${{ steps.set-matrix.outputs.matrix }}
42+
steps:
43+
- name: Build matrix
44+
id: set-matrix
45+
run: |
46+
ALL_TARGETS='[
47+
{"build_target":"cpu","platform":"amd64","runs_on":"ubuntu-latest"},
48+
{"build_target":"cpu","platform":"arm64","runs_on":"ubuntu-24.04-arm"},
49+
{"build_target":"gpu","platform":"amd64","runs_on":"ubuntu-latest"},
50+
{"build_target":"gpu","platform":"arm64","runs_on":"ubuntu-24.04-arm"},
51+
{"build_target":"rocm","platform":"amd64","runs_on":"ubuntu-latest"}
52+
]'
53+
54+
FILTERED=$(echo "$ALL_TARGETS" | jq -c \
55+
--arg target "${{ inputs.build_target }}" \
56+
--arg platform "${{ inputs.platform }}" \
57+
'[.[] | select(
58+
($target == "all" or .build_target == $target) and
59+
(.build_target == "rocm" or $platform == "all" or .platform == $platform)
60+
)]')
61+
62+
if [ "$FILTERED" = "[]" ]; then
63+
echo "::error::No matching build configurations"
64+
exit 1
65+
fi
66+
67+
echo "matrix={\"include\":$FILTERED}" >> "$GITHUB_OUTPUT"
68+
2169
build-images:
70+
needs: setup
2271
env:
2372
DOCKER_BUILDKIT: 1
2473
BUILDKIT_STEP_LOG_MAX_SIZE: 10485760
2574
strategy:
26-
matrix:
27-
include:
28-
- build_target: "cpu"
29-
platform: "amd64"
30-
runs_on: "ubuntu-latest"
31-
- build_target: "gpu"
32-
platform: "amd64"
33-
runs_on: "ubuntu-latest"
34-
- build_target: "cpu"
35-
platform: "arm64"
36-
runs_on: "ubuntu-24.04-arm"
37-
- build_target: "gpu"
38-
platform: "arm64"
39-
runs_on: "ubuntu-24.04-arm"
40-
- build_target: "rocm"
41-
platform: "amd64"
42-
runs_on: "ubuntu-latest"
75+
fail-fast: false
76+
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
4377
runs-on: ${{ matrix.runs_on }}
44-
if: inputs.build_target == 'all' || inputs.build_target == matrix.build_target
4578
steps:
4679
- name: Checkout repository
4780
uses: actions/checkout@v4
@@ -51,16 +84,17 @@ jobs:
5184
- name: Free disk space
5285
run: |
5386
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
54-
docker system prune -af
5587
5688
- name: Set up Docker Buildx
5789
uses: docker/setup-buildx-action@v3
5890
with:
59-
driver-opts: |
60-
image=moby/buildkit:latest
61-
network=host
91+
driver-opts: image=moby/buildkit:v0.21.1
6292

6393
- name: Build image
6494
run: |
6595
TARGET="${{ matrix.build_target }}-${{ matrix.platform }}"
66-
docker buildx bake $TARGET --progress=plain
96+
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
97+
docker buildx bake "$TARGET" --print
98+
else
99+
docker buildx bake "$TARGET" --progress=plain
100+
fi

0 commit comments

Comments
 (0)