forked from tjhei/aspect
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile.k8s
175 lines (156 loc) · 5.31 KB
/
Jenkinsfile.k8s
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
#!groovy
pipeline {
agent {
kubernetes {
//cloud 'kubernetes'
label 'mypod'
containerTemplate {
name 'dealii'
image 'gassmoeller/aspect-tester:8.5.0'
ttyEnabled true
command 'cat'
}
}
}
options {
timeout(time: 2, unit: 'HOURS')
}
stages {
stage ("Info") {
steps {
container('dealii') {
echo "PR: ${env.CHANGE_ID} - ${env.CHANGE_TITLE}"
echo "CHANGE_AUTHOR_EMAIL: ${env.CHANGE_AUTHOR_EMAIL}"
echo "CHANGE_AUTHOR: ${env.CHANGE_AUTHOR}"
echo "CHANGE_AUTHOR_DISPLAY_NAME: ${env.CHANGE_AUTHOR_DISPLAY_NAME}"
echo "building on node ${env.NODE_NAME}"
}
}
}
stage ("Check Permissions") {
when {
allOf {
not {branch 'master'}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
}
}
steps {
container('dealii') {
sh '''
wget -q -O - https://api.github.com/repos/geodynamics/aspect/issues/${CHANGE_ID}/labels | grep 'ready to test' || \
{ echo "This commit will only be tested when it has the label 'ready to test'"; exit 1; }
'''
}
}
}
stage('Check Indentation') {
steps {
container('dealii') {
sh './doc/indent'
sh 'git diff > changes-astyle.diff'
archiveArtifacts artifacts: 'changes-astyle.diff', fingerprint: true
sh '''
git diff --exit-code || \
{ echo "Please check indentation, see artifacts in the top right corner!"; exit 1; }
'''
}
}
}
stage('Build') {
options {
timeout(time: 15, unit: 'MINUTES')
}
steps {
container('dealii') {
sh 'mkdir build-gcc-fast'
// We need to add this option to mpirun, otherwise
// openmpi complains about running as root. We need
// to run as root, because the surrounding Jenkins container
// assumes we have root access.
sh 'sed -i "s/mpirun/mpirun --allow-run-as-root/" "tests/CMakeLists.txt"'
sh '''
cd build-gcc-fast
# Set up build system and compile ASPECT
cmake \
-G 'Ninja' \
-D CMAKE_CXX_FLAGS='-Werror' \
-D ASPECT_TEST_GENERATOR='Ninja' \
-D ASPECT_USE_PETSC='OFF' \
-D ASPECT_RUN_ALL_TESTS='ON' \
-D ASPECT_PRECOMPILE_HEADERS='ON' \
..
'''
sh '''
cd build-gcc-fast
ninja
'''
}
}
}
stage('Test') {
options {
timeout(time: 90, unit: 'MINUTES')
}
steps {
container('dealii') {
sh '''
# This export avoids a warning about
# a discovered, but unconnected infiniband network.
export OMPI_MCA_btl=self,tcp
cd build-gcc-fast/tests
# Let ninja prebuild the test libraries and run
# the tests to create the output files in parallel. We
# want this to always succeed, because it does not generate
# useful output (we do this further down using 'ctest', however
# ctest can not run ninja in parallel, so this is the
# most efficient way to build the tests).
ninja -k 0 tests || true
'''
sh '''
# Avoid the warning described above
export OMPI_MCA_btl=self,tcp
cd build-gcc-fast
# Output the test results using ctest. Since
# the tests were prebuild in the previous shell
# command, this will be fast although it is not
# running in parallel.
ctest \
--no-compress-output \
--test-action Test
'''
}
}
post {
always {
container('dealii') {
// Generate the 'Tests' output page in Jenkins
xunit testTimeMargin: '3000',
thresholdMode: 1,
thresholds: [failed(), skipped()],
tools: [CTest(pattern: 'build-gcc-fast/Testing/**/*.xml')]
// Update the reference test output with the new test results
sh '''
export OMPI_MCA_btl=self,tcp
cd build-gcc-fast
ninja generate_reference_output
'''
// Revert the change to the mpirun command we made above, so
// that the modification does not show up in the 'git diff' command
sh 'git checkout tests/CMakeLists.txt'
// Generate the 'Artifacts' diff-file that can be
// used to update the test results
sh 'git diff tests > changes-test-results.diff'
archiveArtifacts artifacts: 'changes-test-results.diff', fingerprint: true
}
}
}
}
}
}