Skip to content

Commit b8eb208

Browse files
authored
Merge pull request moby#3642 from crazy-max/ci-split-cross
ci: split cross job
2 parents 37d54eb + 7c90be2 commit b8eb208

File tree

6 files changed

+85
-110
lines changed

6 files changed

+85
-110
lines changed

.github/workflows/buildkit.yml

Lines changed: 63 additions & 91 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,42 +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-
RUNC_PLATFORMS: ${{ env.PLATFORMS }}
109-
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}
110-
CACHE_TO: type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}
111-
112-
release-base:
54+
prepare:
11355
runs-on: ubuntu-20.04
11456
outputs:
11557
tag: ${{ steps.prep.outputs.tag }}
11658
push: ${{ steps.prep.outputs.push }}
59+
platforms: ${{ steps.prep.outputs.platforms }}
11760
steps:
118-
- name: Prepare
61+
-
62+
name: Prepare
11963
id: prep
12064
run: |
12165
TAG=pr
@@ -132,20 +76,23 @@ jobs:
13276
fi
13377
echo "tag=${TAG}" >>${GITHUB_OUTPUT}
13478
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}
13581
136-
image:
82+
cross:
13783
runs-on: ubuntu-20.04
13884
needs:
139-
- release-base
140-
- test
141-
- cross
85+
- prepare
14286
strategy:
14387
fail-fast: false
14488
matrix:
145-
target-stage:
146-
- ''
147-
- rootless
89+
platform: ${{ fromJson(needs.prepare.outputs.platforms) }}
14890
steps:
91+
-
92+
name: Prepare
93+
run: |
94+
platform=${{ matrix.platform }}
95+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
14996
-
15097
name: Checkout
15198
uses: actions/checkout@v3
@@ -163,28 +110,33 @@ jobs:
163110
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
164111
buildkitd-flags: --debug
165112
-
166-
name: Login to DockerHub
167-
if: needs.release-base.outputs.push == 'push'
168-
uses: docker/login-action@v2
169-
with:
170-
username: ${{ secrets.DOCKERHUB_USERNAME }}
171-
password: ${{ secrets.DOCKERHUB_TOKEN }}
172-
-
173-
name: Build ${{ needs.release-base.outputs.tag }}
113+
name: Build
174114
run: |
175-
./hack/images "${{ needs.release-base.outputs.tag }}" "$IMAGE_NAME" "${{ needs.release-base.outputs.push }}"
115+
./hack/release-tar "${{ needs.prepare.outputs.tag }}" release-out
176116
env:
177117
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
178-
TARGET: ${{ matrix.target-stage }}
179-
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }} type=gha,scope=image${{ matrix.target-stage }}
180-
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
181128

