This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Jenkinsfile
213 lines (205 loc) · 8.54 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
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
@Library('vega-shared-library') _
/* properties of scmVars (example):
- GIT_BRANCH:PR-40
- GIT_COMMIT:05a1c6fbe7d1ff87cfc40a011a63db574edad7e6
- GIT_PREVIOUS_COMMIT:5d02b46fdb653f789e799ff6ad304baccc32cbf9
- GIT_PREVIOUS_SUCCESSFUL_COMMIT:5d02b46fdb653f789e799ff6ad304baccc32cbf9
- GIT_URL:https://github.com/vegaprotocol/vegawallet.git
*/
def scmVars = null
def version = 'UNKNOWN'
def versionHash = 'UNKNOWN'
def commitHash = 'UNKNOWN'
pipeline {
agent any
options {
skipDefaultCheckout true
timestamps()
timeout(time: 45, unit: 'MINUTES')
}
parameters {
string( name: 'VEGA_CORE_BRANCH', defaultValue: '',
description: '''Git branch, tag or hash of the vegaprotocol/vega repository.
e.g. "develop", "v0.44.0" or commit hash. Default empty: use latests published version.''')
string( name: 'DATA_NODE_BRANCH', defaultValue: '',
description: '''Git branch, tag or hash of the vegaprotocol/data-node repository.
e.g. "develop", "v0.44.0" or commit hash. Default empty: use latests published version.''')
string( name: 'ETHEREUM_EVENT_FORWARDER_BRANCH', defaultValue: '',
description: '''Git branch, tag or hash of the vegaprotocol/ethereum-event-forwarder repository.
e.g. "main", "v0.44.0" or commit hash. Default empty: use latest published version.''')
string( name: 'DEVOPS_INFRA_BRANCH', defaultValue: 'master',
description: 'Git branch, tag or hash of the vegaprotocol/devops-infra repository')
string( name: 'VEGATOOLS_BRANCH', defaultValue: 'develop',
description: 'Git branch, tag or hash of the vegaprotocol/vegatools repository')
string( name: 'SYSTEM_TESTS_BRANCH', defaultValue: 'develop',
description: 'Git branch, tag or hash of the vegaprotocol/system-tests repository')
string( name: 'PROTOS_BRANCH', defaultValue: 'develop',
description: 'Git branch, tag or hash of the vegaprotocol/protos repository')
}
environment {
CGO_ENABLED = 0
GO111MODULE = 'on'
}
stages {
stage('Config') {
steps {
cleanWs()
sh 'printenv'
echo "params=${params}"
echo "isPRBuild=${isPRBuild()}"
script {
params = pr.injectPRParams()
}
echo "params (after injection)=${params}"
}
}
stage('Git clone') {
options { retry(3) }
steps {
script {
scmVars = checkout(scm)
versionHash = sh (returnStdout: true, script: "echo \"${scmVars.GIT_COMMIT}\"|cut -b1-8").trim()
version = sh (returnStdout: true, script: "git describe --tags 2>/dev/null || echo ${versionHash}").trim()
commitHash = getCommitHash()
}
echo "scmVars=${scmVars}"
echo "commitHash=${commitHash}"
}
}
stage('Download dependencies') {
options { retry(3) }
steps {
sh 'go mod download -x'
}
}
stage('Compile') {
environment {
LDFLAGS = "-X code.vegaprotocol.io/vegawallet/version.Version=\"${version}\" -X code.vegaprotocol.io/vegawallet/version.VersionHash=\"${versionHash}\""
}
failFast true
parallel {
stage('Linux build') {
environment {
GOOS = 'linux'
GOARCH = 'amd64'
OUTPUT = './build/vegawallet-linux-amd64'
}
options { retry(3) }
steps {
sh label: 'Compile', script: '''
go build -v -o "${OUTPUT}" -ldflags "${LDFLAGS}"
'''
sh label: 'Sanity check', script: '''
file ${OUTPUT}
${OUTPUT} version --output json
'''
}
}
stage('MacOS build') {
environment {
GOOS = 'darwin'
GOARCH = 'amd64'
OUTPUT = './build/vegawallet-darwin-amd64'
}
options { retry(3) }
steps {
sh label: 'Compile', script: '''
go build -v -o "${OUTPUT}" -ldflags "${LDFLAGS}"
'''
sh label: 'Sanity check', script: '''
file ${OUTPUT}
'''
}
}
stage('Windows build') {
environment {
GOOS = 'windows'
GOARCH = 'amd64'
OUTPUT = './build/vegawallet-windows-amd64'
}
options { retry(3) }
steps {
sh label: 'Compile', script: '''
go build -v -o "${OUTPUT}" -ldflags "${LDFLAGS}"
'''
sh label: 'Sanity check', script: '''
file ${OUTPUT}
'''
}
}
}
}
stage('Tests') {
parallel {
stage('unit tests') {
options { retry(3) }
steps {
sh 'go test -v ./... 2>&1 | tee unit-test-results.txt && cat unit-test-results.txt | go-junit-report > unit-test-report.xml'
junit checksName: 'Unit Tests', testResults: 'unit-test-report.xml'
}
}
stage('unit tests with race') {
environment {
CGO_ENABLED = 1
}
options { retry(3) }
steps {
sh 'go test -v -race ./... 2>&1 | tee unit-test-race-results.txt && cat unit-test-race-results.txt | go-junit-report > unit-test-race-report.xml'
junit checksName: 'Unit Tests with Race', testResults: 'unit-test-race-report.xml'
}
}
stage('linters') {
steps {
sh '''#!/bin/bash -e
golangci-lint run -v --config .golangci.toml
'''
}
}
stage('System Tests Network Smoke') {
steps {
script {
systemTestsCapsule ignoreFailure: !isPRBuild(),
vegaCore: params.VEGA_CORE_BRANCH,
dataNode: params.DATA_NODE_BRANCH,
vegawallet: commitHash,
vegatools: params.VEGATOOLS_BRANCH,
systemTests: params.SYSTEM_TESTS_BRANCH,
protos: params.PROTOS_BRANCH,
testMark: "network_infra_smoke"
}
}
}
stage('Capsule System Tests') {
steps {
script {
systemTestsCapsule vegaCore: params.VEGA_CORE_BRANCH,
dataNode: params.DATA_NODE_BRANCH,
vegawallet: commitHash,
devopsInfra: params.DEVOPS_INFRA_BRANCH,
vegatools: params.VEGATOOLS_BRANCH,
systemTests: params.SYSTEM_TESTS_BRANCH,
protos: params.PROTOS_BRANCH,
ignoreFailure: !isPRBuild()
}
}
}
}
}
}
post {
success {
retry(3) {
script {
slack.slackSendCISuccess name: 'Go Wallet CI', channel: '#tradingcore-notify'
}
}
}
unsuccessful {
retry(3) {
script {
slack.slackSendCIFailure name: 'Go Wallet CI', channel: '#tradingcore-notify'
}
}
}
}
}