forked from fetchai/ledger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
167 lines (142 loc) · 3.3 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
DOCKER_IMAGE_NAME = 'gcr.io/organic-storm-201412/fetch-ledger-develop:v0.2.0'
HIGH_LOAD_NODE_LABEL = 'ledger'
enum Platform
{
CLANG6('Clang 6', 'clang-6.0', 'clang++-6.0'),
GCC7 ('GCC 7', 'gcc', 'g++')
public Platform(label, cc, cxx)
{
this.label = label
this.env_cc = cc
this.env_cxx = cxx
}
public final String label
public final String env_cc
public final String env_cxx
}
enum Configuration
{
DEBUG ('Debug'),
RELEASE('Release')
public Configuration(label)
{
this.label = label
}
public final String label
}
// Only execute long-running tests on develop and merge branches
def should_run_slow_tests()
{
return BRANCH_NAME == 'develop' || BRANCH_NAME ==~ /^PR-\d+-merge$/
}
def static_analysis()
{
return {
stage('Static Analysis') {
node {
stage('SCM Static Analysis') {
checkout scm
}
stage('Run Static Analysis') {
docker.image(DOCKER_IMAGE_NAME).inside {
sh '''\
mkdir -p build-analysis
cd build-analysis
cmake ..
'''
sh './scripts/run_static_analysis.py build-analysis'
}
}
}
}
}
}
def SLOW_stage(name, steps)
{
if (should_run_slow_tests())
{
stage(name) { steps() }
}
}
def create_build(Platform platform, Configuration config)
{
def suffix = "${platform.label} ${config.label}"
def environment = {
return [
"CC=${platform.env_cc}",
"CXX=${platform.env_cxx}"
]
}
return {
stage(suffix) {
node(HIGH_LOAD_NODE_LABEL) {
timeout(120) {
stage("SCM ${suffix}") {
checkout scm
}
withEnv(environment()) {
docker.image(DOCKER_IMAGE_NAME).inside {
stage("Build ${suffix}") {
sh "./scripts/ci-tool.py -B ${config.label}"
}
stage("Unit Tests ${suffix}") {
sh "./scripts/ci-tool.py -T ${config.label}"
}
SLOW_stage("Integration Tests ${suffix}") {
sh "./scripts/ci-tool.py -I ${config.label}"
}
SLOW_stage("End-to-End Tests ${suffix}") {
sh './scripts/ci/install-test-dependencies.sh'
sh "./scripts/ci-tool.py -E ${config.label}"
}
}
}
}
}
}
}
}
def run_builds_in_parallel()
{
def stages = [:]
for (config in Configuration.values()) {
for (platform in Platform.values()) {
stages["${platform.label} ${config.label}"] = create_build(platform, config)
}
}
stages['Static Analysis'] = static_analysis()
stage('Build and Test') {
// Execute stages
parallel stages
}
}
def run_basic_checks()
{
stage('Basic Checks') {
node {
stage('SCM Basic Checks') {
checkout scm
}
docker.image(DOCKER_IMAGE_NAME).inside {
stage('License Check') {
sh './scripts/check_license_header.py'
}
stage('Style Check') {
sh './scripts/apply_style.py -ad'
}
stage('CMake Version Check') {
sh './scripts/check-cmake-versions.py'
}
}
}
}
}
def main()
{
timeout(180) {
run_basic_checks()
run_builds_in_parallel()
}
}
// Entry point
main()