-
Notifications
You must be signed in to change notification settings - Fork 3
334 lines (322 loc) · 10.1 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
name: ci
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
schedule:
- cron: '0 3 * * 0' # every Sunday at 3:00 UTC
workflow_dispatch:
push:
branches:
- 'master'
pull_request:
env:
GO_VERSION: 1.23
SETUP_BUILDX_VERSION: latest
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
BUILDKIT_CACHE_REPO: moby/buildkit-bench-cache
##
BUILDKIT_REPO: moby/buildkit
BUILDKIT_CANDIDATES_KEY: buildkit-candidates
BUILDKIT_ARTIFACT_KEY: buildkit-binaries
BUILDKIT_CACHE_PREFIX: bkbins
BUILDKIT_CANDIDATES_REFS: master
BUILDKIT_CANDIDATES_LAST_DAYS: 15
BUILDKIT_CANDIDATES_LAST_RELEASES: 8
##
BUILDX_REPO: docker/buildx
BUILDX_CANDIDATES_KEY: buildx-candidates
BUILDX_ARTIFACT_KEY: buildx-binaries
BUILDX_CACHE_PREFIX: bxbins
BUILDX_CANDIDATES_REFS: master
BUILDX_CANDIDATES_LAST_DAYS: 15
BUILDX_CANDIDATES_LAST_RELEASES: 8
##
GEN_VALIDATION_MODE: strict
WEBSITE_PUBLIC_PATH: /buildkit-bench/
jobs:
# limitation to using envs in a reusable workflow input
# https://github.com/actions/runner/issues/2372
get-env:
runs-on: ubuntu-24.04
outputs:
BUILDKIT_REPO: ${{ env.BUILDKIT_REPO }}
BUILDKIT_ARTIFACT_KEY: ${{ env.BUILDKIT_ARTIFACT_KEY }}
BUILDKIT_CACHE_PREFIX: ${{ env.BUILDKIT_CACHE_PREFIX }}
BUILDKIT_CANDIDATES_KEY: ${{ env.BUILDKIT_CANDIDATES_KEY }}
BUILDKIT_CANDIDATES_REFS: ${{ env.BUILDKIT_CANDIDATES_REFS }}
BUILDKIT_CANDIDATES_LAST_DAYS: ${{ env.BUILDKIT_CANDIDATES_LAST_DAYS }}
BUILDKIT_CANDIDATES_LAST_RELEASES: ${{ env.BUILDKIT_CANDIDATES_LAST_RELEASES }}
##
BUILDX_REPO: ${{ env.BUILDX_REPO }}
BUILDX_ARTIFACT_KEY: ${{ env.BUILDX_ARTIFACT_KEY }}
BUILDX_CACHE_PREFIX: ${{ env.BUILDX_CACHE_PREFIX }}
BUILDX_CANDIDATES_KEY: ${{ env.BUILDX_CANDIDATES_KEY }}
BUILDX_CANDIDATES_REFS: ${{ env.BUILDX_CANDIDATES_REFS }}
BUILDX_CANDIDATES_LAST_DAYS: ${{ env.BUILDX_CANDIDATES_LAST_DAYS }}
BUILDX_CANDIDATES_LAST_RELEASES: ${{ env.BUILDX_CANDIDATES_LAST_RELEASES }}
steps:
- run: "true"
prepare:
runs-on: ubuntu-24.04
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build tests base
uses: docker/bake-action@v5
with:
source: "{{defaultContext}}"
targets: tests-base
provenance: false
set: |
*.cache-from=type=registry,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
*.cache-to=type=registry,ignore-error=true,mode=max,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
buildkit-binaries:
uses: ./.github/workflows/.binaries.yml
needs:
- get-env
secrets: inherit
with:
target: buildkit
repo: ${{ needs.get-env.outputs.BUILDKIT_REPO }}
artifact_key: ${{ needs.get-env.outputs.BUILDKIT_ARTIFACT_KEY }}
cache_prefix: ${{ needs.get-env.outputs.BUILDKIT_CACHE_PREFIX }}
candidates_key: ${{ needs.get-env.outputs.BUILDKIT_CANDIDATES_KEY }}
refs: ${{ needs.get-env.outputs.BUILDKIT_CANDIDATES_REFS }}
last_days: ${{ needs.get-env.outputs.BUILDKIT_CANDIDATES_LAST_DAYS }}
last_releases: ${{ needs.get-env.outputs.BUILDKIT_CANDIDATES_LAST_RELEASES }}
buildx-binaries:
uses: ./.github/workflows/.binaries.yml
needs:
- get-env
secrets: inherit
with:
target: buildx
repo: ${{ needs.get-env.outputs.BUILDX_REPO }}
artifact_key: ${{ needs.get-env.outputs.BUILDX_ARTIFACT_KEY }}
cache_prefix: ${{ needs.get-env.outputs.BUILDX_CACHE_PREFIX }}
candidates_key: ${{ needs.get-env.outputs.BUILDX_CANDIDATES_KEY }}
refs: ${{ needs.get-env.outputs.BUILDX_CANDIDATES_REFS }}
last_days: ${{ needs.get-env.outputs.BUILDX_CANDIDATES_LAST_DAYS }}
last_releases: ${{ needs.get-env.outputs.BUILDX_CANDIDATES_LAST_RELEASES }}
test:
runs-on: ubuntu-24.04
needs:
- prepare
- buildkit-binaries
env:
TEST_FLAGS: -v
TEST_IMAGE_BUILD: 0
TEST_IMAGE_ID: buildkit-bench
TEST_RESULTS_DIR: bin/results
steps:
-
name: Download binaries
uses: actions/download-artifact@v4
with:
path: /tmp/buildkit-binaries
pattern: ${{ env.BUILDKIT_ARTIFACT_KEY }}-*
merge-multiple: true
-
name: Extract binaries
run: |
mkdir -p ./bin/buildkit-binaries
for f in "/tmp/buildkit-binaries"/*.tar.gz; do
(set -x ; tar -xzvf "$f" -C ./bin/buildkit-binaries && rm "$f")
done
tree -nph ./bin/buildkit-binaries
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver: docker
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Build test image
uses: docker/bake-action@v5
with:
source: "{{defaultContext}}"
targets: tests-buildkit
provenance: false
set: |
*.cache-from=type=registry,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
*.contexts.buildkit-binaries=cwd://bin/buildkit-binaries
*.output=type=docker,name=${{ env.TEST_IMAGE_ID }}
-
name: Checkout
uses: actions/checkout@v4
-
name: Test
run: |
make test
env:
TEST_TYPES: test
-
name: Result
run: |
resultPath=./${{ env.TEST_RESULTS_DIR }}/gotestoutput-tests.json
mv ./${{ env.TEST_RESULTS_DIR }}/gotestoutput.json $resultPath
jq . $resultPath
-
name: Upload results
uses: actions/upload-artifact@v4
with:
name: tests-results
path: ${{ env.TEST_RESULTS_DIR }}
if-no-files-found: error
retention-days: 7
benchmark-buildkit:
uses: ./.github/workflows/.benchmark.yml
needs:
- get-env
- prepare
- buildkit-binaries
secrets: inherit
with:
target: buildkit
artifact_key: ${{ needs.get-env.outputs.BUILDKIT_ARTIFACT_KEY }}
benchmark-buildx:
uses: ./.github/workflows/.benchmark.yml
needs:
- get-env
- prepare
- buildx-binaries
secrets: inherit
with:
target: buildx
artifact_key: ${{ needs.get-env.outputs.BUILDX_ARTIFACT_KEY }}
report:
runs-on: ubuntu-24.04
needs:
- test
- benchmark-buildkit
- benchmark-buildx
steps:
-
name: Download results
uses: actions/download-artifact@v4
with:
path: /tmp/bench-results
pattern: bench-results-*
merge-multiple: true
-
name: Download candidates
uses: actions/download-artifact@v4
with:
path: /tmp/bench-results
pattern: "*-candidates"
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Checkout
uses: actions/checkout@v4
-
name: Create metadata files
run: |
cp ./testconfig.yml /tmp/bench-results/
echo "$(date +'%Y%m%d-%H%M%S')" > /tmp/bench-results/name.txt
env|sort > /tmp/bench-results/env.txt
if [ -f "$GITHUB_EVENT_PATH" ]; then
cp $GITHUB_EVENT_PATH /tmp/bench-results/gha-event.json
fi
-
name: Generate HTML report
uses: docker/bake-action@v5
with:
source: "{{defaultContext}}"
targets: tests-gen
provenance: false
set: |
*.cache-from=type=registry,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
*.contexts.tests-results=cwd:///tmp/bench-results
*.output=./bin/report
env:
BAKE_ALLOW_REMOTE_FS_ACCESS: 1
-
name: Include results to report
run: |
cp -r /tmp/bench-results/* ./bin/report/
-
name: Upload report
uses: actions/upload-artifact@v4
with:
name: report
path: ./bin/report
if-no-files-found: error
publish:
runs-on: ubuntu-24.04
needs:
- report
steps:
-
name: Free disk space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
-
name: Checkout
uses: actions/checkout@v4
-
name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: bin/gh-pages
-
name: Download report
uses: actions/download-artifact@v4
with:
name: report
path: /tmp/bench-report
-
name: Move reports
run: |
reportDir=$(cat /tmp/bench-report/name.txt)
mkdir -p ./website/public/result/$reportDir
mv /tmp/bench-report/* ./website/public/result/$reportDir/
if [ -d ./bin/gh-pages/result ]; then
mv ./bin/gh-pages/result/* ./website/public/result/
fi
-
name: Build website
uses: docker/bake-action@v5
with:
no-cache: true
targets: website
provenance: false
-
name: Publish
uses: crazy-max/ghaction-github-pages@v4
with:
target_branch: gh-pages
build_dir: ./bin/website
jekyll: false
dry_run: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}