forked from mysql/mysql-docker
-
Notifications
You must be signed in to change notification settings - Fork 7
331 lines (290 loc) · 12.8 KB
/
build_test_push.yaml
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
name: Build, test & push executor
on:
workflow_call:
# WARNING: Duplicate everything here into workflow_dispatch
inputs:
rondb_version:
required: true
type: string
rondb_x86_tarball_name:
required: true
type: string
rondb_arm64_tarball_name:
required: true
type: string
is_latest_rondb_release:
required: true
description: "Is latest stable RonDB release; affects the image tag"
type: boolean
default: false
skip_test:
required: true
description: "Skip running a docker-compose cluster with benchmarking"
type: boolean
default: false
base_download_url:
type: string
required: true
description: "Base URL for downloading RonDB tarballs; affects the image name"
default: https://repo.hops.works/master
# Inputs here have to be duplicated from workflow_call...
# https://github.com/orgs/community/discussions/39357
workflow_dispatch:
inputs:
rondb_version:
required: true
type: string
rondb_x86_tarball_name:
required: true
type: string
rondb_arm64_tarball_name:
required: true
type: string
is_latest_rondb_release:
required: true
description: "Is latest stable RonDB release; affects the image tag"
type: boolean
default: false
skip_test:
required: true
description: "Skip running a docker-compose cluster with benchmarking"
type: boolean
default: false
base_download_url:
type: choice
required: true
description: "Base URL for downloading RonDB tarballs; affects the image name"
default: https://repo.hops.works/master
options:
- https://repo.hops.works/master
- https://repo.hops.works/master/rondb-dev
jobs:
payload-validation:
runs-on: ubuntu-latest
steps:
- name: Tarball name is not a path
run: |
if [[ "${{ inputs.rondb_x86_tarball_name }}" == */* || "${{ inputs.rondb_arm64_tarball_name }}" == */* ]]; then
echo "The tarball names contain '/'s, which are not allowed."
exit 1
fi
- name: Check base_download_url is /master if is_latest_rondb_release is selected
run: |
if [ "${{ inputs.is_latest_rondb_release }}" = "true" ] && [ "${{ inputs.base_download_url }}" != "https://repo.hops.works/master" ]; then
echo "is_latest_rondb_release can only be true if base_download_url is set to https://repo.hops.works/master"
exit 1
fi
process-info:
runs-on: ubuntu-latest
needs: [payload-validation]
outputs:
is_highest_release: ${{ steps.is_highest_release.outputs.is_highest }}
arm_image_name: ${{ steps.image_names.outputs.arm }}
x86_image_name: ${{ steps.image_names.outputs.x86 }}
multi_image_name: ${{ steps.image_names.outputs.multi }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if current branch is the highest release branch
if: github.repository == 'logicalclocks/rondb-docker'
id: is_highest_release
run: |
ALL_RELEASES=$(git branch -r | grep 'origin/release-' | sed 's|origin/||')
HIGHEST_RELEASE=$(echo "$ALL_RELEASES" | sort -V | tail -n 1 | xargs)
echo "Highest release branch is '$HIGHEST_RELEASE'"
echo "GITHUB_REF_NAME is '${GITHUB_REF_NAME}'"
if [ "${GITHUB_REF_NAME}" = "$HIGHEST_RELEASE" ]; then
echo "Current branch is the highest release branch."
echo "is_highest=true" >> $GITHUB_OUTPUT
else
echo "Current branch is not the highest release branch."
echo "is_highest=false" >> $GITHUB_OUTPUT
fi
# When using tarballs from rondb-dev, we'll use the image name "rondb-dev"
- name: Get image names
id: image_names
run: |
if [ "${{ inputs.base_download_url }}" == "https://repo.hops.works/master" ]; then
echo "arm=rondb-arm64" >> $GITHUB_OUTPUT
echo "x86=rondb-amd64" >> $GITHUB_OUTPUT
echo "multi=rondb" >> $GITHUB_OUTPUT
else
echo "arm=rondb-dev-arm64" >> $GITHUB_OUTPUT
echo "x86=rondb-dev-amd64" >> $GITHUB_OUTPUT
echo "multi=rondb-dev" >> $GITHUB_OUTPUT
fi
build-test-push-x86:
runs-on: ubuntu-latest
needs: [process-info]
if: ${{ !inputs.skip_test || (github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main'))}}
steps:
- uses: actions/checkout@v4
- name: Login to Dockerhub
uses: docker/login-action@v3
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
with:
username: hopsworks
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and run Docker Compose cluster with benchmarking
if: ${{ !inputs.skip_test }}
run: |
X86_IMAGE_NAME="${{ needs.process-info.outputs.x86_image_name }}"
./run.sh -lv \
--rondb-version ${{ inputs.rondb_version }} \
--rondb-image-name $X86_IMAGE_NAME \
--rondb-tarball-url ${{ inputs.base_download_url }}/${{ inputs.rondb_x86_tarball_name }} \
--size mini \
--run-benchmark sysbench_single \
--detached
- name: Wait for one container exit or timeout
if: ${{ !inputs.skip_test }}
run: |
start=`date +%s`
while true; do
end=`date +%s`
runtime=$((end-start))
if [ $( docker container ls --filter "status=exited" | grep rondb | wc -l ) -gt 0 ]; then
echo "One container is down. We can continue"
docker container ls --filter "status=exited"
exit 0
elif [ $runtime -gt 800 ]; then
echo "The benchmarking seems to be stuck. We're aborting now."
docker ps
exit 1
fi
sleep 2
done
- run: docker container ls
if: ${{ !inputs.skip_test }}
- run: docker logs mgmd_1
if: ${{ !inputs.skip_test }}
- run: docker logs ndbd_1
if: ${{ !inputs.skip_test }}
- run: docker logs mysqld_1
if: ${{ !inputs.skip_test }}
- run: docker logs rest_1
if: ${{ !inputs.skip_test }}
- run: docker logs bench_1
if: ${{ !inputs.skip_test }}
# At this point we only know that one container has exited. We want to
# check whether the bench container has exited with exit code 0. We need
# both status and exit code to do so, since Docker reports exit code 0
# for running containers.
- name: Check Benchmarking Exit Code
if: ${{ !inputs.skip_test }}
run: |
if [ "$(docker inspect bench_1 --format='{{.State.Status}}')" != "exited" ]
then
echo "Some container other than bench_1 exited unexpectedly."
docker ps -a
exit 1
elif [ "$(docker inspect bench_1 --format='{{.State.ExitCode}}')" != "0" ]
then
echo "Benchmarking failed."
cat autogenerated_files/*/volumes/sysbench_single/sysbench_results/oltp_rw_0_0.res
exit 1
fi
- name: Printing Sysbench results
if: ${{ !inputs.skip_test }}
run: cat autogenerated_files/*/volumes/sysbench_single/final_result.txt
- name: Get X86 image ID
run: |
VERSION="$(sed -e 's/^[[:space:]]*//' -e '/-SNAPSHOT$/s/.*/dev/' ./VERSION)"
X86_IMAGE_NAME="${{ needs.process-info.outputs.x86_image_name }}"
TAG=${{ inputs.rondb_version }}-$VERSION
echo "X86_IMAGE_NAME=$X86_IMAGE_NAME" >> $GITHUB_ENV
echo "X86_IMAGE_ID=$X86_IMAGE_NAME:$TAG" >> $GITHUB_ENV
- name: Build X86 image
if: ${{ inputs.skip_test && github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')}}
run: |
docker buildx build . \
--tag $X86_IMAGE_ID \
--build-arg RONDB_VERSION=${{ inputs.rondb_version }} \
--build-arg RONDB_TARBALL_LOCAL_REMOTE=remote \
--build-arg RONDB_X86_TARBALL_URI=${{ inputs.base_download_url }}/${{ inputs.rondb_x86_tarball_name }}
- name: Push versioned image
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
run: |
NEW_IMAGE_ID=hopsworks/$X86_IMAGE_ID
docker tag $X86_IMAGE_ID $NEW_IMAGE_ID
docker push $NEW_IMAGE_ID
- name: Push with tag `latest`
if: ${{ needs.process-info.outputs.is_highest_release == 'true' && inputs.is_latest_rondb_release }}
run: |
NEW_IMAGE_ID=hopsworks/$X86_IMAGE_NAME:latest
docker tag $X86_IMAGE_ID $NEW_IMAGE_ID
docker push $NEW_IMAGE_ID
build-push-arm64:
runs-on: ubuntu-latest
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
needs: [process-info]
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: hopsworks
password: ${{ secrets.DOCKERHUB_TOKEN }}
# We're skipping the benchmarking on ARM64 as we assume this will be run on a regular basis
# during development. ARM64 images are only for development anyways. It is more important to add
# all types of benchmarking to the tests.
- name: Build and push ARM64 image
run: |
VERSION="$(sed -e 's/^[[:space:]]*//' -e '/-SNAPSHOT$/s/.*/dev/' ./VERSION)"
ARM_IMAGE_NAME="${{ needs.process-info.outputs.arm_image_name }}"
TAGS="--tag hopsworks/$ARM_IMAGE_NAME:${{ inputs.rondb_version }}-$VERSION"
if [[ "${{ needs.process-info.outputs.is_highest_release }}" == "true" &&
"${{ inputs.is_latest_rondb_release }}" == "true" ]]; then
TAGS+=" --tag hopsworks/$ARM_IMAGE_NAME:latest"
fi
docker buildx build . \
$TAGS \
--platform=linux/arm64 \
--output type=registry \
--build-arg RONDB_VERSION=${{ inputs.rondb_version }} \
--build-arg RONDB_TARBALL_LOCAL_REMOTE=remote \
--build-arg RONDB_ARM_TARBALL_URI=${{ inputs.base_download_url }}/${{ inputs.rondb_arm64_tarball_name }} \
--cache-to type=registry,ref=hopsworks/rondb-cache,mode=max \
--cache-from type=registry,ref=hopsworks/rondb-cache,mode=max
make-multi-platform-image:
runs-on: ubuntu-latest
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
needs: [process-info, build-test-push-x86, build-push-arm64]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: hopsworks
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Nexus
uses: docker/login-action@v3
with:
registry: docker.hops.works
username: ${{ secrets.NEXUS_USER }}
password: ${{ secrets.NEXUS_PASSWORD }}
- name: Create and push multi-platform image
run: |
VERSION="$(sed -e 's/^[[:space:]]*//' -e '/-SNAPSHOT$/s/.*/dev/' ./VERSION)"
X86_IMAGE_NAME="${{ needs.process-info.outputs.x86_image_name }}"
ARM_IMAGE_NAME="${{ needs.process-info.outputs.arm_image_name }}"
MULTI_IMAGE_NAME="${{ needs.process-info.outputs.multi_image_name }}"
for repo_url in docker.io docker.hops.works; do
echo "Creating and pushing multi-platform image for $repo_url"
docker buildx imagetools create -t $repo_url/hopsworks/$MULTI_IMAGE_NAME:${{ inputs.rondb_version }}-$VERSION \
hopsworks/$X86_IMAGE_NAME:${{ inputs.rondb_version }}-$VERSION \
hopsworks/$ARM_IMAGE_NAME:${{ inputs.rondb_version }}-$VERSION
if [[ "${{ needs.process-info.outputs.is_highest_release }}" == "true" &&
"${{ inputs.is_latest_rondb_release }}" == "true" ]]; then
docker buildx imagetools create -t $repo_url/hopsworks/$MULTI_IMAGE_NAME:latest \
hopsworks/$X86_IMAGE_NAME:latest \
hopsworks/$ARM_IMAGE_NAME:latest
fi
done