-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
360 lines (308 loc) · 9.78 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
stages:
- static_code_analysis
- build
- test
- deploy
include:
- project: 'hive/common-ci-configuration'
ref: 40451cfbe8c2995c66b2d4150dbb3c4d11fd8590
file:
- '/templates/npm_projects.gitlab-ci.yml'
- '/templates/wasm_build.gitlab-ci.yml'
- '/templates/python_projects.gitlab-ci.yml'
variables:
GIT_DEPTH: 0
GIT_STRATEGY: clone
# only build steps needs to have access to the hive submodule
GIT_SUBMODULE_STRATEGY: none
# uses registry.gitlab.syncad.com/hive/wax/ci-base-image:ubuntu22.04-2
CI_BASE_IMAGE_TAG: "@sha256:128bfa65ab2725367fd024a9cd4ac78ee04e3d486af53a4499ab15f7e8264d14"
CI_BASE_IMAGE: "registry.gitlab.syncad.com/hive/wax/ci-base-image${CI_BASE_IMAGE_TAG}"
# uses registry.gitlab.syncad.com/hive/wax/ci-base-image:ubuntu22.04-2
PYTHON_IMAGE_TAG: "${CI_BASE_IMAGE_TAG}"
PYTHON_IMAGE: "${CI_BASE_IMAGE}"
# colors:
TXT_BLUE: "\e[1;34m"
TXT_CLEAR: "\e[0m"
NPM_TOKEN: $CI_JOB_TOKEN
image: "${CI_BASE_IMAGE}"
default:
tags:
- public-runner-docker
build_wheel:
extends: .build_wheel_template
variables:
PYPROJECT_DIR: "${CI_PROJECT_DIR}/python"
GIT_SUBMODULE_STRATEGY: recursive
stage: build
script:
- ./python/scripts/build_wax.sh 1
artifacts:
when: always
paths:
- "${PYPROJECT_DIR}/dist/"
- "${PYPROJECT_DIR}/.build/logs/"
- "${PYPROJECT_DIR}/.build/*.so"
- "build_wheel.env"
- "${PYPROJECT_DIR}/wax/proto"
reports:
dotenv: "build_wheel.env"
verify_poetry_lock_sanity:
extends: .verify_poetry_lock_sanity_template
stage: static_code_analysis
variables:
PYPROJECT_DIR: "$CI_PROJECT_DIR/python"
tags:
- public-runner-docker
wax_wasm_proto_tsc_generation:
extends: .npm_build_template
stage: build
variables:
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
DIST_DIR: "$CI_PROJECT_DIR/ts/wasm/dist"
NPM_PACKAGE_SCOPE: "@hiveio"
NPM_PACKAGE_NAME: "wax"
GIT_SUBMODULE_STRATEGY: recursive
artifacts:
paths:
- "${DIST_DIR}/*.tgz" # Built package
- "${CI_PROJECT_DIR}/ts/wasm/lib/proto" # For documentation generator
- "${CI_PROJECT_DIR}/ts/wasm/lib/build_wasm" # For documentation generator
- "${CI_PROJECT_DIR}/ts/wasm/build_wasm/wax.node.js" # For documentation generator
- "${DIST_DIR}/lib/proto" # For protobuf pattern tests
- "${DIST_DIR}/lib" # For Node.js tests
tags:
- public-runner-docker
wax_wasm_build_tests:
extends: .npm_process_built_package_tarball
stage: build
variables:
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
PACKAGE_TGZ_PATH: "${BUILT_PACKAGE_PATH}"
needs:
- job: wax_wasm_proto_tsc_generation
artifacts: true
script:
- cd "${SOURCE_DIR}"
- npm run build:test
artifacts:
paths:
- "$CI_PROJECT_DIR/ts/wasm/dist/assets"
- "$CI_PROJECT_DIR/ts/wasm/dist/detailed"
- "$CI_PROJECT_DIR/ts/wasm/dist/index.spec.*"
when: always
expire_in: 1 week
tags:
- public-runner-docker
generate_docs:
stage: build
extends: .npm_process_built_package_tarball
variables:
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
DIST_DIR: "$CI_PROJECT_DIR/ts/wasm/dist"
PACKAGE_TGZ_PATH: "${BUILT_PACKAGE_PATH}"
script:
- ./ts/scripts/generate_api_docs.sh "${CI_PROJECT_URL}" "${CI_COMMIT_SHA}"
needs:
- job: wax_wasm_proto_tsc_generation
artifacts: true
artifacts:
paths:
- "${DIST_DIR}/docs"
when: always
expire_in: 1 week
push_to_wiki:
extends: .npm_push_doc_template
stage: deploy
variables:
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
WIKI_PUSH_TOKEN: "$WIKI_PUSH_TOKEN"
DIST_DIR: "${CI_PROJECT_DIR}/ts/wasm/dist"
needs:
- job: generate_docs
artifacts: true
.runtime_like_python_env:
stage: test
extends: .configuration_template
variables:
PYPROJECT_DIR: "${CI_PROJECT_DIR}/python"
needs:
- job: build_wheel
artifacts: true
before_script:
- !reference [.configuration_template, before_script]
- pip install ${PYPROJECT_DIR}/dist/*.whl
- pip list
- ls -al $(poetry -C "${PYPROJECT_DIR}" env info --path)/lib/python3.10/site-packages/
.test_python_env:
extends: .runtime_like_python_env
before_script:
- !reference [.runtime_like_python_env, before_script]
- poetry -C "${PYPROJECT_DIR}" install --no-root # install dependencies for tests
- pip list
test_importing_wax:
extends: .runtime_like_python_env
script:
- echo -e "${TXT_BLUE}Testing...${TXT_CLEAR}"
- cd .. # needed to import installed package instead of local one
- python3 -c "import wax; print(wax.__version__); exit(wax.__version__ == '0.0.0')"
test_wax_protobuf_python:
extends: .test_python_env
script:
- echo -e "${TXT_BLUE}Testing wax with proto ...${TXT_CLEAR}"
- ${PYPROJECT_DIR}/tests/run_tests.sh
artifacts:
reports:
junit: python/tests/report.xml
test_wax_protobuf_python_pattern:
extends: .test_python_env
needs:
- job: build_wheel
artifacts: true
script:
- echo -e "${TXT_BLUE}Testing generated proto files with patterns ...${TXT_CLEAR}"
- diff --brief --recursive --color=never --no-ignore-file-name-case --no-dereference $CI_PROJECT_DIR/python/protobuf_patterns/ $CI_PROJECT_DIR/python/wax/proto/
artifacts:
paths:
- $CI_PROJECT_DIR/python/wax/proto/
when: always
expire_in: 1 week
test_wax_protobuf_python_examples:
extends: .runtime_like_python_env
script:
- echo -e "${TXT_BLUE}Testing visitor of wax protobuf...${TXT_CLEAR}"
- cd $CI_PROJECT_DIR
- ./examples/python/run_example.sh
test_wax_wasm:
extends: .npm_test_template
variables:
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
PACKAGE_TGZ_PATH: "${BUILT_PACKAGE_PATH}"
needs:
- job: wax_wasm_proto_tsc_generation
artifacts: true
- job: wax_wasm_build_tests
artifacts: true
tags:
- public-runner-docker
parallel:
matrix:
- TEST_GROUPS: [
--project=wax_testsuite,
--project=healthchecker_tests,
--project=wax_utils --project=wax_non_encrypted_operations --project=wax_mock_tests --project=wax_encrypted_operations --project=wax_custom_chain_online_tx --project=wax_testsuite_custom_chain_options,
--project=wax_regression_tests --project=wax_operation_factories --project=wax_testsuite_protocol_benchmarks,
]
script:
- cd ts
- npm run test -- $TEST_GROUPS
test_wax_wasm_proto_pattern:
extends: .npm_process_built_package_tarball
needs:
- job: wax_wasm_proto_tsc_generation
artifacts: true
variables:
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
PACKAGE_TGZ_PATH: "${BUILT_PACKAGE_PATH}"
script:
- diff --brief --recursive --color=never --no-ignore-file-name-case --no-dereference "$CI_PROJECT_DIR/ts/protobuf_patterns/proto" "$CI_PROJECT_DIR/ts/wasm/dist/lib/proto"
- tar -tf "${PACKAGE_TGZ_PATH}" > "$CI_PROJECT_DIR/ts/wasm/dist/npm-pack.gen"
- diff --brief --color=never --no-dereference "$CI_PROJECT_DIR/ts/wasm/dist/npm-pack.gen" "$CI_PROJECT_DIR/ts/protobuf_patterns/npm-pack.out"
artifacts:
paths:
- "$CI_PROJECT_DIR/ts/wasm/dist/npm-pack.gen"
- "$CI_PROJECT_DIR/ts/wasm/dist/lib/proto/"
when: always
expire_in: 1 week
tags:
- public-runner-docker
test_wax_wasm_examples:
extends: .npm_process_built_package_tarball
needs:
- job: wax_wasm_proto_tsc_generation
artifacts: true
variables:
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
PACKAGE_TGZ_PATH: "${BUILT_PACKAGE_PATH}"
script:
- cd "${SOURCE_DIR}"
- npm run examples
tags:
- public-runner-docker
.deploy_wheel_needs: &deploy_wheel_needs
needs:
- job: test_importing_wax
- job: test_wax_protobuf_python
- job: build_wheel
artifacts: true
deploy_wheel_to_gitlab:
stage: deploy
extends: .deploy_wheel_to_gitlab_template
variables:
PYPROJECT_DIR: "${CI_PROJECT_DIR}/python"
<<: *deploy_wheel_needs
when: on_success
deploy_wheel_to_pypi:
extends: .deploy_wheel_to_pypi_template
stage: deploy
variables:
PYPROJECT_DIR: "${CI_PROJECT_DIR}/python"
<<: *deploy_wheel_needs
supplement_documentation_url:
extends: .npm_process_built_package_tarball
stage: deploy
needs:
- job: wax_wasm_proto_tsc_generation
artifacts: true
- job: push_to_wiki
artifacts: true
script:
- ./ts/scripts/generate_api_docs.sh "${CI_PROJECT_URL}" "${CI_COMMIT_SHA}" "${GEN_DOC_URL}" tmp_doc
# built package must be repacked to include supplemented README.md file
- cd "${SOURCE_DIR}"
- npm pack --pack-destination "${DIST_DIR}"
- echo BUILT_PACKAGE_PATH="${PACKAGE_TGZ_PATH}" > "${SOURCE_DIR}/built_package_info.env"
variables:
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
PACKAGE_TGZ_PATH: "${BUILT_PACKAGE_PATH}"
DIST_DIR: "$CI_PROJECT_DIR/ts/wasm/dist"
artifacts:
paths:
- "$CI_PROJECT_DIR/ts/README.md"
- "${DIST_DIR}/*.tgz" # Built package
reports:
dotenv:
- "${SOURCE_DIR}/built_package_info.env" # contains path to produced tgz
when: always
expire_in: 1 week
deploy_wax_wasm_dev_package:
extends: .npm_deploy_package_template
stage: deploy
variables:
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
PACKAGE_TGZ_PATH: "${BUILT_PACKAGE_PATH}"
NPM_PACKAGE_SCOPE: "@hiveio"
needs:
- job: test_wax_wasm_examples
- job: test_wax_wasm
- job: test_wax_wasm_proto_pattern
- job: supplement_documentation_url
artifacts: true
tags:
- public-runner-docker
deploy_wax_wasm_production_public_npm:
extends: .registry_npmjs_org_deploy_package_template
stage: deploy
variables:
NPM_PUBLISH_TOKEN: "$INTERNAL_HIDDEN_PUBLISH_TOKEN"
NPM_PACKAGE_NAME: "wax"
SOURCE_DIR: "${CI_PROJECT_DIR}/ts"
PACKAGE_TGZ_PATH: "${BUILT_PACKAGE_PATH}"
needs:
- job: test_wax_wasm_examples
- job: test_wax_wasm
- job: test_wax_wasm_proto_pattern
- job: supplement_documentation_url
artifacts: true
tags:
- public-runner-docker