-
Notifications
You must be signed in to change notification settings - Fork 55
221 lines (185 loc) · 8.01 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
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@v2
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 "::set-output name=ghc::$GHCS"
- name: run stylish-haskell
run: |
# install stylish-haskell
PACKAGE=stylish-haskell
RELEASES=$(curl --silent https://github.com/haskell/$PACKAGE/releases)
URL=https://github.com/$(echo $RELEASES | grep -o '\"[^\"]*-linux-x86_64\.tar\.gz\"' | sed s/\"//g | head -n1)
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@v2
with:
submodules: "recursive"
- name: set env
run: |
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
${{ env.SHELL }} "'cd hstream-http-server && go build -v -o ../dist-newstyle/hstream-http-server main.go'"
- 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: start hstream http server
run: |
HTTP_PORT=$(cat local-data/dev_tools.env|grep HTTP_LOCAL_PORT|cut -d '=' -f2)
SERVER_PORT=$(cat local-data/dev_tools.env|grep SERVER_LOCAL_PORT|cut -d '=' -f2)
NAME="test-http-server"
EXE=$(find dist-newstyle -maxdepth 1 -name "hstream-http-server" -type f)
python3 script/dev-tools shell --check --no-interactive --command "" --detach \
--container-name $NAME -i docker.io/hstreamdb/haskell:${{ matrix.ghc }} -- \
$EXE -httpServerPort $HTTP_PORT -gRPCServerPort $SERVER_PORT
sleep 5
docker logs --tail 100 $NAME
- name: test
run: |
${{ env.CABAL }} -- test --test-show-details=direct all
${{ env.SHELL }} "'cd hstream-http-server && go test -v ./test/...'"
# 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@v2
with:
repository: "hstreamdb/integration-tests"
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: tar tests reports
if: ${{ success() }} || ${{ failure() }}
run: |
mv integration-tests/.logs integration-tests/logs
mv integration-tests/app/build/reports integration-tests/reports
tar -cvf ~/data/reports.tar integration-tests/logs integration-tests/reports
- name: upload tests-reports
uses: actions/upload-artifact@v2
if: ${{ success() }} || ${{ failure() }}
with:
name: integration-tests-reports
path: ~/data/reports.tar
retention-days: 7