-
Notifications
You must be signed in to change notification settings - Fork 245
Expand file tree
/
Copy pathJenkinsfile
More file actions
354 lines (342 loc) · 13.1 KB
/
Copy pathJenkinsfile
File metadata and controls
354 lines (342 loc) · 13.1 KB
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
/* groovylint-disable NestedBlockDepth */
def PYTHON_VERSION_BY_UBUNTU = ['20.04': '3.9', '22.04': '3.10', '24.04': '3.12']
pipeline {
libraries {
lib('fe-pipeline-steps@1.0.0')
}
agent {
node {
label 'docker'
}
}
triggers {
pollSCM('H/5 * * * *')
}
options {
parallelsAlwaysFailFast()
timeout(time: 2, unit: 'HOURS')
skipDefaultCheckout()
}
environment {
UNSTABLE = 'UNSTABLE'
}
stages {
stage('Checkout') {
steps{
checkout([
$class: 'GitSCM',
branches: scm.branches,
userRemoteConfigs: scm.userRemoteConfigs,
])
sshagent(['git_ssh']) {
sh '''
ssh-keyscan -t rsa bitbucket.fe.lan >> ~/.ssh/known_hosts
git config submodule.common.url ssh://git@bitbucket.fe.lan:7999/moctrl/libfranka-common.git
git submodule update --init --recursive --depth 1
'''
}
script{
env.VERSION = feDetermineVersionFromGit()
}
}
}
stage('Matrix') {
matrix {
axes {
axis {
name 'UBUNTU_VERSION'
values '20.04', '22.04', '24.04'
}
}
environment {
DISTRO = "${['20.04': 'focal', '22.04': 'jammy', '24.04': 'noble'][UBUNTU_VERSION]}"
PYTHON_VERSION = "${PYTHON_VERSION_BY_UBUNTU[UBUNTU_VERSION]}"
}
agent {
dockerfile {
dir '.ci'
filename 'Dockerfile'
reuseNode true
additionalBuildArgs "--pull --build-arg UBUNTU_VERSION=${env.UBUNTU_VERSION} --build-arg PYTHON_VERSION=${PYTHON_VERSION_BY_UBUNTU[env.UBUNTU_VERSION]} --tag libfranka:${env.UBUNTU_VERSION}"
args '--privileged ' +
'--cap-add=SYS_PTRACE ' +
'--security-opt seccomp=unconfined ' +
'--shm-size=2g '
}
}
stages {
stage('Init Distro') {
steps {
script {
if (!env.DISTRO) {
error "Unknown UBUNTU_VERSION=${env.UBUNTU_VERSION}"
}
if (!env.PYTHON_VERSION) {
error "Unknown PYTHON_VERSION for UBUNTU_VERSION=${env.UBUNTU_VERSION}"
}
}
}
}
stage('Setup') {
stages {
stage('Notify Stash') {
steps {
script {
notifyBitbucket()
}
}
}
stage('Clean Workspace') {
steps {
script {
def distro = env.DISTRO
withEnv(["DISTRO=${distro}"]) {
sh '''
# Clean build dirs for this distro axis
rm -rf build-*${DISTRO}
rm -rf install-*${DISTRO}
# Remove corrupted googletest fetch content if present
rm -rf build-release.${DISTRO}/_deps/gtest-src build-release.${DISTRO}/_deps/gtest-build || true
rm -rf build-debug.${DISTRO}/_deps/gtest-src build-debug.${DISTRO}/_deps/gtest-build || true
rm -rf build-coverage.${DISTRO}/_deps/gtest-src build-coverage.${DISTRO}/_deps/gtest-build || true
'''
}
}
}
}
}
}
stage('Build') {
stages {
stage('Build debug') {
steps {
dir("build-debug.${env.DISTRO}") {
sh '''
rm -rf CMakeCache.txt CMakeFiles _deps || true
cmake -DCMAKE_BUILD_TYPE=Debug -DSTRICT=ON -DBUILD_COVERAGE=OFF \
-DBUILD_DOCUMENTATION=OFF -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DGENERATE_PYLIBFRANKA=ON ..
make -j$(nproc)
cmake --install . --prefix ../install-debug.${DISTRO}
'''
}
}
}
stage('Build release') {
steps {
dir("build-release.${env.DISTRO}") {
sh '''
rm -rf CMakeCache.txt CMakeFiles _deps || true
cmake -DCMAKE_BUILD_TYPE=Release -DSTRICT=ON -DBUILD_COVERAGE=OFF \
-DBUILD_DOCUMENTATION=ON -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DGENERATE_PYLIBFRANKA=ON ..
make -j$(nproc)
cmake --install . --prefix ../install-release.${DISTRO}
'''
}
}
}
stage('Build coverage') {
when {
not {
environment name: 'UBUNTU_VERSION', value: '24.04'
}
}
steps {
dir("build-coverage.${env.DISTRO}") {
sh '''
rm -rf CMakeCache.txt CMakeFiles _deps || true
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_COVERAGE=ON \
-DBUILD_DOCUMENTATION=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DBUILD_EXAMPLES=OFF -DBUILD_TESTS=ON ..
make -j$(nproc)
'''
}
}
}
}
}
stage('Lint') {
steps {
dir("build-lint.${env.DISTRO}") {
catchError(buildResult: env.UNSTABLE, stageResult: env.UNSTABLE) {
sh '''
cmake -DBUILD_COVERAGE=OFF -DBUILD_DOCUMENTATION=OFF -DBUILD_EXAMPLES=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DBUILD_TESTS=ON ..
make check-tidy -j$(nproc)
'''
}
}
}
}
stage('Format') {
steps {
dir("build-format.${env.DISTRO}") {
catchError(buildResult: env.UNSTABLE, stageResult: env.UNSTABLE) {
sh '''
cmake -DBUILD_COVERAGE=OFF -DBUILD_DOCUMENTATION=OFF -DBUILD_EXAMPLES=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DBUILD_TESTS=ON ..
make check-format -j$(nproc)
'''
}
}
}
}
stage('Coverage') {
when {
not {
environment name: 'UBUNTU_VERSION', value: '24.04'
}
}
steps {
dir("build-coverage.${env.DISTRO}") {
catchError(buildResult: env.UNSTABLE, stageResult: env.UNSTABLE) {
sh '''
cmake -DBUILD_COVERAGE=ON -DBUILD_DOCUMENTATION=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DBUILD_TESTS=ON ..
make coverage -j$(nproc)
'''
publishHTML([allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'coverage',
reportFiles: 'index.html',
reportName: "Code Coverage (${env.DISTRO})"])
}
}
}
}
stage('Test') {
steps {
catchError(buildResult: env.UNSTABLE, stageResult: env.UNSTABLE) {
timeout(time: 300, unit: 'SECONDS') {
sh '''
# ASLR Fix: Disable ASLR temporarily for ASan compatibility
echo "[Debug Tests] Disabling ASLR for ASan compatibility..."
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space || echo "Could not disable ASLR"
echo "[Debug Tests] ASLR status: $(cat /proc/sys/kernel/randomize_va_space)"
'''
script {
dir("build-debug.${env.DISTRO}") {
sh '''
echo "[Debug Tests] Running tests..."
ctest -V
'''
}
dir("build-release.${env.DISTRO}") {
sh '''
echo "[Release Tests] Running tests..."
ctest -V
'''
}
}
sh '''
# Re-enable ASLR for security
echo "[Debug Tests] Re-enabling ASLR..."
echo 2 | sudo tee /proc/sys/kernel/randomize_va_space || echo "Could not re-enable ASLR"
echo "[Debug Tests] ASLR restored to: $(cat /proc/sys/kernel/randomize_va_space)"
'''
}
}
}
post {
always {
catchError(buildResult: env.UNSTABLE, stageResult: env.UNSTABLE) {
junit "build-release.${env.DISTRO}/test_results/*.xml"
junit "build-debug.${env.DISTRO}/test_results/*.xml"
}
}
}
}
stage('Check Github Sync') {
steps {
sh '.ci/checkgithistory.sh https://github.com/frankarobotics/libfranka.git develop'
}
}
stage('Publish deb packages') {
steps {
script {
def distro = env.DISTRO
dir("build-release.${distro}") {
catchError(buildResult: env.UNSTABLE, stageResult: env.UNSTABLE) {
sh 'cpack'
// Publish Debian packages with Git commit hash in the name
fePublishDebian('*.deb', 'fci', "deb.distribution=${distro};deb.component=main;deb.architecture=amd64")
dir('doc') {
sh 'mv docs/*/html/ html/'
sh 'tar cfz ../libfranka-docs.tar.gz html'
}
sh "rename -e 's/(.tar.gz)\$/-${distro}\$1/' *.tar.gz"
publishHTML([allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'doc/html',
reportFiles: 'index.html',
reportName: "API Documentation (${distro})"])
}
}
}
}
}
stage('Publish pylibfranka documentation') {
when {
expression {
env.UBUNTU_VERSION == '20.04'
}
}
steps {
// Build and publish pylibfranka documentation (only on Ubuntu 20.04)
catchError(buildResult: env.UNSTABLE, stageResult: env.UNSTABLE) {
script {
withEnv(["DISTRO=${env.DISTRO}"]) {
sh '''
# Install pylibfranka from root (builds against libfranka in build-release.${DISTRO})
export LD_LIBRARY_PATH="${WORKSPACE}/build-release.${DISTRO}:${LD_LIBRARY_PATH:-}"
if [ -n "$VIRTUAL_ENV" ]; then
python3 -m pip install .
else
python3 -m pip install . --user
fi
'''
dir('pylibfranka/docs') {
sh '''
# Install Sphinx and dependencies (respect virtualenv if present)
if [ -n "$VIRTUAL_ENV" ]; then
python3 -m pip install -r requirements.txt
else
# Add sphinx to PATH for --user installs
export PATH="$HOME/.local/bin:$PATH"
python3 -m pip install -r requirements.txt --user
fi
# Set locale
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# Add libfranka to library path
export LD_LIBRARY_PATH="${WORKSPACE}/build-release.${DISTRO}:${LD_LIBRARY_PATH:-}"
make html
'''
publishHTML([allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: '_build/html',
reportFiles: 'index.html',
reportName: "pylibfranka Documentation (${env.DISTRO})"])
}
}
}
}
}
}
}
}
}
}
post {
success {
fePublishBuildInfo()
}
always {
cleanWs()
script {
notifyBitbucket()
}
}
}
}