This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
117 lines (112 loc) · 4.55 KB
/
Jenkinsfile
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
node {
stage('Get sources') {
checkout scm
}
stage('Get Git submodules') {
sh 'git submodule update --init --recursive'
}
stage('Build main image') {
sh 'cd cpp && docker build -f docker/k0.Dockerfile -t appliedblockchain/k0 .'
}
stage('Build app images') {
sh 'cd cpp && for IMAGE in setup server mtserver convert-vk; do docker build -f docker/$IMAGE.Dockerfile -t appliedblockchain/k0-$IMAGE .; done'
}
stage('ZKP setup') {
sh 'rm -rf /tmp/k0keys && mkdir /tmp/k0keys'
sh 'for circuit in commitment transfer addition withdrawal example; do docker run -v /tmp/k0keys:/tmp/k0keys appliedblockchain/k0-setup $circuit 4 /tmp/k0keys/${circuit}_pk /tmp/k0keys/${circuit}_vk & done; wait'
sh 'for circuit in commitment transfer addition withdrawal example; do docker run -v /tmp/k0keys:/tmp/k0keys appliedblockchain/k0-convert-vk /tmp/k0keys/${circuit}_vk /tmp/k0keys/${circuit}_vk_alt; done'
}
stage('lerna bootstrap') {
sh 'set +ex && export NVM_DIR="$HOME/.nvm" && . ~/.nvm/nvm.sh && nvm use v8 && set -ex && cd js && lerna bootstrap --no-ci'
}
stage('Reset Docker') {
sh 'docker stop $(docker ps -aq) || true'
sh 'docker rm $(docker ps -aq) || true'
sh 'docker rmi $(docker images --filter=reference="*k0chaincode*" -q) || true'
}
stage('Start server') {
sh '''
docker run -d --name k0server \
-v /tmp/k0keys/:/tmp/k0keys/:ro \
-p 4000:80 \
appliedblockchain/k0-server 4 \
/tmp/k0keys/commitment_pk /tmp/k0keys/commitment_vk \
/tmp/k0keys/addition_pk /tmp/k0keys/addition_vk \
/tmp/k0keys/transfer_pk /tmp/k0keys/transfer_vk \
/tmp/k0keys/withdrawal_pk /tmp/k0keys/withdrawal_vk \
/tmp/k0keys/example_pk /tmp/k0keys/example_vk \
80
'''
sh '''
set +ex
export NVM_DIR="$HOME/.nvm"
. ~/.nvm/nvm.sh && nvm use v8
set -ex
cd js/packages/k0-integration-tests-eth
node wait-for-server
'''
}
stage('Ethereum tests') {
sh 'cd js/packages/k0-integration-tests-eth && docker-compose -f docker-compose-ci.yml down'
sh 'cd js/packages/k0-integration-tests-eth && docker-compose -f docker-compose-ci.yml up -d'
sh 'set +ex && export NVM_DIR="$HOME/.nvm" && . ~/.nvm/nvm.sh && nvm use v8 && set -ex && cd js/packages/k0-integration-tests-eth && npm test'
sh 'cd js/packages/k0-integration-tests-eth && docker-compose -f docker-compose-ci.yml down'
}
stage('Fabric tests') {
sh '''
sudo rm -rf js/packages/k0-integration-tests-fabric/network/artefacts/*
docker run -v $PWD/js/packages/k0-integration-tests-fabric/network/artefacts:/artefacts \
-v ~/go/src/github.com/hyperledger/fabric:/opt/gopath/src/github.com/hyperledger/fabric:ro \
-v $PWD/go:/opt/gopath/src/github.com/appliedblockchain/k0/go:ro \
hyperledger/fabric-tools:1.2.0 \
peer chaincode package \
-n k0chaincode -v 1 \
-p github.com/appliedblockchain/k0/go/chaincode/cash \
/artefacts/k0chaincode.1.out
'''
sh '''
set +ex
export NVM_DIR="$HOME/.nvm"
. ~/.nvm/nvm.sh
nvm use v8
set -ex
cd js/packages/k0-integration-tests-fabric/network
CI=true ./start.sh
'''
sh '''
cd js/packages/k0-integration-tests-fabric/network
for org in alpha beta gamma bank
do
docker-compose run ${org}tools peer chaincode install /artefacts/k0chaincode.1.out
done
'''
sh '''
cd js/packages/k0-integration-tests-fabric
set +ex
export NVM_DIR="$HOME/.nvm"
. ~/.nvm/nvm.sh
nvm use v8
set -ex
CHAINCODE_ID=k0chaincode node instantiate
'''
sh '''
cd js/packages/k0-integration-tests-fabric
set +ex
export NVM_DIR="$HOME/.nvm"
. ~/.nvm/nvm.sh
nvm use v8
set -ex
CHAINCODE_ID=k0chaincode node_modules/.bin/mocha test
'''
sh '''
cd js/packages/k0-integration-tests-fabric/network
CI=true ./stop.sh
'''
}
stage('Stop server') {
sh '''
docker stop k0server
docker rm k0server
'''
}
}