-
Notifications
You must be signed in to change notification settings - Fork 20
/
Jenkinsfile
136 lines (130 loc) · 4.96 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
#!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("libswiftnav")
def builder = context.getBuilder()
/**
* - Mount the refrepo to keep git operations functional on a repo that uses ref-repo during clone
**/
String dockerMountArgs = "-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: '7'))
}
stages {
stage('Build') {
parallel {
stage('Unit Test') {
agent {
dockerfile {
args dockerMountArgs
}
}
steps {
gitPrep()
script {
builder.cmake()
builder.make(workDir: "build")
}
// Convert the test results into a Jenkins-parsable junit-XML format
sh("./tools/check2junit.py build/tests/test_results.xml > build/tests/test_results_junit.xml")
stash(
name: 'libswiftnavUnit',
includes: 'build/tests/test_results_junit.xml')
}
}
stage('Bazel Build') {
agent {
docker {
image '571934480752.dkr.ecr.us-west-2.amazonaws.com/swift-build-bazel:2023-06-21'
}
}
steps {
gitPrep()
script {
sh('''#!/bin/bash -ex
| CC=gcc-8 CXX=g++-8 bazel build --subcommands //...
| bazel run //:gen_compile_commands
| bazel run //:swiftnav-test
| bazel coverage --collect_code_coverage --combined_report=lcov //...
| genhtml bazel-out/_coverage/_coverage_report.dat -o coverage
| tar -zcvf coverage.tar.gz coverage/
|'''.stripMargin())
}
}
post {
always {
archiveArtifacts(artifacts: 'coverage.tar.gz', allowEmptyArchive: true)
}
}
}
stage('Format & Lint') {
agent {
dockerfile {
filename "Dockerfile.modern"
args dockerMountArgs
}
}
steps {
gitPrep()
script {
builder.cmake()
builder.make(workDir: "build", target: "clang-format-all-check")
builder.make(workDir: "build", target: "clang-tidy-all-check")
}
}
post {
always {
archiveArtifacts(artifacts: 'fixes.yaml', allowEmptyArchive: true)
}
}
}
stage('Code Coverage') {
agent {
dockerfile {
args dockerMountArgs
}
}
steps {
gitPrep()
script {
builder.cmake(buildType: "Debug", codeCoverage: "ON")
builder.make(workDir: "build", target: "ccov-all")
}
}
post {
success {
script {
context.uploadCodeCov(repo: "libswiftnav", searchdir: "build")
}
}
}
}
}
}
}
post {
always {
node('linux') {
unstash(name: "libswiftnavUnit")
junit('build/tests/*.xml')
}
script {
context.slackNotify()
context.postCommon()
}
}
}
}