forked from icon-project/goloop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
432 lines (396 loc) · 12.5 KB
/
.gitlab-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
stages:
- deps
- unit
- build
- pack
- integration
- deploy
- cleanup
variables:
IMAGE_GO_DEPS: "goloop/go-deps:${CI_COMMIT_REF_NAME}"
IMAGE_PY_DEPS: "goloop/py-deps:${CI_COMMIT_REF_NAME}"
IMAGE_JAVA_DEPS: "goloop/java-deps:${CI_COMMIT_REF_NAME}"
IMAGE_ROCKSDB_DEPS: "goloop/rocksdb-deps:${CI_COMMIT_REF_NAME}"
IMAGE_BUILD_DEPS: "goloop/build-deps:${CI_COMMIT_REF_NAME}"
IMAGE_GOLOOP: "goloop:${CI_COMMIT_REF_NAME}"
IMAGE_GOLOOP_PY: "goloop-py:${CI_COMMIT_REF_NAME}"
IMAGE_GOLOOP_JAVA: "goloop-java:${CI_COMMIT_REF_NAME}"
REGISTRY: "ci.arch.iconloop.com:80"
RPC_DUMP: "true"
before_script:
- env
deps:go:
image: docker:git
stage: deps
script:
- sh docker/build-deps/build.sh go
- sh docker/build-deps/build.sh rocksdb
- sh docker/build-deps/build.sh build
tags:
- docker-build
deps:py:
image: docker:git
stage: deps
script:
- sh docker/build-deps/build.sh py
tags:
- docker-build
deps:java:
image: docker:git
stage: deps
script:
- sh docker/build-deps/build.sh java
tags:
- docker-build
unit:go:
image: "${IMAGE_BUILD_DEPS}"
stage: unit
script:
- make test
tags:
- docker
unit:py:
image: "${IMAGE_PY_DEPS}"
stage: unit
script:
- cd pyee
- python -m unittest -v
tags:
- docker
unit:java:
image: "${IMAGE_JAVA_DEPS}"
stage: unit
script:
- cd javaee
- ./gradlew test
tags:
- docker
build:go:
image: "${IMAGE_BUILD_DEPS}"
stage: build
script:
- make goloop
- GOBUILD_TAGS="" make gstool
- ./bin/goloop doc ./doc/goloop_cli.md
artifacts:
expire_in: 1 day
paths:
- bin/
- doc/goloop_cli.md
tags:
- docker
build:pyee:
image: "${IMAGE_PY_DEPS}"
stage: build
script:
- cd pyee
- pip3 install wheel
- python3 setup.py bdist_wheel -d ../build/pyee/dist
artifacts:
expire_in: 1 day
paths:
- build/pyee/dist/
tags:
- docker
build:java:
image: "${IMAGE_JAVA_DEPS}"
stage: build
script:
- cd javaee
- ./gradlew -Prelease api:build app:execman:distZip
artifacts:
expire_in: 1 day
paths:
- javaee/app/execman/build/distributions/
- javaee/api/build/javadoc/
tags:
- docker
.pack: &pack
image: docker:git
stage: pack
variables:
IMAGE_BASE: "goloop/base:${CI_COMMIT_REF_NAME}"
tags:
- docker-build
# pack:goloop:py:
# <<: *pack
# variables:
# IMAGE_BASE: "goloop/base-py:${CI_COMMIT_REF_NAME}"
# script:
# - sh docker/base/build.sh py
# - sh docker/goloop-py/build.sh
# dependencies:
# - build:go
# - build:pyee
pack:goloop:java:
<<: *pack
variables:
IMAGE_BASE: "goloop/base-java:${CI_COMMIT_REF_NAME}"
script:
- sh docker/base/build.sh java
- sh docker/goloop-java/build.sh
dependencies:
- build:go
- build:java
pack:goloop:
<<: *pack
variables:
IMAGE_BASE: "goloop/base-all:${CI_COMMIT_REF_NAME}"
script:
- sh docker/base/build.sh all
- sh docker/goloop/build.sh
dependencies:
- build:go
- build:pyee
- build:java
.integration:goloop: &IT__goloop
image: "docker:java11" #sh -c 'echo -e "FROM docker:git\nRUN apk add openjdk11" | docker build --tag docker:java11 -'
stage: integration
variables:
GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesis.json"
GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/py.props"
GOLOOP_MULTI_SCRIPT: docker/goloop/multi.sh
before_script:
- env
- export GRADLE_USER_HOME=${CI_PROJECT_DIR}/testsuite/.gradle
- export GOLOOP_DOCKER_REPLICAS=4
- export GOLOOP_DATA=${CI_PROJECT_DIR}.tmp/${CI_COMMIT_REF_NAME}/${CI_PIPELINE_ID}/${CI_JOB_ID}
- export GOLOOP_GOD_KEYSTORE=${CI_PROJECT_DIR}/testsuite/data/keystore_god.json
- export SELF_CONTAINER=$(docker ps --filter label=com.gitlab.gitlab-runner.job.id=${CI_JOB_ID} --format {{.ID}});
export GOLOOP_DOCKER_MOUNT="/builds";
FORMAT_MOUNT_NAME="{{range .Mounts}}{{if eq .Destination \"/builds\"}}{{.Name}}{{end}}{{end}}";
export GOLOOP_DOCKER_VOLUME=$(docker inspect ${SELF_CONTAINER} --format "${FORMAT_MOUNT_NAME}");
export GOLOOP_DOCKER_NETWORK=${GOLOOP_DOCKER_NETWORK:-goloop_${CI_JOB_ID}_net};
export GOLOOP_DOCKER_PREFIX=${GOLOOP_DOCKER_PREFIX:-goloop-${CI_JOB_ID}};
export GOLOOP_RPC_DUMP=${RPC_DUMP};
sh ${GOLOOP_MULTI_SCRIPT} create
- sh ${GOLOOP_MULTI_SCRIPT} join ${GOLOOP_GENESIS} ${GOLOOP_GOD_KEYSTORE}; cat ${GOLOOP_GENESIS}
- sh ${GOLOOP_MULTI_SCRIPT} start
- sh ${GOLOOP_MULTI_SCRIPT} env ${GOLOOP_ENVFILE}; cat ${GOLOOP_ENVFILE}
- docker network connect --alias test ${GOLOOP_DOCKER_NETWORK} ${SELF_CONTAINER}
- cd testsuite
script:
- ./gradlew test -DNO_SERVER="true" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
after_script:
- export GOLOOP_DATA=${CI_PROJECT_DIR}.tmp/${CI_COMMIT_REF_NAME}/${CI_PIPELINE_ID}/${CI_JOB_ID};
cp -rf $GOLOOP_DATA goloop_data || echo "failed copy $GOLOOP_DATA"
- export SELF_CONTAINER=$(docker ps --filter label=com.gitlab.gitlab-runner.job.id=${CI_JOB_ID} --format {{.ID}});
export GOLOOP_DOCKER_NETWORK=${GOLOOP_DOCKER_NETWORK:-goloop_${CI_JOB_ID}_net};
docker network disconnect ${GOLOOP_DOCKER_NETWORK} ${SELF_CONTAINER}
- export GOLOOP_DOCKER_PREFIX=${GOLOOP_DOCKER_PREFIX:-goloop-${CI_JOB_ID}};
sh ${GOLOOP_MULTI_SCRIPT} rm
cache:
key: "${CI_COMMIT_REF_SLUG}"
paths:
- testsuite/.gradle/caches
- testsuite/.gradle/native
- testsuite/.gradle/wrapper
dependencies:
- build:go
artifacts:
expire_in: 1 day
when: on_failure
name: "${CI_COMMIT_REF_SLUG}_${CI_PIPELINE_ID}_${CI_JOB_ID}"
paths:
- goloop_data
- testsuite/build/reports
tags:
- docker-service
except:
- tags
# IT:py:pyscore:
# <<: *IT__goloop
# variables:
# GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesisStorage/genesis_py.json"
# GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/py.props"
# GOLOOP_MULTI_SCRIPT: docker/goloop-py/multi.sh
# script:
# - ./gradlew testPyScore -DNO_SERVER="true" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
#
# IT:py:pygov:
# <<: *IT__goloop
# variables:
# GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesisStorage/genesis_gov.json"
# GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/pygov.props"
# GOLOOP_MULTI_SCRIPT: docker/goloop-py/multi.sh
# script:
# - ./gradlew testPyGov -DNO_SERVER="true" -DAUDIT="false" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
#
# IT:py:pyaudit:
# <<: *IT__goloop
# variables:
# GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesisStorage/genesis_audit.json"
# GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/pygov.props"
# GOLOOP_MULTI_SCRIPT: docker/goloop-py/multi.sh
# script:
# - ./gradlew testPyGov -DNO_SERVER="true" -DAUDIT="true" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
IT:java:javascore:
<<: *IT__goloop
variables:
GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesisStorage/genesis_java.json"
GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/java.props"
GOLOOP_MULTI_SCRIPT: docker/goloop-java/multi.sh
script:
- ./gradlew testJavaScore -DNO_SERVER="true" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
IT:goloop:javagov:
<<: *IT__goloop
variables:
GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesisStorage/genesis_javagov.json"
GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/javagov.props"
GOLOOP_MULTI_SCRIPT: docker/goloop/multi.sh
script:
- ./gradlew testJavaGov -DNO_SERVER="true" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
IT:goloop:pyaudit:
<<: *IT__goloop
variables:
GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesisStorage/genesis_audit.json"
GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/pygov.props"
GOLOOP_MULTI_SCRIPT: docker/goloop/multi.sh
script:
- ./gradlew testPyGov -DNO_SERVER="true" -DAUDIT="true" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
IT:goloop:pygov:
<<: *IT__goloop
variables:
GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesisStorage/genesis_gov.json"
GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/pygov.props"
GOLOOP_MULTI_SCRIPT: docker/goloop/multi.sh
script:
- ./gradlew testPyGov -DNO_SERVER="true" -DAUDIT="false" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
IT:goloop:pyscore:
<<: *IT__goloop
variables:
GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesis.json"
GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/py.props"
GOLOOP_MULTI_SCRIPT: docker/goloop/multi.sh
script:
- ./gradlew testPyScore -DNO_SERVER="true" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
IT:goloop:javascore:
<<: *IT__goloop
variables:
GOLOOP_GENESIS: "${CI_PROJECT_DIR}/testsuite/data/genesisStorage/genesis_java.json"
GOLOOP_ENVFILE: "${CI_PROJECT_DIR}/testsuite/data/chainenv/java.props"
GOLOOP_MULTI_SCRIPT: docker/goloop/multi.sh
script:
- ./gradlew testJavaScore -DNO_SERVER="true" -DCHAIN_ENV="${GOLOOP_ENVFILE}"
.pages: &pages
image: node:lts-alpine
stage: deploy
variables:
PAGES_PUBLIC: "${CI_PROJECT_PATH}/${CI_COMMIT_REF_SLUG}"
PAGES_SOURCE: "public"
before_script:
- env
- mkdir -p /public/${PAGES_PUBLIC}
script:
- echo "$(ls $PAGES_SOURCE)"
after_script:
- if [ -d ${PAGES_SOURCE} ];then rm -rf /public/${PAGES_PUBLIC}/*;cp -r ${PAGES_SOURCE}/* /public/${PAGES_PUBLIC}/;fi
- echo "http://ci.arch.iconloop.com/pages/${PAGES_PUBLIC}"
cache:
key: "${CI_JOB_STAGE}-${CI_COMMIT_REF_NAME}"
paths:
- node_modules
artifacts:
expire_in: 1 day
paths:
- public
tags:
- pages
only:
- base
- master
- tags
pages:doc:
<<: *pages
variables:
PAGES_PUBLIC: "${CI_PROJECT_PATH}/${CI_COMMIT_REF_SLUG}/doc"
PAGES_SOURCE: "doc/dist"
script:
- cd doc
- npm install yarn
- yarn install
- ./node_modules/.bin/widdershins -l --summary goloop_admin_api.yaml -o goloop_admin_api.md
- sed -i "s/base:.*/base:'\/pages\/${PAGES_PUBLIC//\//\\\/}\/',/" .vuepress/config.js
- sed -i 's/\/\/EndOfSidebar/["documentation","Documentation"],\n\/\/EndOfSidebar/' .vuepress/config.js
- mv README.md documentation.md
- cat .vuepress/hometags ../README.md > README.md && sed -i "s/doc\///g" README.md
- ./node_modules/.bin/vuepress build --dest dist ./
pages:javadoc:
<<: *pages
variables:
PAGES_PUBLIC: "${CI_PROJECT_PATH}/${CI_COMMIT_REF_SLUG}/javadoc"
PAGES_SOURCE: "javaee/api/build/javadoc"
pages:IT:goloop:pyscore:
<<: *pages
variables:
PAGES_PUBLIC: "${CI_PROJECT_PATH}/${CI_COMMIT_REF_SLUG}/ITJ_goloop/pyscore"
PAGES_SOURCE: "testsuite/build/reports/tests/testPyScore"
when: on_failure
dependencies:
- IT:goloop:pyscore
pages:IT:goloop:pygov:
<<: *pages
variables:
PAGES_PUBLIC: "${CI_PROJECT_PATH}/${CI_COMMIT_REF_SLUG}/ITJ_goloop/pygov"
PAGES_SOURCE: "testsuite/build/reports/tests/testPyGov"
when: on_failure
dependencies:
- IT:goloop:pygov
pages:IT:goloop:pyaudit:
<<: *pages
variables:
PAGES_PUBLIC: "${CI_PROJECT_PATH}/${CI_COMMIT_REF_SLUG}/ITJ_goloop/pyaudit"
PAGES_SOURCE: "testsuite/build/reports/tests/testPyGov"
when: on_failure
dependencies:
- IT:goloop:pyaudit
pages:IT:goloop:javascore:
<<: *pages
variables:
PAGES_PUBLIC: "${CI_PROJECT_PATH}/${CI_COMMIT_REF_SLUG}/ITJ_goloop/javascore"
PAGES_SOURCE: "testsuite/build/reports/tests/testJavaScore"
when: on_failure
dependencies:
- IT:goloop:javascore
pages:IT:goloop:javagov:
<<: *pages
variables:
PAGES_PUBLIC: "${CI_PROJECT_PATH}/${CI_COMMIT_REF_SLUG}/ITJ_goloop/javagov"
PAGES_SOURCE: "testsuite/build/reports/tests/testJavaGov"
when: on_failure
dependencies:
- IT:goloop:javagov
.push: &push
image: docker:git
stage: deploy
script:
- export REGISTRY_REPO_TAG=${REGISTRY}/${REPO_TAG}
- docker tag ${REPO_TAG} ${REGISTRY_REPO_TAG}
- docker push ${REGISTRY_REPO_TAG}
- docker rmi ${REGISTRY_REPO_TAG}
tags:
- docker-build
only:
- tags
#push:goloop:py:
# <<: *push
# variables:
# REPO_TAG: "goloop-py:${CI_COMMIT_REF_NAME}"
push:goloop:java:
<<: *push
variables:
REPO_TAG: "goloop-java:${CI_COMMIT_REF_NAME}"
push:goloop:
<<: *push
variables:
REPO_TAG: "goloop:${CI_COMMIT_REF_NAME}"
.cleanup:integration:
image: docker:git
stage: cleanup
script:
- export CACHE_DOCKER_CONTAINERS=$(docker container ls -a -f "label=com.gitlab.gitlab-runner.cache.dir=/builds/${CI_PROJECT_NAMESPACE}" --format "{{.ID}}")
- for CONTAINER in ${CACHE_DOCKER_CONTAINERS};do
docker run --rm --volumes-from ${CONTAINER} alpine rm -rf ${CI_PROJECT_DIR}.tmp/${CI_COMMIT_REF_NAME}/${CI_PIPELINE_ID};
done;
tags:
- docker-service