forked from hyperledger-archives/indy-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile.cd
1955 lines (1569 loc) · 72.7 KB
/
Jenkinsfile.cd
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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!groovy
@Library('SovrinHelpers') _
testReleaseVersion = env.INDY_SDK_TEST_RELEASE_VERSION ?: null
properties([
[$class: 'BuildDiscarderProperty', strategy: [
$class : 'LogRotator',
artifactDaysToKeepStr: '28',
artifactNumToKeepStr : '',
daysToKeepStr : '28',
numToKeepStr : ''
]]
]);
Ubuntu16 = "Ubuntu 16.04"
Ubuntu18 = "Ubuntu 18.04"
Centos = "Centos"
libindyBuildFinished = [(Ubuntu16): false, (Ubuntu18): false, (Centos): false]
libvcxBuildFinished = [(Ubuntu16): false, (Ubuntu18): false, (Centos): false]
ubuntuPakageTypes = [(Ubuntu16): "xenial", (Ubuntu18): "bionic"]
gitHubUserCredId = env.GITHUB_BOT_USER ?: 'sovbot-github'
sovrinPackagingRepo = env.SOVRIN_PACKAGING_REPO ?: 'https://github.com/sovrin-foundation/sovrin-packaging'
sovrinPackagingBranch = env.SOVRIN_PACKAGING_BRANCH ?: 'master'
mavenDeployAddOptions = env.MAVEN_DEPLOY_ADD_OPTIONS ?: ''
androidArchArray = ["arm", "armv7", "x86", "arm64", "x86_64"]
try {
testing()
publishing()
if (acceptanceTesting()) {
releasing()
}
notifyingSuccess()
} catch (err) {
notifyingFailure()
throw err
}
def testing() {
stage('Static Analysis') {
staticValidation()
}
stage('Testing') {
parallel([
'ubuntu-test' : { ubuntuTesting() },
'centos-test' : { centosTesting() },
'android-test': { androidTesting() },
'windows-test': { windowsTesting() },
'ios-test' : { iosTesting() },
'macos-test' : { macosTesting() }
])
}
}
def publishing() {
stage('Publishing') {
echo "${env.BRANCH_NAME}: start publishing"
publishedVersions = parallel([
'centos-files' : { centosPublishing() },
'ubuntu-files' : { ubuntuPublishing() },
'windows-files': { windowsPublishing() },
'android-files': { androidPublishing() },
'ios-files' : { iosPublishing() },
'macos-files' : { macOsPublishing() },
])
if (publishedVersions['windows-files'] != publishedVersions['ubuntu-files']) { // FIXME check rhel too, IS-307
error "platforms artifacts have different versions"
}
}
}
def acceptanceTesting() {
stage('Acceptance testing') {
if (env.BRANCH_NAME == 'rc') {
echo "${env.BRANCH_NAME}: acceptance testing"
if (approval.check("default")) {
return true
}
} else {
echo "${env.BRANCH_NAME}: skip acceptance testing"
}
return false
}
}
def releasing() {
stage('Releasing') {
if (env.BRANCH_NAME == 'rc') {
publishingRCtoStable()
}
}
}
def notifyingSuccess() {
currentBuild.result = "SUCCESS"
node('ubuntu-master') {
sendNotification.success('indy-sdk')
}
}
def notifyingFailure() {
currentBuild.result = "FAILED"
node('ubuntu-master') {
sendNotification.fail([slack: true])
}
}
def staticValidation() {
parallel([
'libindy' : { runValdiationRust('libindy') },
'libnullpay': { runValdiationRust('libnullpay') },
'libvcx' : { runValdiationRust('vcx/libvcx') },
'cli' : { runValdiationRust('cli') }
])
}
def runValdiationRust(dir) {
node('ubuntu') {
try {
cleanWs()
checkout scm
def testEnv
if (dir == 'vcx/libvcx') {
testEnv = dockerBuild("static-validation-libvcx", "vcx/ci/ubuntu.dockerfile .")
} else {
testEnv = dockerBuild("static-validation-libindy", "libindy/ci/ubuntu.dockerfile libindy/ci")
}
testEnv.inside {
//FIXME waiting on IS-823
//sh "cargo clippy --manifest-path ${dir}/Cargo.toml"
sh "cargo clippy --manifest-path ${dir}/Cargo.toml -- -W clippy::style -W clippy::correctness -W clippy::complexity -W clippy::perf"
}
} finally {
cleanWs()
}
}
}
def getBuildPoolVerOptions(pool_type, plenum_ver, anoncreds_ver, node_ver) {
if (pool_type != null && plenum_ver != null && anoncreds_ver != null && node_ver != null) {
return "--build-arg=indy_stream=${pool_type} --build-arg indy_plenum_ver=${plenum_ver} --build-arg indy_anoncreds_ver=${anoncreds_ver} --build-arg indy_node_ver=${node_ver}"
} else {
return ""
}
}
def getUserUid() {
return sh(returnStdout: true, script: 'id -u').trim()
}
def dockerBuild(name, file = 'ci/ubuntu.dockerfile ci', customParams = '') {
return docker.build("$name-test", "--build-arg uid=${getUserUid()} ${customParams} -f $file")
}
def dockerClean(env_name, network_name) {
try {
try {
sh returnStatus: true, script: "docker ps --format '{{.ID}}' --filter network=${network_name} | xargs docker rm -f"
//TODO: FIXME
} catch (error) {
echo "${env_name} Test: error while force clean-up network ${network_name} - ${error}"
}
try {
echo "${env_name} Test: remove pool network ${network_name}"
sh returnStatus: true, script: "docker network rm ${network_name}"
} catch (error) {
echo "${env_name} Test: error while delete ${network_name} - ${error}"
}
}
finally {
sh "docker container prune -f"
sh "docker network prune -f"
}
}
def openPool(env_name, network_name, pool_type = null, pool_ver = null, plenum_ver = null, anoncreds_ver = null, node_ver = null) {
echo "${env_name} Test: Clean docker"
dockerClean(env_name, network_name)
echo "${env_name} Test: Create docker network (${network_name}) for nodes pool and test image"
sh "docker network create --subnet=10.0.0.0/8 ${network_name}"
echo "${env_name} Test: Build docker image for nodes pool ver. ${pool_ver}"
echo "${env_name} Test: Building nodes pool for versions: plenum ${plenum_ver}, anoncreds ${anoncreds_ver}, node ${node_ver}"
verOptions = getBuildPoolVerOptions(pool_type, plenum_ver, anoncreds_ver, node_ver)
def poolEnv = dockerBuild("indy_pool_${pool_ver}", 'ci/indy-pool.dockerfile ci',
"--build-arg pool_ip=10.0.0.2 ${verOptions}")
echo "${env_name} Test: Run nodes pool"
return poolEnv.run("--ip=\"10.0.0.2\" --network=${network_name}")
}
def closePool(env_name, network_name, poolInst) {
echo "${env_name} Test: Cleanup"
try {
echo "${env_name} Test: stop pool"
poolInst.stop()
} catch (error) {
echo "${env_name} Tests: error while stop pool ${error}"
}
finally {
dockerClean(env_name, network_name)
}
step([$class: 'WsCleanup'])
}
String getSrcVersion(folder) {
if (testReleaseVersion) {
return testReleaseVersion
} else {
commit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
def version = sh(returnStdout: true, script: "wget -q https://raw.githubusercontent.com/hyperledger/indy-sdk/$commit/$folder/Cargo.toml -O - | grep -E '^version =' | head -n1 | cut -f2 -d= | cut -f2 -d '\"'").trim()
return version
}
}
def linuxTesting(file, env_name, network_name) {
def full_testing = runAllTests(env_name)
parallel([
failFast : true,
"${env_name} Test: build and test libindy": {
node('ubuntu') {
cleanWs()
linuxLibindyBuild(file, env_name, network_name, full_testing)
}
},
"${env_name} Test: test other components" : {
waitUntil {
libindyBuildFinished[env_name]
}
def jobs = [
"${env_name}-cli-test": {
linuxModuleTesting(file, env_name, network_name, this.&linuxCLITesting)
},
"${env_name}-vcx-test": {
vcxTesting(file, env_name, network_name, full_testing)
}
]
if (full_testing) {
jobs["${env_name}-rust-test"] = {
linuxModuleTesting(file, env_name, network_name, this.&linuxRustTesting)
}
jobs["${env_name}-java-test"] = {
linuxModuleTesting(file, env_name, network_name, this.&linuxJavaTesting)
}
jobs["${env_name}-python-test"] = {
linuxModuleTesting(file, env_name, network_name, this.&linuxPythonTesting)
}
jobs["${env_name}-nodejs-test"] = {
linuxModuleTesting(file, env_name, network_name, this.&linuxNodejsTesting)
}
}
parallel(jobs)
},
])
}
def vcxTesting(file, env_name, network_name, full_testing) {
parallel([
failFast : true,
"${env_name} Test: build and test libvcx" : {
node('ubuntu') {
cleanWs()
linuxVcxBuild(file, env_name, network_name)
}
},
"${env_name} Test: test other vcx components": {
if (full_testing) {
waitUntil {
libvcxBuildFinished[env_name]
}
def jobs = [
"${env_name}-vcx-nodejs-test": {
linuxModuleTesting(file, env_name, network_name, this.&linuxVcxNodejsTesting)
},
"${env_name}-vcx-java-test" : {
linuxModuleTesting(file, env_name, network_name, this.&linuxVcxJavaTesting)
},
"${env_name}-vcx-python-test": {
linuxModuleTesting(file, env_name, network_name, this.&linuxVcxPythonTesting)
}
]
parallel(jobs)
}
},
])
}
def linuxLibindyBuild(file, env_name, network_name, full_testing) {
def poolInst
try {
echo "${env_name} Test: Checkout csm"
checkout scm
poolInst = openPool(env_name, network_name)
def testEnv = buildTestEnv(file, env_name)
testEnv.inside {
echo "${env_name} Libindy Test: Build"
sh '''
cd libindy
cargo build --release --features "fatal_warnings sodium_static"
'''
stash includes: 'libindy/target/release/libindy.so,libindy/target/release/libindy.a', name: "LibindyBuildResult${env_name}"
}
sh "cp libindy/target/release/libindy.so wrappers/java/lib"
sh "cp libindy/target/release/libindy.so wrappers/python"
sh "cp libindy/target/release/libindy.so wrappers/rust"
sh "cp libindy/target/release/libindy.so wrappers/nodejs"
sh "cp libindy/target/release/libindy.so cli"
sh "cp libindy/target/release/libindy.so libnullpay"
sh "cp libindy/target/release/libindy.so vcx/libvcx"
sh "cp libindy/target/release/libindy.so vcx/wrappers/node"
sh "cp libindy/target/release/libindy.so vcx/wrappers/java"
sh "cp libindy/target/release/libindy.so vcx/wrappers/python3"
sh "cp libindy/target/release/libindy.so vcx/dummy-cloud-agent"
testEnv.inside {
echo "${env_name} Libnullpay Test: Build"
sh '''
cd libnullpay
LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo build --release
'''
stash includes: 'libnullpay/target/release/libnullpay.so', name: "LibnullpayBuildResult${env_name}"
}
sh "cp libnullpay/target/release/libnullpay.so cli"
sh "cp libnullpay/target/release/libnullpay.so vcx/libvcx"
sh "cp libnullpay/target/release/libnullpay.so vcx/wrappers/node"
sh "cp libnullpay/target/release/libnullpay.so vcx/wrappers/java"
sh "cp libnullpay/target/release/libnullpay.so vcx/wrappers/python3"
stash includes: 'wrappers/java/lib/libindy.so', name: "LibindyJavaSO${env_name}"
stash includes: 'wrappers/python/libindy.so', name: "LibindyPythonSO${env_name}"
stash includes: 'wrappers/rust/libindy.so', name: "LibindyRustSO${env_name}"
stash includes: 'wrappers/nodejs/libindy.so', name: "LibindyNodejsSO${env_name}"
stash includes: 'cli/libindy.so', name: "LibindyCliSO${env_name}"
stash includes: 'cli/libnullpay.so', name: "LibnullpayCliSO${env_name}"
stash includes: 'vcx/libvcx/libindy.so,vcx/libvcx/libnullpay.so', name: "VCXLibindyAndLibnullpaySO${env_name}"
stash includes: 'vcx/wrappers/node/libindy.so,vcx/wrappers/node/libnullpay.so', name: "VcxNodeLibindyAndLibnullpaySO${env_name}"
stash includes: 'vcx/wrappers/java/libindy.so,vcx/wrappers/java/libnullpay.so', name: "VcxJavaLibindyAndLibnullpaySO${env_name}"
stash includes: 'vcx/wrappers/python3/libindy.so,vcx/wrappers/python3/libnullpay.so', name: "VcxPythonLibindyAndLibnullpaySO${env_name}"
stash includes: 'vcx/dummy-cloud-agent/libindy.so', name: "LibindyCloudAgentSO${env_name}"
libindyBuildFinished[env_name] = true
testEnv.inside("--network=${network_name}") {
echo "${env_name} Libindy Test: Test Libindy submodules"
for (component in ["libindy/indy-api-types", "libindy/indy-utils", "libindy/indy-wallet"]) {
testLibindyComponent(component)
}
echo "${env_name} Libindy Test: Test"
def features_args = full_testing ? "--features sodium_static" : "--features \"sodium_static only_high_cases\""
sh """
cd libindy
RUST_BACKTRACE=1 cargo test --release --no-run ${features_args}
RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release ${features_args}
"""
}
echo "${env_name} Libnullpay Test: Test"
testEnv.inside("--network=${network_name}") {
sh '''
cd libnullpay
LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo test --no-run --release
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=debug RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release
'''
}
}
finally {
closePool(env_name, network_name, poolInst)
}
}
def testLibindyComponent(directory) {
sh """
cd ${directory}
RUST_BACKTRACE=1 cargo test --release --no-run
RUST_BACKTRACE=1 RUST_LOG=indy::=debug,zmq=trace RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release
"""
}
def linuxVcxBuild(file, env_name, network_name) {
def poolInst
try {
echo "${env_name} Test: Checkout csm"
checkout scm
poolInst = openPool(env_name, network_name)
def testEnv = buildTestEnv(file, env_name)
unstash name: "VCXLibindyAndLibnullpaySO${env_name}"
echo "${env_name} Libvcx Test: Build"
testEnv.inside {
sh '''
cd vcx/libvcx
LIBRARY_PATH=./ cargo build --release --features fatal_warnings
'''
stash includes: 'vcx/libvcx/target/release/libvcx.so', name: "LibvcxBuildResult${env_name}"
}
sh "cp vcx/libvcx/target/release/libvcx.so vcx/wrappers/node"
sh "cp vcx/libvcx/target/release/libvcx.so vcx/wrappers/java"
sh "cp vcx/libvcx/target/release/libvcx.so vcx/wrappers/python3"
stash includes: 'vcx/wrappers/node/libvcx.so', name: "VcxNodeLibvcxSO${env_name}"
stash includes: 'vcx/wrappers/java/libvcx.so', name: "VcxJavaLibvcxSO${env_name}"
stash includes: 'vcx/wrappers/python3/libvcx.so', name: "VcxPythonLibvcxSO${env_name}"
libvcxBuildFinished[env_name] = true
sh "cp vcx/libvcx/libindy.so vcx/dummy-cloud-agent"
testEnv.inside("--network=${network_name}") {
sh '''
cd vcx/dummy-cloud-agent
sed -i 's/\\("protocol_type": "\\)2.0/\\11.0/' config/sample-config.json
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy=info cargo run config/sample-config.json &
'''
echo "${env_name} Libvcx Test: Run tests"
sh '''
cd vcx/libvcx
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=vcx=debug,indy=debug RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release --features "pool_tests agency"
'''
}
testEnv.inside("--network=${network_name}") {
sh '''
cd vcx/dummy-cloud-agent
sed -i 's/\\("protocol_type": "\\)1.0/\\12.0/' config/sample-config.json
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy=info cargo run config/sample-config.json &
'''
echo "${env_name} Libvcx Test: Run vcx demo test for protocol version 2.0"
// TODO in Rust 1.39.0 there was a problem with test name before "--". Temporary put test name after it.
sh '''
cd vcx/libvcx
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=vcx=debug,indy=debug RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release --features "pool_tests agency_v2" -- tests::test_real_proof_for_protocol_type_v2 --exact
LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=vcx=debug,indy=debug RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release --features "pool_tests aries" -- v3::test::aries_demo --exact
'''
}
}
finally {
closePool(env_name, network_name, poolInst)
}
}
def linuxJavaTesting(env_name, network_name, testEnv) {
unstash name: "LibindyJavaSO${env_name}"
dir('wrappers/java') {
testEnv.inside("--ip=\"10.0.0.3\" --network=${network_name}") {
echo "${env_name} Libindy Test: Test java wrapper"
sh "RUST_LOG=indy::=debug TEST_POOL_IP=10.0.0.2 mvn clean test"
}
}
}
def linuxPythonTesting(env_name, network_name, testEnv) {
unstash name: "LibindyPythonSO${env_name}"
dir('wrappers/python') {
testEnv.inside("--ip=\"10.0.0.3\" --network=${network_name}") {
echo "${env_name} Libindy Test: Test python wrapper"
sh '''
python3 -m pip install --user -e .[test]
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_LOG=indy::=debug TEST_POOL_IP=10.0.0.2 python3 -m pytest
'''
}
}
}
def linuxCLITesting(env_name, network_name, testEnv) {
unstash name: "LibindyCliSO${env_name}"
unstash name: "LibnullpayCliSO${env_name}"
echo "${env_name} Indy Cli Test: tests"
testEnv.inside("--network=${network_name}") {
sh '''
cd cli
LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo build --release --features fatal_warnings
LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo test --release --features "nullpay_plugin" --no-run
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy::=debug RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release --features "nullpay_plugin"
'''
stash includes: 'cli/target/release/indy-cli', name: "IndyCliBuildResult${env_name}"
}
}
def linuxRustTesting(env_name, network_name, testEnv) {
unstash name: "LibindyRustSO${env_name}"
dir('wrappers/rust') {
testEnv.inside("--network=${network_name}") {
echo "${env_name} Indy Rust wrapper Test: Build"
sh 'LIBRARY_PATH=./ RUST_BACKTRACE=1 cargo test --release --no-run'
echo "${env_name} Indy Rust wrapper Test: Run tests"
sh 'LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_BACKTRACE=1 RUST_LOG=indy::=debug RUST_TEST_THREADS=1 TEST_POOL_IP=10.0.0.2 cargo test --release'
}
}
}
def linuxNodejsTesting(env_name, network_name, testEnv) {
unstash name: "LibindyNodejsSO${env_name}"
testEnv.inside("--network=${network_name}") {
echo "${env_name} Libindy Test: Test nodejs wrapper"
sh '''
cd wrappers/nodejs
npm run prepare
npm install
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} RUST_LOG=indy::=debug TEST_POOL_IP=10.0.0.2 npm test
'''
}
}
def linuxVcxNodejsTesting(env_name, network_name, testEnv) {
unstash name: "VcxNodeLibvcxSO${env_name}"
unstash name: "VcxNodeLibindyAndLibnullpaySO${env_name}"
testEnv.inside("--network=${network_name}") {
echo "${env_name} Vcx Test: Test nodejs wrapper"
sh '''
cd vcx/wrappers/node/
npm i
npm run compile
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} LIBVCX_PATH=./ npm test
'''
}
}
def linuxVcxJavaTesting(env_name, network_name, testEnv) {
unstash name: "VcxJavaLibvcxSO${env_name}"
unstash name: "VcxJavaLibindyAndLibnullpaySO${env_name}"
dir('vcx/wrappers/java') {
echo "${env_name} Vcx Test: Test java wrapper"
testEnv.inside("--network=${network_name}") {
sh 'LIBRARY_PATH=./ LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} ./gradlew --no-daemon test'
}
}
}
def linuxVcxPythonTesting(env_name, network_name, testEnv) {
unstash name: "VcxPythonLibvcxSO${env_name}"
unstash name: "VcxPythonLibindyAndLibnullpaySO${env_name}"
dir('vcx/wrappers/python3') {
testEnv.inside {
echo "${env_name} Vcx Test: Test python wrapper"
sh '''
python3 -m pip install --user pytest==3.6.4 pytest-asyncio==0.10.0
LD_LIBRARY_PATH=./:${LD_LIBRARY_PATH} python3 -m pytest -s
'''
}
}
}
def windowsTesting() {
node('win2016') {
stage('Windows Test') {
def ws_path = "workspace/${env.JOB_NAME}".replace(' ', '_')
ws(ws_path) {
cleanWs()
try {
echo "Windows Test: Checkout scm"
checkout scm
echo "Windows Test: Run Indy pool"
bat "docker -H $INDY_SDK_SERVER_IP build --build-arg pool_ip=$INDY_SDK_SERVER_IP -f ci/indy-pool.dockerfile -t indy_pool ci"
bat "docker -H $INDY_SDK_SERVER_IP run -d --network host --name indy_pool -p 9701-9708:9701-9708 indy_pool"
setupRust()
dir('libindy') {
echo "Windows Test: Download prebuilt dependencies"
bat 'wget -O prebuilt.zip "https://repo.sovrin.org/windows/libindy/deps/indy-sdk-deps.zip"'
bat 'unzip prebuilt.zip -d prebuilt'
echo "Windows Libindy Test: Build"
withEnv([
"INDY_PREBUILT_DEPS_DIR=$WORKSPACE\\libindy\\prebuilt",
"INDY_CRYPTO_PREBUILT_DEPS_DIR=$WORKSPACE\\libindy\\prebuilt",
"MILAGRO_DIR=$WORKSPACE\\libindy\\prebuilt",
"LIBZMQ_PREFIX=$WORKSPACE\\libindy\\prebuilt",
"SODIUM_LIB_DIR=$WORKSPACE\\libindy\\prebuilt",
"OPENSSL_DIR=$WORKSPACE\\libindy\\prebuilt",
"PATH=$WORKSPACE\\libindy\\prebuilt\\lib;$PATH",
"RUST_BACKTRACE=1"
]) {
bat "cargo build --release --features fatal_warnings"
bat "cargo test --release --no-run"
echo "Windows Libindy Test: Run tests"
withEnv([
"RUST_TEST_THREADS=1",
"RUST_LOG=indy::=debug,zmq=trace",
"TEST_POOL_IP=$INDY_SDK_SERVER_IP"
]) {
bat "cargo test --release"
}
}
stash includes: 'target/release/*.dll,target/release/*.dll.lib', name: 'LibindyWindowsBuildResult'
}
dir('libnullpay') {
echo "Windows Libnullpay Test: Build"
withEnv([
"RUST_BACKTRACE=1"
]) {
bat "cargo build --release --features fatal_warnings"
bat "cargo test --release --no-run"
echo "Windows Libnullpay Test: Run tests"
withEnv([
"RUST_TEST_THREADS=1",
"RUST_LOG=indy::=debug,zmq=trace",
"TEST_POOL_IP=$INDY_SDK_SERVER_IP",
"PATH=$WORKSPACE\\libindy\\target\\release;$PATH",
]) {
bat "cargo test --release"
}
}
stash includes: 'target/release/*.dll,target/release/*.dll.lib', name: 'LibnullpayWindowsBuildResult'
}
bat "PowerShell.exe \"Copy-Item $WORKSPACE/libnullpay/target/release/nullpay.dll -Destination $WORKSPACE/cli\""
dir('cli') {
bat "PowerShell.exe \"&{(Get-Content -Path docker_pool_transactions_genesis -Raw) -replace '10\\.0\\.0\\.2','$INDY_SDK_SERVER_IP'} | Set-Content -Path docker_pool_transactions_genesis\""
def featuresArgs = ''
// def featuresArgs = '--features "nullpay_plugin"' // disabled because of IS-1109
echo "Windows Indy Cli Test: Build"
withEnv([
"RUST_BACKTRACE=1"
]) {
bat "cargo build --release --features fatal_warnings"
echo "Windows Indy Cli Test: Build tests"
bat "cargo test --release $featuresArgs --no-run"
echo "Windows Indy Cli Test: Run tests"
withEnv([
"RUST_TEST_THREADS=1",
"RUST_LOG=indy::=debug,zmq=trace",
"TEST_POOL_IP=$INDY_SDK_SERVER_IP"
]) {
bat "cargo test --release $featuresArgs"
}
}
stash includes: 'target/release/indy-cli.exe,target/release/*.dll', name: 'IndyCliWindowsBuildResult'
}
bat "PowerShell.exe \"Copy-Item $WORKSPACE/libnullpay/target/release/nullpay.dll -Destination $WORKSPACE/vcx/libvcx\""
dir('vcx/libvcx') {
echo "Windows Libvcx Test: Build"
// FIXME remove that once https://jira.hyperledger.org/browse/IS-1127 is resolved
bat """
PowerShell.exe "&{(Get-Content -Path src/settings.rs -Raw) -replace '/tmp/test_init.json','./test_init.json'} | Set-Content -Path src/settings.rs"
"""
withEnv([
"OPENSSL_DIR=$WORKSPACE\\libindy\\prebuilt",
"RUST_BACKTRACE=1"
]) {
bat "cargo build --release --features fatal_warnings"
bat "cargo test --release --no-run"
echo "Windows Libvcx Test: Run tests"
withEnv([
"RUST_TEST_THREADS=1",
"RUST_LOG=vcx=debug,indy::=debug",
"PATH=$WORKSPACE\\libindy\\target\\release;$PATH",
]) {
bat "cargo test --release"
}
}
stash includes: 'target/release/*.dll,target/release/*.dll.lib', name: 'LibvcxWindowsBuildResult'
}
} finally {
try {
bat "docker -H $INDY_SDK_SERVER_IP stop indy_pool"
} catch (ignore) {
}
try {
bat "docker -H $INDY_SDK_SERVER_IP rm indy_pool"
} catch (ignore) {
}
cleanWs()
}
}
cleanWs()
}
}
}
def runAllTests(env_name) {
return env_name == Ubuntu18
// if (env_name == Ubuntu18) { TODO: FIXME install python in Ubuntu 16.04?
// return true
// }
// return (env.BRANCH_NAME == 'rc')
}
def ubuntuTesting() {
stage('Ubuntu Test') {
parallel([
"ubuntu:16.04": {
linuxTesting("ci/ubuntu.dockerfile ci", Ubuntu16, "pool_network")
},
"ubuntu:18.04": {
linuxTesting("ci/ubuntu18.dockerfile ci", Ubuntu18, "pool_network")
}
])
}
}
def linuxAndroidOnEmulatorTesting(env_name, network_name, testEnv) {
sh 'chmod -R 755 libindy/ci/*.sh'
sh 'chmod -R 755 libindy/*.sh'
def emu_arch = "x86"
echo "${env_name} Libindy Test: Test on ${emu_arch} emulator"
testEnv.inside("--network=${network_name}") {
sh "cd libindy && ./android.test.sh ${emu_arch} --release"
}
}
def iosTesting() {
def setupRustIOS = {
sh "rustup target add aarch64-apple-ios x86_64-apple-ios"
}
def cleanSimulators = {
sh '''
xcrun simctl list devices | grep 'IndySDK' | awk '{print $4}' | sed -n 's/(\\(.*\\))/\\1/p'
xcrun simctl list devices | grep 'IndySDK' | awk '{print $4}' | sed -n 's/(\\(.*\\))/\\1/p' | xargs xcrun simctl delete
'''
}
def createSimulators = {
sh '''
xcrun simctl create "iPhone X IndySDK" "iPhone X" "11.2"
'''
}
node('macos') {
cleanWs()
stage('iOS Test') {
try {
echo "iOS Test: Checkout scm"
checkout scm
echo "iOS Test: setup rust, brew and simulators"
//FIXME restore `setupRust()`
//FIXME We downgrade rust for iOS build as 1.46.0 forces building cdylib crate that causes linking errors.
//FIXME See https://github.com/rust-lang/rust/issues/79373 for details.
//FIXME It is fixed in nightly already and we will switch to 1.49 after it is released.
sh "rustup default 1.45.0"
setupRustIOS()
setupBrewPackages()
cleanSimulators()
createSimulators()
withEnv([
"BUNDLE_PATH=$HOME/.gem.indy_sdk"
]) {
dir('wrappers/ios') {
echo "iOS Test: Installing ruby, bundler and gems"
sh '''
rbenv install -s $(cat .ruby-version)
gem install bundler
bundler install
bundler list
'''
}
dir('wrappers/ios/libindy-pod') {
echo "iOS Test: Installing dependencies (pods)"
sh "bundler exec pod install --repo-update"
}
echo "iOS Test: Building Libindy Universal iOS Pod"
buildIOSPod("libindy", "")
echo "iOS Test: Running pool"
macosRunPool("indy_pool")
// FIXME replace this hack (manually rewrite installed pod)
sh "rm -f wrappers/ios/libindy-pod/Pods/libindy/*.[ah]"
sh "cp libindy/out_pod/*.[ah] wrappers/ios/libindy-pod/Pods/libindy"
// FIXME restore Xcode testing
// dir('wrappers/ios/libindy-pod') {
// echo "iOS Test: Testing"
// sh "xcodebuild test -workspace Indy.xcworkspace -scheme Indy-demo -destination 'platform=iOS Simulator,name=iPhone X IndySDK,OS=11.2'"
// }
stash includes: 'libindy/out_pod/libindy.tar.gz', name: "LibindyUniversalIOSPod"
echo "iOS Test: Building Libindy iOS Pod for aarch64-apple-ios"
buildIOSPod("libindy", "aarch64-apple-ios")
stash includes: 'libindy/out_pod/libindy.tar.gz', name: "LibindyMiniIOSPod"
echo "iOS Test: Building Libnullpay Universal iOS Pod"
buildIOSPod("libnullpay", "")
stash includes: 'libnullpay/out_pod/libnullpay.tar.gz', name: "LibnullpayUniversalIOSPod"
echo "iOS Test: Building Libnullpay iOS Pod for aarch64-apple-ios"
buildIOSPod("libnullpay", "aarch64-apple-ios")
stash includes: 'libnullpay/out_pod/libnullpay.tar.gz', name: "LibnullpayMiniIOSPod"
}
} finally {
try {
cleanSimulators()
} catch (ignore) {
}
macosStopPool("indy_pool")
step([$class: 'WsCleanup'])
}
}
}
}
def buildIOSPod(packageName, targets) {
sh 'chmod -R 777 ci'
sh "rm -rf ${packageName}/out_pod"
echo "iOS Test: build ${packageName} pod"
sh "ci/ios-build.sh $packageName $targets"
}
def centosTesting() {
stage('Centos Test') {
linuxTesting("ci/centos.dockerfile ci", "Centos", "pool_network")
}
}
def macosTesting() {
node('macos') {
cleanWs()
stage('MacOS Test') {
def pool_name = "indy_pool"
try {
echo "MacOS Test: Checkout scm"
checkout scm
setupRust()
setupBrewPackages()
macosRunPool(pool_name)
macosModuleBuildingAndTest('libindy')
stash includes: 'libindy/target/release/libindy.dylib,libindy/target/release/libindy.a', name: 'LibindyMacosBuildResult'
sh "cp libindy/target/release/libindy.dylib libnullpay"
sh "cp libindy/target/release/libindy.dylib vcx/libvcx"
sh "cp libindy/target/release/libindy.dylib cli"
macosModuleBuildingAndTest('libnullpay')
stash includes: 'libnullpay/target/release/libnullpay.dylib,libnullpay/target/release/libnullpay.a', name: 'LibnullpayMacosBuildResult'
sh "cp libnullpay/target/release/libnullpay.dylib vcx/libvcx"
macosModuleBuildingAndTest('vcx/libvcx')
stash includes: 'vcx/libvcx/target/release/libvcx.dylib,vcx/libvcx/target/release/libvcx.a', name: 'LibvcxMacosBuildResult'
sh "sed -i'.original' -e 's/10.0.0.2/127.0.0.1/g' cli/docker_pool_transactions_genesis"
macosModuleBuildingAndTest('cli')
stash includes: 'cli/target/release/indy-cli', name: 'IndyCliMacosBuildResult'
//TODO wrappers testing
} finally {
step([$class: 'WsCleanup'])
}
}
}
}
def macosRunPool(pool_name) {
sh "docker rm -f ${pool_name} || true"
sh "docker build -f ci/indy-pool.dockerfile -t ${pool_name} ci"
sh "docker run -d --name ${pool_name} -p 9701-9708:9701-9708 ${pool_name}"
}
def macosStopPool(pool_name) {
try {
sh "docker stop ${pool_name}"
} catch (ignore) {
}
try {
sh "docker rm ${pool_name}"
} catch (ignore) {
}
}
def macosModuleBuildingAndTest(library) {
dir(library) {
echo "MacOS ${library} Testing: Build"
sh "LIBRARY_PATH=./ cargo build --release --features fatal_warnings"
echo "MacOS ${library} Testing: Run Tests"
sh "LIBRARY_PATH=./ cargo test --release --no-run"
sh "LIBRARY_PATH=./ RUST_TEST_THREADS=1 cargo test --release"
}
}
def centosPublishing() {
def libindyVersion
def env_name = Centos
node('ubuntu') {
cleanWs()
stage("Publish ${env_name} Files") {
try {
echo "Publish ${env_name} files: Checkout scm"
checkout scm
libindyVersion = getSrcVersion("libindy")
echo "Publish ${env_name}: Build docker image"
def testEnv = dockerBuild('indy-sdk', 'libindy/ci/centos.dockerfile ci')
libindyRpmPublishing(testEnv, libindyVersion, env_name)
libnullpayRpmPublishing(testEnv, env_name)
libvcxRpmPublishing(testEnv, env_name)
indyCliRpmPublishing(testEnv, env_name)
}
finally {
echo "Publish ${env_name} files: Cleanup"
step([$class: 'WsCleanup'])
}
}
}
return libindyVersion
}
def libindyRpmPublishing(testEnv, version, env_name) {
echo 'Publish Libindy rpm files'
rpmPublishing(testEnv, "libindy", "libindy", version, "LibindyBuildResult${env_name}")
}
def libnullpayRpmPublishing(testEnv, env_name) {
echo 'Publish Libnullpay rpm files'
def libnullpayVersion = getSrcVersion("libnullpay")
rpmPublishing(testEnv, "libnullpay", "libnullpay", libnullpayVersion, "LibnullpayBuildResult${env_name}")
}
def libvcxRpmPublishing(testEnv, env_name) {
echo 'Publish Libvcx rpm files'