-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathJenkinsfile
154 lines (140 loc) · 5.31 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
#!groovy
/**
* This Jenkinsfile will only work in a Swift Navigation build/CI environment, as it uses
* non-public docker images and pipeline libraries.
*/
// Use 'ci-jenkins@somebranch' to pull shared lib from a different branch than the default.
// Default is configured in Jenkins and should be from "stable" tag.
@Library("ci-jenkins") import com.swiftnav.ci.*
def context = new Context(context: this)
context.setRepo("gnss-converters")
def builder = context.getBuilder()
/**
* - Mount the ccache to speed up builds
* - Mount the refrepo to keep git operations functional on a repo that uses ref-repo during clone
**/
String dockerMountArgs = "-v /mnt/efs/ccache:/home/jenkins/.ccache -v /mnt/efs/refrepo:/mnt/efs/refrepo"
pipeline {
// Override agent in each stage to make sure we don't share containers among stages.
agent any
options {
// Make sure job aborts after 2 hours if hanging.
timeout(time: 2, unit: 'HOURS')
timestamps()
// Keep builds for 7 days.
buildDiscarder(logRotator(daysToKeepStr: '3'))
}
// Overwrite in stages that need clang
environment {
// Default compiler. Override in each stage as needed.
CC='gcc-6'
CXX='g++-6'
COMPILER='gcc-6'
// Default parallelism for make
MAKEJ='4'
// Since ~/.ccache is mounted from a shared NFS disk, make sure the temp
// dir is local to the container.
CCACHE_TEMPDIR='/tmp/ccache_tmp'
}
stages {
stage('Build') {
parallel {
stage('Build c') {
agent {
dockerfile {
args dockerMountArgs
}
}
steps {
gitPrep()
script {
builder.cmake(workDir: "c", cmakeAddArgs: "-DTHIRD_PARTY_INCLUDES_AS_SYSTEM=true -Dnov2sbp_BUILD=true")
builder.make(workDir: "c/build")
builder.make(workDir: "c/build", target: "clang-format-all")
}
/** Run clang-format.
* If the resulting 'git diff' is non-empty, then it found something,
* so error out and display the diff.
*/
sh '''#!/bin/bash -ex
git --no-pager diff --name-only HEAD > /tmp/clang-format-diff
if [ -s "/tmp/clang-format-diff" ]; then
echo "clang-format warning found"
git --no-pager diff
exit 1
fi
'''
sh '''#!/bin/bash -ex
(cd c && cd build && make clang-tidy-all)
if [ -e "c/fixes.yaml" ]; then
echo "clang-tidy warning found"
exit 1
fi
'''
script {
builder.make(workDir: "c/build", target: "do-all-tests")
}
}
post {
always {
archiveArtifacts(artifacts: 'c/fixes.yaml', allowEmptyArchive: true)
}
}
}
stage('Fuzz Test Checker') {
agent {
dockerfile {
args dockerMountArgs
}
}
environment {
CFLAGS='-fsanitize=address'
CXXFLAGS='-fsanitize=address'
LDFLAGS='-fsanitize=address'
}
steps {
gitPrep()
fetchTestData()
script {
builder.cmake(workDir: 'c', cmakeAddArgs: '-DTHIRD_PARTY_INCLUDES_AS_SYSTEM=true -DI_KNOW_WHAT_I_AM_DOING_AND_HOW_DANGEROUS_IT_IS__GNSS_CONVERTERS_DISABLE_CRC_VALIDATION=true')
builder.make(workDir: 'c/build', target: 'rerun-known-failures-ubx2sbp')
builder.make(workDir: 'c/build', target: 'rerun-known-failures-rtcm3tosbp')
}
}
}
}
}
}
post {
success {
script {
def automatedPr = new AutomatedPR(context: context)
automatedPr.merge()
}
}
failure {
script {
def automatedPr = new AutomatedPR(context: context)
automatedPr.alertSlack()
}
}
always {
script {
context.slackNotify(channel: '#positioning-dev')
context.slackNotify(channel: '#release', branches: ['.*v.*-release'])
}
}
cleanup {
cleanWs()
}
}
}
/**
* Retrieve test data submodule (it's large and not needed for all stages, so
* don't fetch it unless needed).
* @param args
* @return
*/
def fetchTestData(Map args = [:]) {
sh 'git submodule update --init --checkout --recursive c/afl/findings'
}