forked from PX4/PX4-Autopilot
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Jenkinsfile-SITL_tests_coverage
192 lines (167 loc) · 5.79 KB
/
Jenkinsfile-SITL_tests_coverage
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
#!/usr/bin/env groovy
pipeline {
agent none
stages {
stage('ROS Tests') {
steps {
script {
def missions = [
[
name: "FW",
test: "mavros_posix_test_mission.test",
mission: "FW_mission_1",
vehicle: "plane"
],
[
name: "MC_box",
test: "mavros_posix_test_mission.test",
mission: "MC_mission_box",
vehicle: "iris"
],
[
name: "MC_offboard_att",
test: "mavros_posix_tests_offboard_attctl.test",
mission: "",
vehicle: "iris"
],
[
name: "MC_offboard_pos",
test: "mavros_posix_tests_offboard_posctl.test",
mission: "",
vehicle: "iris"
],
[
name: "Rover 1",
test: "mavros_posix_test_mission.test",
mission: "rover_mission_1",
vehicle: "rover"
],
[
name: "VTOL_standard",
test: "mavros_posix_test_mission.test",
mission: "VTOL_mission_1",
vehicle: "standard_vtol"
],
[
name: "VTOL_tailsitter",
test: "mavros_posix_test_mission.test",
mission: "VTOL_mission_1",
vehicle: "tailsitter"
],
// [
// name: "VTOL_tiltrotor",
// test: "mavros_posix_test_mission.test",
// mission: "VTOL_mission_1",
// vehicle: "tiltrotor"
// ],
]
def test_nodes = [:]
for (def i = 0; i < missions.size(); i++) {
test_nodes.put(missions[i].name, createTestNode(missions[i]))
}
parallel test_nodes
} // script
} // steps
} // stage ROS Tests
stage('Coverage') {
parallel {
stage('code coverage (python)') {
agent {
docker {
image 'px4io/px4-dev-base-bionic:2019-10-24'
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw'
}
}
steps {
sh 'export'
sh 'make distclean'
sh 'git fetch --tags'
sh 'make python_coverage'
withCredentials([string(credentialsId: 'FIRMWARE_CODECOV_TOKEN', variable: 'CODECOV_TOKEN')]) {
sh 'curl -s https://codecov.io/bash | bash -s - -F python'
}
sh 'make distclean'
}
}
stage('unit tests') {
agent {
docker {
image 'px4io/px4-dev-base-bionic:2019-10-24'
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw'
}
}
steps {
sh 'export'
sh 'make distclean'
sh 'git fetch --tags'
sh 'make tests'
withCredentials([string(credentialsId: 'FIRMWARE_CODECOV_TOKEN', variable: 'CODECOV_TOKEN')]) {
sh 'curl -s https://codecov.io/bash | bash -s - -F unittest'
}
sh 'make distclean'
}
}
} // parallel
} // stage Coverage
} //stages
environment {
CCACHE_DIR = '/tmp/ccache'
CI = true
CTEST_OUTPUT_ON_FAILURE = 1
PX4_CMAKE_BUILD_TYPE = 'Coverage'
}
options {
buildDiscarder(logRotator(numToKeepStr: '10', artifactDaysToKeepStr: '20'))
timeout(time: 60, unit: 'MINUTES')
}
} // pipeline
def createTestNode(Map test_def) {
return {
node {
cleanWs()
docker.image("px4io/px4-dev-ros-melodic:2019-10-24").inside('-e HOME=${WORKSPACE}') {
stage(test_def.name) {
def test_ok = true
sh('export')
checkout(scm)
// run test
try {
sh('make distclean')
sh 'git fetch --tags'
sh('ccache -z')
sh('make px4_sitl_default')
sh('make px4_sitl_default sitl_gazebo')
sh('ccache -s')
sh('make rostest_run TEST_FILE=' + test_def.test + ' TEST_MISSION=' + test_def.mission + ' TEST_VEHICLE=' + test_def.vehicle)
} catch (exc) {
// save all test artifacts for debugging
archiveArtifacts(allowEmptyArchive: false, artifacts: '.ros/**/*.ulg, .ros/**/rosunit-*.xml, .ros/**/rostest-*.log')
test_ok = false
}
// log analysis
withCredentials([string(credentialsId: 'FIRMWARE_CODECOV_TOKEN', variable: 'CODECOV_TOKEN')]) {
sh 'curl -s https://codecov.io/bash | bash -s - -F sitl_mission_${STAGE_NAME}'
// process log data (with python code coverage)
try {
//sh('coverage run -p Tools/ecl_ekf/process_logdata_ekf.py .ros/log/*/*.ulg')
sh('Tools/ecl_ekf/process_logdata_ekf.py .ros/log/*/*.ulg')
} catch (exc) {
// save log analysis artifacts for debugging
archiveArtifacts(allowEmptyArchive: false, artifacts: '.ros/**/*.pdf, .ros/**/*.csv')
// FIXME: don't let the script to fail the build
// test_ok = false
}
// upload log to flight review (https://logs.px4.io/) with python code coverage
sh('coverage run -p Tools/upload_log.py -q --description "${JOB_NAME}: ${STAGE_NAME}" --feedback "${JOB_NAME} ${CHANGE_TITLE} ${CHANGE_URL}" --source CI .ros/log/*/*.ulg')
// upload python code coverage to codecov.io
sh 'curl -s https://codecov.io/bash | bash -s - -X gcov -F sitl_python_${STAGE_NAME}'
}
if (!test_ok) {
error('ROS Test failed')
}
} // stage
cleanWs()
} // docker.image
} // node
} // return
} // createTestNode