182-
binaries:
129+
image:
183130
runs-on: ubuntu-20.04
184131
needs:
185-
- release-base
132+
- prepare
186133
- test
187-
- cross
134+
strategy:
135+
fail-fast: false
136+
matrix:
137+
target-stage:
138+
- ''
139+
- rootless
188140
steps:
189141
-
190142
name: Checkout
@@ -203,27 +155,47 @@ jobs:
203155
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
204156
buildkitd-flags: --debug
205157
-
206-
name: Build ${{ needs.release-base.outputs.tag }}
158+
name: Login to DockerHub
159+
if: needs.prepare.outputs.push == 'push'
160+
uses: docker/login-action@v2
161+
with:
162+
username: ${{ secrets.DOCKERHUB_USERNAME }}
163+
password: ${{ secrets.DOCKERHUB_TOKEN }}
164+
-
165+
name: Build ${{ needs.prepare.outputs.tag }}
207166
run: |
208-
./hack/release-tar "${{ needs.release-base.outputs.tag }}" release-out
167+
./hack/images "${{ needs.prepare.outputs.tag }}" "$IMAGE_NAME" "${{ needs.prepare.outputs.push }}"
209168
env:
210169
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
211-
PLATFORMS: ${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64
212-
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }} type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}
170+
TARGET: ${{ matrix.target-stage }}
171+
CACHE_FROM: type=gha,scope=image${{ matrix.target-stage }}
172+
CACHE_TO: type=gha,scope=image${{ matrix.target-stage }}
173+
174+
release:
175+
runs-on: ubuntu-20.04
176+
needs:
177+
- prepare
178+
- test
179+
- cross
180+
- image
181+
steps:
213182
-
214-
name: Upload artifacts
215-
uses: actions/upload-artifact@v3
183+
name: Download artifacts
184+
uses: actions/download-artifact@v3
216185
with:
217186
name: buildkit
218187
path: ./release-out/*
219-
if-no-files-found: error
188+
-
189+
name: List artifacts
190+
run: |
191+
tree -nh ./release-out/
220192
-
221193
name: GitHub Release
222194
if: startsWith(github.ref, 'refs/tags/v')
223-
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
195+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
224196
env:
225197
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
226198
with:
227199
draft: true
228200
files: ./release-out/*
229-
name: ${{ needs.release-base.outputs.tag }}
201+
name: ${{ needs.prepare.outputs.tag }}

.github/workflows/dockerd.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ on:
1212
env:
1313
SETUP_BUILDX_VERSION: "latest"
1414
SETUP_BUILDKIT_IMAGE: "moby/buildkit:latest"
15-
CACHE_GHA_SCOPE_IT: "integration-tests"
16-
CACHE_GHA_SCOPE_BINARIES: "binaries"
1715
TESTFLAGS: "-v --parallel=1 --timeout=30m"
1816

1917
jobs:
@@ -129,7 +127,7 @@ jobs:
129127
TESTPKGS: "${{ matrix.pkg }}"
130128
TESTFLAGS: "${{ env.TESTFLAGS }} --run=//worker=${{ matrix.worker }}$"
131129
SKIP_INTEGRATION_TESTS: "${{ matrix.skip-integration-tests }}"
132-
CACHE_FROM: "type=gha,scope=${{ env.CACHE_GHA_SCOPE_IT }} type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }}"
130+
CACHE_FROM: "type=gha,scope=build-integration-tests"
133131
BUILDKIT_INTEGRATION_DOCKERD_FLAGS: |
134132
--bip=10.66.66.1/24
135133
--default-address-pool=base=10.66.66.0/16,size=24

.github/workflows/frontend.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
outputs:
4242
typ: ${{ steps.prep.outputs.typ }}
4343
push: ${{ steps.prep.outputs.push }}
44+
tag: ${{ steps.prep.outputs.tag }}
4445
tags: ${{ steps.prep.outputs.tags }}
4546
steps:
4647
-
@@ -59,6 +60,7 @@ jobs:
5960
fi
6061
echo "typ=${TYP}" >>${GITHUB_OUTPUT}
6162
echo "push=${PUSH}" >>${GITHUB_OUTPUT}
63+
echo "tag=${TAG}" >>${GITHUB_OUTPUT}
6264
if [ "${TYP}" = "master" ]; then
6365
echo "tags=$(jq -cn --arg tag "$TAG" '[$tag, "labs"]')" >>${GITHUB_OUTPUT}
6466
else
@@ -114,3 +116,20 @@ jobs:
114116
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
115117
CACHE_FROM: type=gha,scope=${{ env.CACHE_SCOPE }}
116118
CACHE_TO: type=gha,scope=${{ env.CACHE_SCOPE }}
119+
120+
release:
121+
runs-on: ubuntu-20.04
122+
if: startsWith(github.ref, 'refs/tags/dockerfile')
123+
needs:
124+
- prepare
125+
- test
126+
- image
127+
steps:
128+
-
129+
name: GitHub Release
130+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
with:
134+
draft: true
135+
name: ${{ needs.prepare.outputs.tag }}

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,10 @@ RUN --mount=target=. --mount=target=/root/.cache,type=cache \
107107
CGO_ENABLED=0 xx-go build -ldflags "$(cat /tmp/.ldflags) -extldflags '-static'" -tags "osusergo netgo static_build seccomp ${BUILDKITD_TAGS}" -o /usr/bin/buildkitd ./cmd/buildkitd && \
108108
xx-verify --static /usr/bin/buildkitd
109109

110-
FROM scratch AS binaries-linux-helper
110+
FROM scratch AS binaries-linux
111111
COPY --link --from=runc /usr/bin/runc /buildkit-runc
112112
# built from https://github.com/tonistiigi/binfmt/releases/tag/buildkit%2Fv7.1.0-30
113113
COPY --link --from=tonistiigi/binfmt:buildkit-v7.1.0-30@sha256:45dd57b4ba2f24e2354f71f1e4e51f073cb7a28fd848ce6f5f2a7701142a6bf0 / /
114-
115-
FROM binaries-linux-helper AS binaries-linux
116114
COPY --link --from=buildctl /usr/bin/buildctl /
117115
COPY --link --from=buildkitd /usr/bin/buildkitd /
118116

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" \

hack/cross

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,5 @@ if [ -n "$PLATFORMS" ]; then
1010
platformFlag="--platform=$PLATFORMS"
1111
fi
1212

13-
if [ -n "$RUNC_PLATFORMS" ]; then
14-
buildxCmd build $cacheFromFlags $cacheToFlags \
15-
--target "binaries-linux-helper" \
16-
--platform "$RUNC_PLATFORMS" \
17-
$currentcontext
18-
fi
19-
2013
buildxCmd build $platformFlag $cacheFromFlags \
2114
$currentcontext

0 commit comments

Comments
 (0)