-
Notifications
You must be signed in to change notification settings - Fork 5
274 lines (265 loc) · 7.96 KB
/
ci.yml
File metadata and controls
274 lines (265 loc) · 7.96 KB
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
name: ci
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- 'master'
pull_request:
env:
GO_VERSION: 1.22
SETUP_BUILDX_VERSION: latest
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
BUILDKIT_REPO: moby/buildkit
BUILDKIT_ARTIFACT_KEY: buildkit-binaries
BUILDKIT_CACHE_REPO: moby/buildkit-bench-cache
CANDIDATES_REFS: master
CANDIDATES_LAST_DAYS: 15
CANDIDATES_LAST_RELEASES: 8
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 }}
CANDIDATES_REFS: ${{ env.CANDIDATES_REFS }}
CANDIDATES_LAST_DAYS: ${{ env.CANDIDATES_LAST_DAYS }}
CANDIDATES_LAST_RELEASES: ${{ env.CANDIDATES_LAST_RELEASES }}
steps:
- run: "true"
prepare:
runs-on: ubuntu-24.04
outputs:
includes: ${{ steps.set.outputs.includes }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
-
name: Set includes
id: set
run: |
go run -mod=vendor ./cmd/gotestmetrics \
--debug list --gha-output includes
-
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/.buildkit-binaries.yml
needs:
- get-env
secrets: inherit
with:
repo: ${{ needs.get-env.outputs.BUILDKIT_REPO }}
refs: ${{ needs.get-env.outputs.CANDIDATES_REFS }}
last_days: ${{ needs.get-env.outputs.CANDIDATES_LAST_DAYS }}
last_releases: ${{ needs.get-env.outputs.CANDIDATES_LAST_RELEASES }}
artifact_key: ${{ needs.get-env.outputs.BUILDKIT_ARTIFACT_KEY }}
test:
runs-on: ubuntu-24.04
needs:
- prepare
- buildkit-binaries
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.prepare.outputs.includes) }}
env:
TEST_FLAGS: -v --timeout=5h
TEST_IMAGE_BUILD: 0
TEST_IMAGE_ID: buildkit-bench
TEST_RESULTS_DIR: bin/results
TEST_GEN: 0
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: Build test image
uses: docker/bake-action@v5
with:
source: "{{defaultContext}}"
targets: tests
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: |
./hack/test
env:
TEST_BENCH_REGEXP: ${{ matrix.test }}$
TEST_BENCH_RUN: ${{ matrix.count }}
TEST_BENCH_TIME: ${{ matrix.benchtime }}
-
name: Result
run: |
resultName=$(echo ${{ matrix.test }} | sed 's/\//-/g')
resultPath=./${{ env.TEST_RESULTS_DIR }}/gotestoutput-$resultName.json
echo "TEST_RESULT_NAME=$resultName" >> $GITHUB_ENV
echo "TEST_RESULT_PATH=$resultPath" >> $GITHUB_ENV
mv ./${{ env.TEST_RESULTS_DIR }}/gotestoutput.json $resultPath
jq . $resultPath
-
name: Upload results
uses: actions/upload-artifact@v4
with:
name: bench-results-${{ env.TEST_RESULT_NAME }}
path: ${{ env.TEST_RESULT_PATH }}
if-no-files-found: error
retention-days: 1
report:
runs-on: ubuntu-24.04
needs:
- test
steps:
-
name: Download results
uses: actions/download-artifact@v4
with:
path: /tmp/buildkit-bench
pattern: bench-results-*
merge-multiple: true
-
name: Download candidates
uses: actions/download-artifact@v4
with:
name: candidates
path: /tmp/buildkit-bench
-
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: 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/buildkit-bench
*.output=./bin/report
env:
BAKE_ALLOW_REMOTE_FS_ACCESS: 1
-
name: Include additional files to report directory
run: |
cp /tmp/buildkit-bench/* ./testconfig.yml ./bin/report/
cat <<EOF > ./bin/report/metadata.txt
repo=${{ github.repository }}
commit=${{ github.sha }}
EOF
-
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: 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/buildkit-bench-report
-
name: Move reports
run: |
reportDir=$(date +'%Y%m%d-%H%M%S')
mkdir -p ./website/public/result/$reportDir
mv /tmp/buildkit-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:
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 }}