forked from LiskHQ/lisk-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
160 lines (153 loc) · 4.8 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
@Library('lisk-jenkins') _
properties([disableConcurrentBuilds(), pipelineTriggers([])])
pipeline {
agent { node { label 'lisk-desktop' } }
options {
timeout(time: 45, unit: 'MINUTES')
ansiColor('xterm')
}
parameters {
string(name: 'CORE_VERSION', defaultValue: '4.0.0-rc.3')
string(name: 'SERVICE_BRANCH_NAME', defaultValue: 'release/0.7.0')
}
stages {
stage('install') {
steps {
nvm(getNodejsVersion()) {
sh '''
npm i -g yarn
yarn --cwd app && yarn
'''
}
}
}
stage('lint') {
steps {
ansiColor('xterm') {
nvm(getNodejsVersion()) {
sh '''
rm -rf lisk-service/ # linting will fail otherwise
yarn run lint
'''
}
}
}
}
stage('build') {
steps {
parallel (
"prod": {
nvm(getNodejsVersion()) {
withEnv(["DEFAULT_NETWORK=testnet", "BUILD_NAME=build"]) {
sh '''
cp -R /home/lisk/fonts/basierCircle setup/react/assets/fonts
cp -R /home/lisk/fonts/gilroy setup/react/assets/fonts
yarn run build
'''
}
}
stash includes: 'app/build/', name: 'build'
},
"E2E": {
nvm(getNodejsVersion()) {
withEnv(["DEFAULT_NETWORK=customNode", "BUILD_NAME=buildE2E"]) {
sh '''
cp -R /home/lisk/fonts/basierCircle setup/react/assets/fonts
cp -R /home/lisk/fonts/gilroy setup/react/assets/fonts
yarn run build:e2e
# locally serve build
nohup npx serve -l 8081 ./app/buildE2E >serve.out 2>serve.err &
'''
}
}
stash includes: 'app/buildE2E/', name: 'buildE2E'
},
)
}
}
stage('deploy') {
agent { node { label 'explorer-www' } }
steps {
unstash 'build'
sh '''
mkdir -p /var/www/test/${JOB_NAME%/*}/$BRANCH_NAME
rsync -axl --delete $WORKSPACE/app/build/ /var/www/test/${JOB_NAME%/*}/$BRANCH_NAME/
rm -rf $WORKSPACE/app/build
'''
githubNotify context: 'Jenkins test deployment',
description: 'Commit was deployed to test',
status: 'SUCCESS',
targetUrl: "${HUDSON_URL}test/" + "${JOB_NAME}".tokenize('/')[0] + "/${BRANCH_NAME}"
}
}
stage('test') {
steps {
parallel (
// cypress
"end-to-end": {
dir('lisk-service') {
checkout([$class: 'GitSCM', branches: [[name: params.SERVICE_BRANCH_NAME ]], userRemoteConfigs: [[url: 'https://github.com/LiskHQ/lisk-service']]])
}
nvm(getNodejsVersion()) {
withEnv(["REACT_APP_MSW=true"]) {
wrap([$class: 'Xvfb']) {
sh '''
# lisk-core
npm i -g lisk-core@^4.0.0-rc.3
rm -rf ~/.lisk/
# lisk-core blockchain:import --force ./e2e/artifacts/blockchain.tar.gz
nohup lisk-core start --network=devnet --api-ws --api-host=0.0.0.0 --config ./e2e/artifacts/config.json --overwrite-config >lisk-core.out 2>lisk-core.err &
echo $! >lisk-core.pid
# lisk-service
cp -f lisk-service/docker/example.env lisk-service/.env
echo LISK_APP_WS=ws://host.docker.internal:7887 >>lisk-service/.env
make -C lisk-service build
make -C lisk-service up
## logs
# cat lisk-core.out
# echo "===== core error ===="
# cat lisk-core.err
# echo "======== service ======="
# docker ps
# wait for service to be up and running
sleep 10
set -e; while [[ $(curl -s --fail http://127.0.0.1:9901/api/v3/index/status | jq '.data.percentageIndexed') != 100 ]]; do echo waiting; sleep 10; done; set +e
curl --verbose http://127.0.0.1:9901/api/v3/network/status
curl --verbose http://127.0.0.1:9901/api/v3/blocks
PW_BASE_URL=http://127.0.0.1:8081/# \
yarn run cucumber:playwright:open
'''
}
}
}
},
// jest
"unit": {
nvm(getNodejsVersion()) {
sh 'ON_JENKINS=true yarn run test'
}
},
)
}
post {
failure {
archiveArtifacts artifacts: 'e2e/assets/', allowEmptyArchive: true
}
always {
sh '''
# kill lisk-service process
make -C lisk-service logs
make -C lisk-service down
# kill lisk-core process
kill $( cat lisk-core.pid ) || true
sleep 10
kill -9 $( cat lisk-core.pid ) || true
cat lisk-core.out
cat lisk-core.err
'''
}
}
}
}
}
// vim: filetype=groovy