forked from hyperledger-archives/indy-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
143 lines (121 loc) · 3.71 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
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
#!groovy
@Library('SovrinHelpers') _
name = 'indy-sdk'
def err
def publishBranch = (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'devel')
try {
// ALL BRANCHES: master, devel, PRs
// 1. TEST
stage('Test') {
parallel 'ubuntu-test': {
node('ubuntu') {
stage('Ubuntu Test') {
testUbuntu()
}
}
}
}
if (!publishBranch) {
echo "${env.BRANCH_NAME}: skip publishing"
return
}
// 2. PUBLISH TO Cargo
stage('Publish to Cargo') {
node('ubuntu') {
publishToCargo()
}
}
} catch (e) {
currentBuild.result = "FAILED"
node('ubuntu-master') {
sendNotification.fail([slack: publishBranch])
}
err = e
} finally {
if (err) {
throw err
}
currentBuild.result = "SUCCESS"
if (publishBranch) {
node('ubuntu-master') {
sendNotification.success(name)
}
}
}
def testUbuntu() {
def poolInst
def network_name = "pool_network"
try {
echo 'Ubuntu Test: Checkout csm'
checkout scm
echo "Ubuntu 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 'Ubuntu Test: Build docker image for nodes pool'
def poolEnv = dockerHelpers.build('indy_pool', 'ci/indy-pool.dockerfile ci')
echo 'Ubuntu Test: Run nodes pool'
poolInst = poolEnv.run("--ip=\"10.0.0.2\" --network=${network_name}")
echo 'Ubuntu Test: Build docker image'
def testEnv = dockerHelpers.build(name)
testEnv.inside("--ip=\"10.0.0.3\" --network=${network_name}") {
echo 'Ubuntu Test: Test'
sh 'chmod -R 777 /home/indy/'
sh 'cargo update'
try {
sh 'RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test --features "interoperability_tests"'
/* TODO FIXME restore after xunit will be fixed
sh 'RUST_TEST_THREADS=1 cargo test-xunit'
*/
}
finally {
/* TODO FIXME restore after xunit will be fixed
junit 'test-results.xml'
*/
}
}
}
finally {
echo 'Ubuntu Test: Cleanup'
try {
sh "docker network inspect ${network_name}"
} catch (ignore) {
}
try {
if (poolInst) {
echo 'Ubuntu Test: stop pool'
poolInst.stop()
}
} catch (err) {
echo "Ubuntu Tests: error while stop pool ${err}"
}
try {
echo "Ubuntu Test: remove pool network ${network_name}"
sh "docker network rm ${network_name}"
} catch (err) {
echo "Ubuntu Test: error while delete ${network_name} - ${err}"
}
step([$class: 'WsCleanup'])
}
}
def publishToCargo() {
try {
echo 'Publish to Cargo: Checkout csm'
checkout scm
echo 'Publish to Cargo: Build docker image'
def testEnv = dockerHelpers.build(name)
testEnv.inside {
echo 'Update version'
def suffix = env.BRANCH_NAME == 'master' ? env.BUILD_NUMBER : 'devel-' + env.BUILD_NUMBER;
sh 'chmod -R 777 ci'
sh "ci/update-package-version.sh $suffix"
withCredentials([string(credentialsId: 'cargoSecretKey', variable: 'SECRET')]) {
sh 'cargo login $SECRET'
}
sh 'cargo package --allow-dirty'
sh 'cargo publish --allow-dirty'
}
}
finally {
echo 'Publish to cargo: Cleanup'
step([$class: 'WsCleanup'])
}
}