forked from inviwo/inviwo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
218 lines (202 loc) · 7.42 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
214
215
216
217
218
@NonCPS
def getChangeString() {
MAX_MSG_LEN = 100
def changeString = ""
echo "Gathering SCM changes"
def changeLogSets = currentBuild.rawBuild.changeSets
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
truncated_msg = entry.msg.take(MAX_MSG_LEN)
changeString += "${new Date(entry.timestamp).format("yyyy-MM-dd HH:mm:ss")} "
changeString += "[${entry.commitId.take(8)}] ${entry.author}: ${truncated_msg}\n"
}
}
if (!changeString) {
changeString = " - No new changes"
}
return changeString
}
def nicelog(env = [], fun) {
withEnv(['TERM=xterm'] + env) {
ansiColor {
timestamps {
fun()
}
}
}
}
node {
properties([
parameters([
booleanParam(
defaultValue: false,
description: 'Do a clean build',
name: 'Clean Build'
),
choice(
choices: "Release\nDebug\nMinSizeRel\nRelWithDebInfo\n", // The first will be default
description: 'Select build configuration',
name: 'Build Type'
)
]),
pipelineTriggers([
[$class: 'GitHubPushTrigger']
])
])
try {
stage('Fetch') {
echo "Building inviwo Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
dir('inviwo') {
checkout scm
sh 'git submodule sync' // needed when a submodule has a new url
sh 'git submodule update --init'
}
}
stage('Build') {
if (params['Clean Build']) {
echo "Clean build, removing build folder"
sh "rm -r build"
}
dir('build') {
nicelog(['CC=/usr/bin/gcc-5', 'CXX=/usr/bin/g++-5']) {
sh """
ccache -z # reset ccache statistics
# tell ccache where the project root is
export CPATH=`pwd`
export CCACHE_BASEDIR=`readlink -f \${CPATH}/..`
cmake -G \"Ninja\" -LA \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=${params['Build Type']} \
-DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so \
-DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ \
-DCMAKE_PREFIX_PATH=/opt/Qt/5.6/gcc_64 \
-DIVW_CMAKE_DEBUG=ON \
-DIVW_DOXYGEN_PROJECT=ON \
-DBUILD_SHARED_LIBS=ON \
-DIVW_MODULE_GLFW=ON \
-DIVW_TINY_GLFW_APPLICATION=ON \
-DIVW_TINY_QT_APPLICATION=ON \
-DIVW_MODULE_ABUFFERGL=ON \
-DIVW_MODULE_ANIMATION=ON \
-DIVW_MODULE_ANIMATIONQT=ON \
-DIVW_MODULE_PLOTTING=ON \
-DIVW_MODULE_PLOTTINGGL=ON \
-DIVW_MODULE_POSTPROCESSING=ON \
-DIVW_MODULE_USERINTERFACEGL=ON \
-DIVW_MODULE_HDF5=ON \
-DIVW_UNITTESTS=ON \
-DIVW_UNITTESTS_RUN_ON_BUILD=OFF \
-DIVW_INTEGRATION_TESTS=ON \
-DIVW_RUNTIME_MODULE_LOADING=ON \
../inviwo
ninja
ccache -s # print ccache statistics
"""
}
}
}
stage('Unit tests') {
dir('build/bin') {
nicelog {
sh '''
export DISPLAY=:0
rc=0
for unittest in inviwo-unittests-*
do echo ==================================
echo Running: ${unittest}
./${unittest} || rc=$?
done
exit ${rc}
'''
}
}
}
stage('Integration tests') {
dir('build/bin') {
nicelog {
sh '''
export DISPLAY=:0
./inviwo-integrationtests
'''
}
}
}
stage('Copyright check') {
dir('inviwo') {
nicelog {
sh '''
python3 tools/refactoring/check-copyright.py .
'''
}
}
}
stage('Doxygen') {
dir('build') {
nicelog {
sh '''
export DISPLAY=:0
ninja DOXY-ALL
'''
}
}
}
try {
stage('Regression tests') {
dir('regress') {
nicelog {
sh """
export DISPLAY=:0
python3 ../inviwo/tools/regression.py \
--inviwo ../build/bin/inviwo \
--header ${env.JENKINS_HOME}/inviwo-config/header.html \
--output . \
--repos ../inviwo
"""
}
}
}
} catch (e) {
// Mark as unstable, if we mark as failed, the report will not be published.
currentBuild.result = 'UNSTABLE'
}
stage('Publish') {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: false,
reportDir: 'regress',
reportFiles: 'report.html',
reportName: 'Regression Report'
])
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: false,
reportDir: 'build/doc/inviwo/html',
reportFiles: 'index.html',
reportName: 'Doxygen Documentation'
])
}
currentBuild.result = 'SUCCESS'
} catch (e) {
currentBuild.result = 'FAILURE'
throw e
} finally {
stage('Slack') {
echo "result: ${currentBuild.result}"
def res2color = ['SUCCESS' : 'good', 'UNSTABLE' : 'warning' , 'FAILURE' : 'danger' ]
def color = res2color.containsKey(currentBuild.result) ? res2color[currentBuild.result] : 'warning'
slackSend(
color: color,
channel: "#jenkins-branch-pr",
message: "Inviwo branch: ${env.BRANCH_NAME}\n" + \
"Status: ${currentBuild.result}\n" + \
"Job: ${env.BUILD_URL} \n" + \
"Regression: ${env.JOB_URL}Regression_Report/\n" + \
"Changes: " + getChangeString()
)
}
}
}