-
Notifications
You must be signed in to change notification settings - Fork 55
625 lines (543 loc) · 21.2 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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
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
# NOTE: hstream-admin-store requires ghc8.10 to build.
# Also there is a WIP ghc9 support for hsthrift:
# https://github.com/facebookincubator/hsthrift/pull/107
build-hstream-admin-store:
needs: pre-build
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: set env
run: |
docker pull docker.io/hstreamdb/haskell:8.10
echo "CABAL=python3 script/dev-tools cabal --no-interactive --no-services-required \
--check -i docker.io/hstreamdb/haskell:8.10 -- \
--project-file=cabal.project.hadmin.store" >> $GITHUB_ENV
echo "SHELL=python3 script/dev-tools shell --no-interactive --no-services-required \
--check -i docker.io/hstreamdb/haskell:8.10" >> $GITHUB_ENV
- name: cabal freeze
run: |
${{ env.CABAL }} update
${{ env.CABAL }} freeze
- name: cache
uses: actions/cache@v3
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: ${{ runner.os }}-8.10-v1-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project*') }}
restore-keys: |
${{ runner.os }}-8.10-v1
- name: install
run: |
${{ env.CABAL }} update
${{ env.SHELL }} "'make clean'"
${{ env.SHELL }} "'make thrift'"
${{ env.CABAL }} install hadmin-store
- name: run hadmin-store
run: ${{ env.CABAL }} exec hadmin-store --help
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:
- name: Free disk space
run: |
echo "Before..."
df -h
sudo rm -rf \
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
"/usr/local/share/boost" \
/usr/lib/jvm || true
echo "After..."
df -h
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: CPU info
run: |
sudo apt-get install cpuid
cpuid
- name: set env
run: |
docker pull docker.io/hstreamdb/haskell:${{ matrix.ghc }}
GHC_MAJOR_VER="$(echo ${{ matrix.ghc }} | cut -d'.' -f1)"
echo "GHC_MAJOR_VER=$GHC_MAJOR_VER" >> $GITHUB_ENV
if [ "$GHC_MAJOR_VER" = "8" ]; then
echo "EXTRA_CABAL_ARGS='--project-file=cabal.project.ghc810'" >> $GITHUB_ENV
else
echo "EXTRA_CABAL_ARGS=''" >> $GITHUB_ENV
fi
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
echo "TEST_CONTAINER_NAME=test-hstream-server" >> $GITHUB_ENV
- name: start required services
run: python3 script/dev-tools start-services
- name: cabal freeze
run: |
${{ env.CABAL }} update
${{ env.CABAL }} ${{ env.EXTRA_CABAL_ARGS }} freeze
- name: cache
uses: actions/cache@v3
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-v1-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project*') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-v1-
# 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 }} ${{ env.EXTRA_CABAL_ARGS }} build --enable-tests --enable-benchmarks all
${{ env.CABAL }} ${{ env.EXTRA_CABAL_ARGS }} install hstream
- name: start hstream server
run: |
export CONTAINER_NAME=$TEST_CONTAINER_NAME
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 $TEST_CONTAINER_NAME
- name: test
run: |
${{ env.SHELL }} "'make syntax-test-run'"
${{ env.SHELL }} "'make plan-test-run'"
${{ env.CABAL }} ${{ env.EXTRA_CABAL_ARGS }} test --test-show-details=direct all
- name: collect hserver logs
if: ${{ success() }} || ${{ failure() }}
run: |
rm -rf hserver.log
docker logs $TEST_CONTAINER_NAME &> hserver.log
- name: upload hserver logs
uses: actions/upload-artifact@v3
if: ${{ success() }} || ${{ failure() }}
with:
name: hserver-logs-${{ matrix.ghc }}
path: hserver.log
retention-days: 7
# 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)
# NOTE: The quick-build-dev-image relies on the "hstreamdb/hstream" base image.
# If you have installed any additional libraries in the builder image (hstreamdb/haskell),
# and these libraries are required (e.g., if a lib.so file is needed), you may encounter a
# linking error during the integration tests that follow. In such cases, you will need to
# publish a new version of the hstreamdb/hstream image first, which includes the necessary
# libraries.
- name: quick build new hstream image
run: |
mkdir -p ~/data
if [ "${{ env.GHC_MAJOR_VER }}" = "8" ]; then
python3 script/dev-tools quick-build-dev-image \
--builder-image docker.io/hstreamdb/haskell:${{ matrix.ghc }} \
--project-file cabal.project.ghc810 \
--only-hstream \
-t $NEW_HSTREAM_IMAGE
else
python3 script/dev-tools quick-build-dev-image \
--builder-image docker.io/hstreamdb/haskell:${{ matrix.ghc }} \
--only-hstream \
-t $NEW_HSTREAM_IMAGE
fi
docker save -o ~/data/new_hstream_image.tar $NEW_HSTREAM_IMAGE
- uses: actions/upload-artifact@v3
with:
name: image-testing-${{ matrix.ghc }}
path: ~/data/new_hstream_image.tar
retention-days: 2
integration-tests:
needs: [pre-build, build-and-test]
runs-on: ubuntu-latest
name: integration-tests-ghc-${{ matrix.ghc }}
strategy:
fail-fast: false
matrix:
ghc: ${{ fromJson(needs.pre-build.outputs.ghc) }}
steps:
- name: Free disk space
run: |
echo "Before..."
df -h
sudo rm -rf \
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
"/usr/local/share/boost" \
/usr/lib/jvm || true
echo "After..."
df -h
- name: retrieve saved docker image
uses: actions/download-artifact@v3
with:
name: image-testing-${{ matrix.ghc }}
path: ~/data
- name: docker load
run: |
docker load -i ~/data/new_hstream_image.tar
docker run -t --rm $NEW_HSTREAM_IMAGE /usr/local/bin/hstream-server +RTS --info
- name: fetch integration tests source code
uses: actions/checkout@v3
with:
repository: "hstreamdb/integration-tests"
submodules: "recursive"
path: integration-tests
- uses: actions/setup-java@v3
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-${{ matrix.ghc }}
path: ci_artifact
retention-days: 7
integration-tests-rqlite:
needs: [pre-build, build-and-test]
runs-on: ubuntu-latest
name: integration-tests-rqlite-ghc-${{ matrix.ghc }}
strategy:
fail-fast: false
matrix:
ghc: ${{ fromJson(needs.pre-build.outputs.ghc) }}
steps:
- name: Free disk space
run: |
echo "Before..."
df -h
sudo rm -rf \
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
"/usr/local/share/boost" \
/usr/lib/jvm || true
echo "After..."
df -h
- name: retrieve saved docker image
uses: actions/download-artifact@v3
with:
name: image-testing-${{ matrix.ghc }}
path: ~/data
- name: docker load
run: |
docker load -i ~/data/new_hstream_image.tar
docker run -t --rm $NEW_HSTREAM_IMAGE /usr/local/bin/hstream-server +RTS --info
- name: fetch integration tests source code
uses: actions/checkout@v3
with:
repository: "hstreamdb/integration-tests"
submodules: "recursive"
path: integration-tests
- uses: actions/setup-java@v3
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-${{ matrix.ghc }}
path: ci_artifact
retention-days: 7
distributed-tests:
needs: [pre-build, build-and-test]
runs-on: ubuntu-latest
name: distributed-tests-ghc-${{ matrix.ghc }}
strategy:
fail-fast: false
matrix:
ghc: ${{ fromJson(needs.pre-build.outputs.ghc) }}
steps:
- name: retrieve saved docker image
uses: actions/download-artifact@v3
with:
name: image-testing-${{ matrix.ghc }}
path: ~/data
- name: docker load
run: |
docker load -i ~/data/new_hstream_image.tar
docker run -t --rm $NEW_HSTREAM_IMAGE /usr/local/bin/hstream-server +RTS --info
- 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-${{ matrix.ghc }}
path: ci_artifact
retention-days: 7
# hstream-io-tests:
# needs: [pre-build, build-and-test]
# runs-on: ubuntu-latest
# name: hstream-io-tests-ghc-${{ matrix.ghc }}
# strategy:
# fail-fast: false
# matrix:
# ghc: ${{ fromJson(needs.pre-build.outputs.ghc) }}
# steps:
# - name: retrieve saved docker image
# uses: actions/download-artifact@v3
# with:
# name: image-testing-${{ matrix.ghc }}
# path: ~/data
# - name: docker load
# run: |
# docker load -i ~/data/new_hstream_image.tar
# docker run -t --rm $NEW_HSTREAM_IMAGE /usr/local/bin/hstream-server +RTS --info
# - 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/gradle-build-action@v2
# - name: build and pull images
# run: |
# cd hstream-connectors
# export CONNECTOR_IMAGE_VERSION=v0.2.3
# make pull_images
# make build_images
# - name: run hstream io tests
# run: |
# cd hstream-connectors/integration_tests
# export HSTREAM_IMAGE_NAME=$NEW_HSTREAM_IMAGE
# export HSTREAM_IO_USE_DEFAULT_IMAGES=true
# ./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-${{ matrix.ghc }}
# path: ci_artifact
# retention-days: 7
deploy-k8s:
# disabled due to a lack of hardware resources of the github action
if: false
needs: [pre-build, build-and-test]
runs-on: ubuntu-latest
name: deploy-to-minikube-ghc-${{ matrix.ghc }}
strategy:
fail-fast: true
matrix:
ghc: ${{ fromJson(needs.pre-build.outputs.ghc) }}
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-${{ matrix.ghc }}
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"