Skip to content

Commit 3cc6a4b

Browse files
committed
ci: split cross job
Signed-off-by: CrazyMax <[email protected]>
1 parent ad2bfcf commit 3cc6a4b

File tree

2 files changed

+74
-107
lines changed

2 files changed

+74
-107
lines changed

.github/workflows/buildkit.yml

Lines changed: 73 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,8 @@ env:
2525
SETUP_BUILDKIT_IMAGE: "moby/buildkit:latest"
2626
IMAGE_NAME: "moby/buildkit"
2727
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le,linux/riscv64"
28-
CACHE_GHA_SCOPE_BINARIES: "binaries"
29-
CACHE_GHA_SCOPE_CROSS: "cross"
3028

3129
jobs:
32-
base:
33-
runs-on: ubuntu-20.04
34-
steps:
35-
-
36-
name: Checkout
37-
uses: actions/checkout@v3
38-
-
39-
name: Expose GitHub Runtime
40-
uses: crazy-max/ghaction-github-runtime@v2
41-
-
42-
name: Set up QEMU
43-
uses: docker/setup-qemu-action@v2
44-
-
45-
name: Set up Docker Buildx
46-
uses: docker/setup-buildx-action@v2
47-
with:
48-
version: ${{ env.SETUP_BUILDX_VERSION }}
49-
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
50-
buildkitd-flags: --debug
51-
-
52-
name: Build ${{ env.CACHE_GHA_SCOPE_BINARIES }}
53-
run: |
54-
./hack/build_ci_first_pass binaries
55-
env:
56-
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }}
57-
CACHE_TO: type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }}
58-
5930
test:
6031
uses: ./.github/workflows/.test.yml
6132
with:
@@ -80,41 +51,15 @@ jobs:
8051
skip-integration-tests: 1
8152
typ: integration
8253
83-
cross:
84-
runs-on: ubuntu-20.04
85-
steps:
86-
-
87-
name: Checkout
88-
uses: actions/checkout@v3
89-
-
90-
name: Expose GitHub Runtime
91-
uses: crazy-max/ghaction-github-runtime@v2
92-
-
93-
name: Set up QEMU
94-
uses: docker/setup-qemu-action@v2
95-
-
96-
name: Set up Docker Buildx
97-
uses: docker/setup-buildx-action@v2
98-
with:
99-
version: ${{ env.SETUP_BUILDX_VERSION }}
100-
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
101-
buildkitd-flags: --debug
102-
-
103-
name: Cross
104-
run: |
105-
./hack/cross
106-
env:
107-
PLATFORMS: ${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64
108-
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}
109-
CACHE_TO: type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}
110-
111-
release-base:
54+
prepare:
11255
runs-on: ubuntu-20.04
11356
outputs:
11457
tag: ${{ steps.prep.outputs.tag }}
11558
push: ${{ steps.prep.outputs.push }}
59+
platforms: ${{ steps.prep.outputs.platforms }}
11660
steps:
117-
- name: Prepare
61+
-
62+
name: Prepare
11863
id: prep
11964
run: |
12065
TAG=pr
@@ -131,20 +76,23 @@ jobs:
13176
fi
13277
echo "tag=${TAG}" >>${GITHUB_OUTPUT}
13378
echo "push=${PUSH}" >>${GITHUB_OUTPUT}
79+
platforms=$(jq -c -n --argjson str '"${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64"' '$str|split(",")')
80+
echo "platforms=$platforms" >>${GITHUB_OUTPUT}
13481
135-
image:
82+
cross:
13683
runs-on: ubuntu-20.04
13784
needs:
138-
- release-base
139-
- test
140-
- cross
85+
- prepare
14186
strategy:
14287
fail-fast: false
14388
matrix:
144-
target-stage:
145-
- ''
146-
- rootless
89+
platform: ${{ fromJson(needs.prepare.outputs.platforms) }}
14790
steps:
91+
-
92+
name: Prepare
93+
run: |
94+
platform=${{ matrix.platform }}
95+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
14896
-
14997
name: Checkout
15098
uses: actions/checkout@v3
@@ -162,28 +110,61 @@ jobs:
162110
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
163111
buildkitd-flags: --debug
164112
-
165-
name: Login to DockerHub
166-
if: needs.release-base.outputs.push == 'push'
167-
uses: docker/login-action@v2
168-
with:
169-
username: ${{ secrets.DOCKERHUB_USERNAME }}
170-
password: ${{ secrets.DOCKERHUB_TOKEN }}
171-
-
172-
name: Build ${{ needs.release-base.outputs.tag }}
113+
name: Build
173114
run: |
174-
./hack/images "${{ needs.release-base.outputs.tag }}" "$IMAGE_NAME" "${{ needs.release-base.outputs.push }}"
115+
./hack/release-tar "${{ needs.prepare.outputs.tag }}" release-out
175116
env:
176117
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
177-
TARGET: ${{ matrix.target-stage }}
178-
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }} type=gha,scope=image${{ matrix.target-stage }}
179-
CACHE_TO: type=gha,scope=image${{ matrix.target-stage }}
118+
PLATFORMS: ${{ matrix.platform }}
119+
CACHE_FROM: type=gha,scope=cross-${{ env.PLATFORM_PAIR }}
120+
CACHE_TO: type=gha,scope=cross-${{ env.PLATFORM_PAIR }}
121+
-
122+
name: Upload artifacts
123+
uses: actions/upload-artifact@v3
124+
with:
125+
name: buildkit
126+
path: ./release-out/*
127+
if-no-files-found: error
180128

181129
binaries:
182130
runs-on: ubuntu-20.04
183131
needs:
184-
- release-base
185-
- test
132+
- prepare
186133
- cross
134+
- test
135+
steps:
136+
-
137+
name: Download artifacts
138+
uses: actions/download-artifact@v3
139+
with:
140+
name: buildkit
141+
path: ./release-out/*
142+
-
143+
name: List artifacts
144+
run: |
145+
tree -nh ./release-out/
146+
-
147+
name: GitHub Release
148+
if: startsWith(github.ref, 'refs/tags/v')
149+
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
150+
env:
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152+
with:
153+
draft: true
154+
files: ./release-out/*
155+
name: ${{ needs.prepare.outputs.tag }}
156+
157+
image:
158+
runs-on: ubuntu-20.04
159+
needs:
160+
- prepare
161+
- test
162+
strategy:
163+
fail-fast: false
164+
matrix:
165+
target-stage:
166+
- ''
167+
- rootless
187168
steps:
188169
-
189170
name: Checkout
@@ -202,27 +183,18 @@ jobs:
202183
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
203184
buildkitd-flags: --debug
204185
-
205-
name: Build ${{ needs.release-base.outputs.tag }}
206-
run: |
207-
./hack/release-tar "${{ needs.release-base.outputs.tag }}" release-out
208-
env:
209-
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
210-
PLATFORMS: ${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64
211-
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }} type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}
212-
-
213-
name: Upload artifacts
214-
uses: actions/upload-artifact@v3
186+
name: Login to DockerHub
187+
if: needs.prepare.outputs.push == 'push'
188+
uses: docker/login-action@v2
215189
with:
216-
name: buildkit
217-
path: ./release-out/*
218-
if-no-files-found: error
190+
username: ${{ secrets.DOCKERHUB_USERNAME }}
191+
password: ${{ secrets.DOCKERHUB_TOKEN }}
219192
-
220-
name: GitHub Release
221-
if: startsWith(github.ref, 'refs/tags/v')
222-
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
193+
name: Build ${{ needs.prepare.outputs.tag }}
194+
run: |
195+
./hack/images "${{ needs.prepare.outputs.tag }}" "$IMAGE_NAME" "${{ needs.prepare.outputs.push }}"
223196
env:
224-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
225-
with:
226-
draft: true
227-
files: ./release-out/*
228-
name: ${{ needs.release-base.outputs.tag }}
197+
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
198+
TARGET: ${{ matrix.target-stage }}
199+
CACHE_FROM: type=gha,scope=image${{ matrix.target-stage }}
200+
CACHE_TO: type=gha,scope=image${{ matrix.target-stage }}

hack/build_ci_first_pass

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TYP=$1
66
set -e
77

88
usage() {
9-
echo "usage: ./hack/build_ci_first_pass <binaries|integration-tests>"
9+
echo "usage: ./hack/build_ci_first_pass <integration-tests>"
1010
exit 1
1111
}
1212

@@ -15,11 +15,6 @@ if [ -z "$TYP" ]; then
1515
fi
1616

1717
case $TYP in
18-
"binaries")
19-
buildxCmd build $cacheFromFlags $cacheToFlags \
20-
--target "binaries" \
21-
$currentcontext
22-
;;
2318
"integration-tests")
2419
buildxCmd build $cacheFromFlags $cacheToFlags \
2520
--target "integration-tests-base" \

0 commit comments

Comments
 (0)