-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
469 lines (429 loc) · 13.8 KB
/
.gitlab-ci.yml
File metadata and controls
469 lines (429 loc) · 13.8 KB
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
variables:
CI_DISPOSABLE_ENVIRONMENT: "true"
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2375
DOCKER_TLS_CERTDIR: ""
GITLAB_ADVANCED_SAST_ENABLED: "true"
SECURE_LOG_LEVEL: "info"
SECRET_DETECTION_ENABLED: "true"
DS_GRADLE_RESOLUTION_POLICY: "none"
DS_EXCLUDED_PATHS: "spec, docs, test, tests, tmp, proxy"
SAST_EXCLUDED_PATHS: "spec, docs, test, tests, tmp, proxy"
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
stages:
- security
- fmt
- build
- test
- test_long
- deploy
.base:
image: xenoky/lwk-builder@sha256:2ae964fa1de82046cd86f4a9997a624a00b91c7374f9ffdc4d23ce117da115a3
tags:
- cloud
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- stuck_or_timeout_failure
services:
- docker:27-dind
before_script:
- cp /usr/local/cargo/bin/waterfalls /bin/waterfalls_b8818e1
sast:
stage: security
needs: []
dependency_scanning:
stage: security
needs: []
secret_detection:
stage: security
needs: []
build_bindings:
stage: build
needs: []
extends: .base
script:
- cargo build --release -p lwk_bindings
artifacts:
paths:
- target/release/liblwk.so
expire_in: 1 day
fmt_clippy:
stage: fmt
needs: []
extends: .base
script:
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
- cargo fmt --check
- cargo clippy --all-targets -- -D warnings
test_clean:
stage: test
needs: []
image: rust:1.75
script:
- cargo build
test_no_default_features:
stage: test
needs: []
extends: .base
# We need to polish how we feature gate our code
# However let's do things iteratively rather than all at once
# TODO: add RUSTFLAGS="-D warnings" to address warnings too
# TODO: test other crates too
# TODO: replace cargo build with cargo check --tests
script:
- cargo build -p lwk_wollet --no-default-features
allow_failure: true # TODO: remove once fixed
test_wollet:
stage: test
needs: []
extends: .base
script:
- docker pull xenoky/local-jade-emulator:1.0.27
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
- cargo test -p lwk_wollet -p lwk_signer
test_jade:
stage: test
needs: []
extends: .base
variables:
TMPDIR: ${CI_PROJECT_DIR} # otherwise issue with the docker
script:
- docker pull tulipan81/blind_pin_server:v0.0.7
- docker pull xenoky/local-jade-emulator:1.0.27
- cargo test -p lwk_jade
test_ledger:
stage: test
needs: []
extends: .base
script:
- cargo test -p lwk_ledger --features asyncr
test_serial:
stage: test
needs: []
extends: .base
variables:
script:
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
- cargo test --no-run --features serial
# run tests for minor crates all together
test_minor:
stage: test
needs: []
extends: .base
script:
- cargo test -p lwk_tiny_jrpc -p lwk_app -p lwk_containers -p lwk_common -p lwk_hwi -p lwk_rpc_model -p lwk_signer
test_cli:
stage: test
needs: []
extends: .base
script:
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
- cargo test -p lwk_cli
test_simplicity:
stage: test
needs: []
extends: .base
script:
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
- cargo test -p lwk_simplicity
unit_tests:
stage: test
needs: []
extends: .base
script:
- cargo nextest run --lib --profile unit # ensure unit tests don't take more than a sec each
test_coverage:
stage: test_long
needs: [fmt_clippy]
extends: .base
variables:
RUSTFLAGS: "-C instrument-coverage"
LLVM_PROFILE_FILE: "coverage-%p-%m.profraw"
TMPDIR: ${CI_PROJECT_DIR} # otherwise issue with the docker
JAVA_OPTS: "-Xmx2g"
script:
- docker pull tulipan81/blind_pin_server:v0.0.7
- docker pull xenoky/local-jade-emulator:1.0.27
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
- cargo nextest run --features foreign_bindings,asyncr --profile ci
- grcov . -s . --binary-path ./target/debug/ -t cobertura --branch --ignore-not-existing --ignore "*cargo*" -o ./target/coverage.xml -p $(pwd)
- "xmllint --xpath \"concat('Coverage: ', 100 * string(//coverage/@line-rate), ' perc')\" target/coverage.xml"
- grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --ignore "*cargo*" -o ./target/coverage/ -p $(pwd)
coverage: '/Coverage: \d+(?:\.\d+)?/'
artifacts:
paths:
- target/coverage.xml
- target/coverage/
- target/nextest/ci/junit.xml
reports:
coverage_report:
coverage_format: cobertura
path: target/coverage.xml
junit: target/nextest/ci/junit.xml
build_cli:
stage: test
needs: []
extends: .base
only:
- master@liquid/lwk
script:
- cargo build --release -p lwk_cli
artifacts:
paths:
- target/release/lwk_cli
when: always
expire_in: 14 days
audit:
stage: test
needs: []
extends: .base
script:
- cargo audit --deny yanked
doc:
stage: test
needs: []
extends: .base
variables:
RUSTDOCFLAGS: "-D warnings --cfg docsrs"
script:
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
# - cargo +nightly doc --all-features --no-deps # we can't use --all-features right now because of lightning feature
- cargo +nightly doc --no-deps -p lwk_app --all-features
- cargo +nightly doc --no-deps -p lwk_cli --all-features
- cargo +nightly doc --no-deps -p lwk_common --all-features
- cargo +nightly doc --no-deps -p lwk_containers --all-features
- cargo +nightly doc --no-deps -p lwk_hwi --all-features
- cargo +nightly doc --no-deps -p lwk_jade --all-features
- cargo +nightly doc --no-deps -p lwk_ledger --all-features
- cargo +nightly doc --no-deps -p lwk_rpc_model --all-features
- cargo +nightly doc --no-deps -p lwk_signer --all-features
- cargo +nightly doc --no-deps -p lwk_test_util --all-features
- cargo +nightly doc --no-deps -p lwk_tiny_jrpc --all-features
- cargo +nightly doc --no-deps -p lwk_wasm --all-features
- cargo +nightly doc --no-deps -p lwk_wollet --all-features
- cargo +nightly doc --no-deps -p lwk_bindings --features foreign_bindings
examples:
stage: test
needs: []
extends: .base
script:
- cargo run --example list_transactions
bindings:
stage: test
needs: []
extends: .base
variables:
JAVA_OPTS: "-Xmx2g"
script:
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
- cargo test -p lwk_bindings --features foreign_bindings
csharp:
stage: test
needs: [build_bindings]
extends: .base
script:
- mkdir csharp
- cp target/release/liblwk.so csharp/
- uniffi-bindgen-cs --library csharp/liblwk.so --out-dir csharp
- sed -i 's#\"lwk\"#\"./liblwk.so\"#g' csharp/lwk.cs # this is an hack, but make it work until we understand how to properly reference the dynamic lib
- cp lwk_bindings/tests/bindings/list_transactions.cs csharp
- cp lwk_bindings/tests/test_data/test-dotnet.csproj csharp
- cd csharp && dotnet run && cd -
- rm -rf csharp/bin && rm -rf csharp/obj # remove dotnet-build created files
artifacts:
paths:
- csharp
cpp:
stage: test
needs: [build_bindings]
extends: .base
script:
- mkdir cpp
- cp target/release/liblwk.so cpp/
- uniffi-bindgen-cpp --library cpp/liblwk.so --out-dir cpp
- cp lwk_bindings/tests/bindings/list_transactions.cpp cpp
- cd cpp
- g++ -std=c++20 -L./ -Wl,-rpath,./ -o test list_transactions.cpp lwk.cpp -llwk
- ./test && cd -
- rm -rf cpp/test cpp/list_transactions.cpp # cleanup
artifacts:
paths:
- cpp
just:
stage: test
needs: []
extends: .base
variables:
JAVA_OPTS: "-Xmx2g"
script:
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
- just python-test-bindings
- just python-test-bindings-simplicity
- just kotlin # kotlin-android would require cargo-ndk and various targets, tested on github which produce the kotlin package
wasm:
stage: test_long
needs: [fmt_clippy]
extends: .base
variables:
RUSTFLAGS: "--cfg=web_sys_unstable_apis"
script:
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
- cargo check --target wasm32-unknown-unknown -p lwk_common -p lwk_rpc_model -p lwk_containers -p lwk_hwi
- cargo check --target wasm32-unknown-unknown -p lwk_wollet --no-default-features --features esplora,serial,amp2,amp0
- cargo check --target wasm32-unknown-unknown -p lwk_signer --no-default-features
- cargo check --target wasm32-unknown-unknown -p lwk_jade --no-default-features --features asyncr --features serial
- cargo check --target wasm32-unknown-unknown -p lwk_ledger --no-default-features
- cargo check --target wasm32-unknown-unknown -p lwk_boltz --no-default-features
- cd lwk_wasm && CHROMEDRIVER_ARGS="--allowed-ips=127.0.0.1" WASM_BINDGEN_TEST_TIMEOUT=60 wasm-pack test --chrome --headless --features serial && cd -
- cd lwk_wasm && RUSTFLAGS="--cfg=web_sys_unstable_apis" CARGO_PROFILE_RELEASE_OPT_LEVEL=z wasm-pack build --features serial && cd -
# testing nodejs package
- cd lwk_wasm
- RUSTFLAGS="--cfg=web_sys_unstable_apis" CARGO_PROFILE_RELEASE_OPT_LEVEL=z wasm-pack build --target nodejs --out-dir pkg_node -- --features serial,simplicity
- sed -i 's/"lwk_wasm"/"lwk_node"/g' pkg_node/package.json
- cd tests/node
- npm install
- npm run test
artifacts:
paths:
- lwk_wasm/pkg
nix:
stage: test_long
needs: [fmt_clippy]
image: xenoky/lwk-nix-builder@sha256:c24c03dce4f0f9ea10614844c29e0cdef0b0bcf80ce68e83da57e820a2049da1
variables:
EXP_FEAT: --extra-experimental-features nix-command --extra-experimental-features flakes
CACHE: --extra-trusted-public-keys nix.casatta.it:HseKZh7436/vKXfZDBHbhr7wwAkzjLwY5BIq+OOrITg= --extra-substituters https://nix.casatta.it
script:
- nix $EXP_FEAT $CACHE build .
- nix $EXP_FEAT $CACHE develop . -c rust-analyzer analysis-stats . 2>log # prints ERROR if there are cyclic deps with dev-deps
- (! grep ERROR log)
# AMP0 has a closed source backend, so its tests are unreliable, allow them to fail.
# Anyway for MRs/PRs that touch AMP0 code, this must pass.
amp0:
stage: test_long
needs: [fmt_clippy]
extends: .base
script:
- cp ./context/env.sh / && cd / && . ./env.sh && cd -
# slow amp0 unit tests
- cargo test -p lwk_wollet slow_amp0 -- --include-ignored
# bindings
- cargo test -p lwk_bindings --features foreign_bindings amp0
# wasm
- cd lwk_wasm
- RUSTFLAGS="--cfg=web_sys_unstable_apis" wasm-pack build --dev --target nodejs --out-dir pkg_node -- --features serial
- sed -i 's/"lwk_wasm"/"lwk_node"/g' pkg_node/package.json
- cd tests/node
- npm install
- node amp0-setup.js
- node amp0-daily-ops.js
allow_failure: true
boltz_chain:
stage: test_long
needs: [fmt_clippy]
extends: .base
script:
- cd lwk_boltz
- git submodule update --init --recursive
- just regtest-env-start && sleep 15 # explicitly start the env to give more time to bitcoind to start
- just test-chain
allow_failure: true
boltz_mrh:
stage: test_long
needs: [fmt_clippy]
extends: .base
script:
- cd lwk_boltz
- git submodule update --init --recursive
- just regtest-env-start && sleep 15 # explicitly start the env to give more time to bitcoind to start
- just test-mrh
allow_failure: true
boltz_reverse:
stage: test_long
needs: [fmt_clippy]
extends: .base
script:
- cd lwk_boltz
- git submodule update --init --recursive
- just regtest-env-start && sleep 15 # explicitly start the env to give more time to bitcoind to start
- just test-reverse
allow_failure: true
boltz_submarine:
stage: test_long
needs: [fmt_clippy]
extends: .base
script:
- cd lwk_boltz
- git submodule update --init --recursive
- just regtest-env-start && sleep 15 # explicitly start the env to give more time to bitcoind to start
- just test-submarine
allow_failure: true
# maven credentials and gpg settings
# in runner's ~/.gradle/gradle.properties
publish_to_maven:
stage: deploy
tags:
- m4
rules:
- if: '$CI_COMMIT_TAG'
when: manual
needs: []
script:
- just kotlin-multiplatform
- cd lwk_bindings/android_bindings
- ./gradlew publish --no-daemon
artifacts:
paths:
- lwk_bindings/android_bindings/lib/build/libs
- lwk_bindings/android_bindings/lib/build/outputs
- lwk_bindings/android_bindings/lib/build/publications
when: always
expire_in: 7 days
allow_failure: true
publish_snapshot_to_maven:
stage: deploy
tags:
- m4
needs: []
variables:
SIMPLICITY: "1"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- when: manual
script:
- just kotlin-multiplatform
- cd lwk_bindings/android_bindings
- RAW_VERSION=$(grep '^libraryVersion=' gradle.properties | cut -d'=' -f2)
- BASE_VERSION=${RAW_VERSION%-SNAPSHOT}
- VERSION_CORE=$(echo "$BASE_VERSION" | sed -E 's/[^0-9.].*$//')
- IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_CORE"
- MAJOR=${MAJOR:-0}
- MINOR=${MINOR:-0}
- PATCH=${PATCH:-0}
- NEXT_PATCH=$((PATCH + 1))
- NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}"
- GIT_COMMIT=$(git rev-parse --short=8 HEAD)
- SNAPSHOT_VERSION="${NEXT_VERSION}-SNAPSHOT"
- SNAPSHOT_VERSION_COMMIT="${NEXT_VERSION}-${GIT_COMMIT}-SNAPSHOT"
- |
if [ "$CI_COMMIT_BRANCH" = "master" ]; then
echo "Publishing snapshot versions ${SNAPSHOT_VERSION}"
./gradlew -PlibraryVersion=${SNAPSHOT_VERSION} publish --no-daemon
fi
echo "Publishing snapshot version ${SNAPSHOT_VERSION_COMMIT}"
./gradlew -PlibraryVersion=${SNAPSHOT_VERSION_COMMIT} publish --no-daemon
artifacts:
paths:
- lwk_bindings/android_bindings/lib/build/libs
- lwk_bindings/android_bindings/lib/build/outputs
- lwk_bindings/android_bindings/lib/build/publications
when: always
expire_in: 7 days
allow_failure: true