-
Notifications
You must be signed in to change notification settings - Fork 55
484 lines (411 loc) · 15.5 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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
name: ci
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
env:
NEW_HSTREAM_IMAGE: new_hstream_image
jobs:
pre-build:
runs-on: ubuntu-latest
name: prepare pre-build environment for tests
outputs:
ghc: ${{ steps.parser.outputs.ghc }}
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- id: parser
run: |
pkgcabal="hstream/hstream.cabal"
GHCS=$(cat ${pkgcabal} | grep tested-with | python3 -c 'import sys, re, json; print(re.findall(r"(\d+\.\d+\.\d+)", sys.stdin.read()))')
echo "Set ghc versions: $GHCS..."
echo "ghc=$GHCS" >> $GITHUB_OUTPUT
- name: run stylish-haskell
run: |
# install stylish-haskell
PACKAGE=stylish-haskell
URL=$(\
curl --silent https://api.github.com/repos/haskell/$PACKAGE/releases/latest \
| grep "browser_download_url.*linux-x86_64\.tar\.gz" \
| cut -d ':' -f 2,3 \
| tr -d \" \
)
VERSION=$(echo $URL | sed -e 's/.*-\(v[\.0-9]\+-linux-x86_64\)\.tar\.gz/\1/')
TEMP=$(mktemp --directory)
curl --progress-bar --location -o$TEMP/$PACKAGE.tar.gz $URL
tar -xzf $TEMP/$PACKAGE.tar.gz -C$TEMP
chmod +x $TEMP/$PACKAGE-$VERSION/$PACKAGE
# check all sources
echo "Run script/format.sh with latest stylish-haskell..."
FORMATER_BIN=$TEMP/$PACKAGE-$VERSION/$PACKAGE bash script/format.sh ci && git diff-index --exit-code HEAD
build-and-test:
needs: pre-build
runs-on: ubuntu-latest
name: GHC-${{ matrix.ghc }}
strategy:
fail-fast: false
matrix:
ghc: ${{ fromJson(needs.pre-build.outputs.ghc) }}
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: set env
run: |
docker pull docker.io/hstreamdb/haskell:${{ matrix.ghc }}
echo "CABAL=python3 script/dev-tools cabal --check --no-interactive -i docker.io/hstreamdb/haskell:${{ matrix.ghc }}" >> $GITHUB_ENV
echo "SHELL=python3 script/dev-tools shell --check --no-interactive -i docker.io/hstreamdb/haskell:${{ matrix.ghc }}" >> $GITHUB_ENV
- name: start required services
run: python3 script/dev-tools start-services
- name: cabal update
run: ${{ env.CABAL }} update
- name: cabal freeze
run: ${{ env.CABAL }} freeze
- name: cache
uses: actions/cache@v3
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-v2-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project*') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-v2
# Since we use the upgraded version of z-data and z-io, this should resolve the problem.
#
# We remove these caches because there is an unknown reason that will cause ci to fail without any error message.
#- name: remove all Z related builds
# run: find ~/.cabal/store/ -maxdepth 2 -type d -name "Z*" -o -name "zoo*" | xargs rm -rf
- name: build
run: |
${{ env.CABAL }} update
${{ env.SHELL }} "'make clean'"
${{ env.SHELL }} make
${{ env.CABAL }} -- build --enable-tests --enable-benchmarks all
${{ env.CABAL }} -- install hstream
- name: start hstream server
run: |
export CONTAINER_NAME="test-hstream-server"
export IMAGE="docker.io/hstreamdb/haskell:${{ matrix.ghc }}"
export EXTRA_OPTS="--check --no-interactive --detach"
export COMMAND=" "
export EXE=$(find dist-newstyle -name "hstream-server" -type f)
./script/start-server.sh
sleep 5
docker logs --tail 100 $CONTAINER_NAME
- name: test
run: |
${{ env.CABAL }} -- test --test-show-details=direct all
# Due to an [cabal bug](https://github.com/haskell/cabal/issues/7423),
# `cabal check` will emit a warning even if the `-O2` option is just
# an flag. This is disabled until the problem is fixed.
#- name: check
# run: |
# python3 script/dev-tools cabal --check --no-interactive -i docker.io/hstreamdb/haskell:${{ matrix.ghc }} -- sdist all
# # unfortunately, there is no `cabal check all`
# #log_info "Run all cabal check..."
# # Note that we ignore hstream-store package to run cabal check, because there
# # is an unexpected warning:
# # ...
# # Warning: 'cpp-options': -std=c++17 is not portable C-preprocessor flag
# # Warning: Hackage would reject this package.
# for dir in hstream-sql hstream-processing hstream; do
# python3 script/dev-tools shell --check --no-interactive -i docker.io/hstreamdb/haskell:${{ matrix.ghc }} "'cd $dir && cabal check'"
# done
# TODO
#- name: haddock
# python3 script/dev-tools cabal --check --no-interactive -i docker.io/hstreamdb/haskell:${{ matrix.ghc }} -- haddock haddock --enable-documentation --haddock-for-hackage all
# -------------------------------------------------------------------------------
- name: stop all started services
run: docker rm -f $(docker ps -a -q)
- name: quick build new hstream image
run: |
mkdir -p ~/data
python3 script/dev-tools quick-build-dev-image \
--builder-image docker.io/hstreamdb/haskell:${{ matrix.ghc }} \
-t $NEW_HSTREAM_IMAGE
docker save -o ~/data/new_hstream_image.tar $NEW_HSTREAM_IMAGE
- uses: actions/upload-artifact@v3
with:
name: image-testing
path: ~/data/new_hstream_image.tar
retention-days: 5
integration-tests:
needs: build-and-test
runs-on: ubuntu-latest
name: integration-tests
strategy:
fail-fast: false
steps:
- name: retrieve saved docker image
uses: actions/download-artifact@v3
with:
name: image-testing
path: ~/data
- name: docker load
run: docker load -i ~/data/new_hstream_image.tar
- name: fetch integration tests source code
uses: actions/checkout@v3
with:
repository: "hstreamdb/integration-tests"
submodules: "recursive"
path: integration-tests
- uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: 11
cache: "gradle"
- uses: gradle/wrapper-validation-action@v1
- name: run integration tests
run: |
cd integration-tests
export HSTREAM_IMAGE_NAME=$NEW_HSTREAM_IMAGE
./gradlew test --info --fail-fast -Dtag='basicTest'
- name: collect tests reports
if: ${{ success() }} || ${{ failure() }}
run: |
rm -rf ci_artifact && mkdir ci_artifact
mv integration-tests/.logs ci_artifact/logs
mv integration-tests/app/build/reports ci_artifact/reports
- name: upload tests-reports
uses: actions/upload-artifact@v3
if: ${{ success() }} || ${{ failure() }}
with:
name: integration-tests-reports
path: ci_artifact
retention-days: 7
integration-tests-rqlite:
needs: build-and-test
runs-on: ubuntu-latest
name: integration-tests-rqlite
strategy:
fail-fast: false
steps:
- name: retrieve saved docker image
uses: actions/download-artifact@v3
with:
name: image-testing
path: ~/data
- name: docker load
run: docker load -i ~/data/new_hstream_image.tar
- name: fetch integration tests source code
uses: actions/checkout@v3
with:
repository: "hstreamdb/integration-tests"
submodules: "recursive"
path: integration-tests
- uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: 11
cache: "gradle"
- uses: gradle/wrapper-validation-action@v1
- name: run integration tests
run: |
cd integration-tests
export HSTREAM_IMAGE_NAME=$NEW_HSTREAM_IMAGE
export HSTREAM_META_STORE=RQLITE
./gradlew test --info --fail-fast -Dtag='basicTest'
- name: collect tests reports
if: ${{ success() }} || ${{ failure() }}
run: |
rm -rf ci_artifact && mkdir ci_artifact
mv integration-tests/.logs ci_artifact/logs
mv integration-tests/app/build/reports ci_artifact/reports
- name: upload tests-reports
uses: actions/upload-artifact@v3
if: ${{ success() }} || ${{ failure() }}
with:
name: integration-tests-rqlite-reports
path: ci_artifact
retention-days: 7
distributed-tests:
needs: build-and-test
runs-on: ubuntu-latest
name: distributed-tests
strategy:
fail-fast: false
steps:
- name: retrieve saved docker image
uses: actions/download-artifact@v3
with:
name: image-testing
path: ~/data
- name: docker load
run: docker load -i ~/data/new_hstream_image.tar
- name: fetch distributed tests source code
uses: actions/checkout@v3
with:
repository: "hstreamdb/distributed-tests"
submodules: "recursive"
path: distributed-tests
- uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: 11
cache: "gradle"
# https://github.com/gradle/wrapper-validation-action/issues/66
- uses: gradle/wrapper-validation-action@v1
- name: run distributed tests
run: |
cd distributed-tests
export HSTREAM_IMAGE_NAME=$NEW_HSTREAM_IMAGE
./gradlew test --info --fail-fast
- name: collect tests reports
if: ${{ success() }} || ${{ failure() }}
run: |
rm -rf ci_artifact && mkdir ci_artifact
mv distributed-tests/.logs ci_artifact/logs
mv distributed-tests/app/build/reports ci_artifact/reports
- name: upload tests-reports
uses: actions/upload-artifact@v3
if: ${{ success() }} || ${{ failure() }}
with:
name: distributed-tests-reports
path: ci_artifact
retention-days: 7
hstream-io-tests:
needs: build-and-test
runs-on: ubuntu-latest
name: hstream-io-tests
strategy:
fail-fast: false
steps:
- name: retrieve saved docker image
uses: actions/download-artifact@v3
with:
name: image-testing
path: ~/data
- name: docker load
run: docker load -i ~/data/new_hstream_image.tar
- name: fetch hstream io tests source code
uses: actions/checkout@v3
with:
repository: "hstreamdb/hstream-connectors"
submodules: "recursive"
path: hstream-connectors
- uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: 11
cache: "gradle"
- uses: gradle/wrapper-validation-action@v1
- name: publish local java-toolkit
working-directory: ./hstream-connectors/java-toolkit
run: ./gradlew publishToMavenLocal -PdisableSigning --info
- name: build images
run: |
cd hstream-connectors/source-debezium
./gradlew buildImages
cd ../sink-jdbc
./gradlew buildImages
cd ../sink-mongodb
./gradlew buildImages
- name: run hstream io tests
run: |
cd hstream-connectors/integration_tests
export HSTREAM_IMAGE_NAME=$NEW_HSTREAM_IMAGE
./gradlew test --info --fail-fast
- name: collect tests reports
if: ${{ success() }} || ${{ failure() }}
run: |
rm -rf ci_artifact && mkdir ci_artifact
mv hstream-connectors/integration_tests/.logs ci_artifact/logs
mv hstream-connectors/integration_tests/app/build/reports ci_artifact/reports
export U=$(id -u); export G=$(id -g); sudo chown -R $U:$G /tmp/io
mv /tmp/io/tasks ci_artifact/tasks
- name: upload tests-reports
uses: actions/upload-artifact@v3
if: ${{ success() }} || ${{ failure() }}
with:
name: hstream-io-logs
path: ci_artifact
retention-days: 7
deploy-k8s:
# disabled due to a lack of hardware resources of the github action
if: false
needs: build-and-test
runs-on: ubuntu-latest
name: deploy to minikube
strategy:
fail-fast: true
steps:
- name: Start minikube
uses: medyagh/setup-minikube@master
- name: Try the cluster !
run: kubectl get pods -A
- name: Retrieve saved docker image
uses: actions/download-artifact@v3
with:
name: image-testing
path: ~/data
- name: Load image
run: |
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
docker load -i ~/data/new_hstream_image.tar
docker tag $NEW_HSTREAM_IMAGE hstreamdb/hstream
echo -n "verifying images:"
docker images
- uses: actions/checkout@v3
- name: Deploy to minikube by helm
run: |
cd deploy/chart/hstream
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm dependency build .
helm install my-hstream .
- name: Waiting for cluster ready
run: |
timeout=600 # seconds
until ( \
kubectl exec -it my-hstream-0 -- hadmin server status |grep "100.*Running" && \
kubectl exec -it my-hstream-0 -- hadmin server status |grep "101.*Running" && \
kubectl exec -it my-hstream-0 -- hadmin server status |grep "102.*Running"
) >/dev/null 2>&1;
do
>&2 echo "Waiting for cluster ready ..."
kubectl get pods
sleep 10
timeout=$((timeout - 10))
if [ $timeout -le 0 ]; then
echo "Timeout!" && \
kubectl logs --tail 100 my-hstream-0 ; \
kubectl logs --tail 100 my-hstream-1 ; \
kubectl logs --tail 100 my-hstream-2 ; \
kubectl exec -it my-hstream-0 -- hadmin server status ; \
exit 1;
fi
done
sleep 2
kubectl exec -it my-hstream-0 -- hadmin store --host my-hstream-logdevice-admin-server status
kubectl exec -it my-hstream-0 -- hadmin server status
- name: Fetch bench source code
uses: actions/checkout@v3
with:
repository: "hstreamdb/bench"
submodules: "recursive"
path: a_bench
- name: Run simple appends
run: |
eval $(minikube -p minikube docker-env)
cd a_bench
echo -e "FROM openjdk:11\nCOPY . /srv\nWORKDIR /srv" | docker build -t tmp_bench -f - .
ADDR=$(kubectl get pods my-hstream-0 --template '{{.status.podIP}}')
docker run -t --rm tmp_bench \
./gradlew writeBench --args="\
--bench-time=30 \
--warmup=1 \
--service-url=$ADDR:6570 \
--thread-count=1 \
--stream-count=2 \
--shard-count=1 \
--stream-backlog-duration=60 \
--stream-replication-factor=1 \
--record-size=1024 \
--batch-bytes-limit=2048 \
--batch-age-limit=500 \
--rate-limit=100 \
--total-bytes-limit=8192"