-
Notifications
You must be signed in to change notification settings - Fork 6
/
ros1_build.sh
executable file
·74 lines (63 loc) · 2.8 KB
/
ros1_build.sh
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
#!/bin/bash
set -xe
# install dependencies
sudo apt-get update && sudo apt-get install -y lcov python3-pip python-rosinstall libgtest-dev cmake && rosdep update
sudo apt-get update && sudo apt-get install -y python3-colcon-common-extensions && sudo -H pip3 install -U setuptools
# NOTE: Workaround for setuptools 50.0.* (see https://github.com/pypa/setuptools/issues/2352)
export SETUPTOOLS_USE_DISTUTILS=stdlib
# nosetests needs coverage for Python 2
sudo apt-get install python-pip -y && sudo -H pip install -U coverage
# enable Python coverage "https://github.com/ros/catkin/blob/kinetic-devel/cmake/test/nosetests.cmake#L59"
export CATKIN_TEST_COVERAGE=1
REPO_NAME=$(basename -- ${TRAVIS_BUILD_DIR})
echo "repo: ${REPO_NAME} branch: ${TRAVIS_BRANCH}"
. "/opt/ros/${ROS_DISTRO}/setup.sh"
cd "/${ROS_DISTRO}_ws/"
if [ "${TRAVIS_BRANCH}" == "master" ] && [ -f "./src/${REPO_NAME}/.rosinstall.master" ]; then
mkdir dep
cd "/${ROS_DISTRO}_ws/dep"
ln -s "../src/${REPO_NAME}/.rosinstall.master" .rosinstall
rosws update
cd "/${ROS_DISTRO}_ws/"
rosdep install --from-paths src dep --ignore-src --rosdistro "${ROS_DISTRO}" -r -y
else
rosdep install --from-paths src --ignore-src --rosdistro "${ROS_DISTRO}" -r -y
fi
# use colcon as build tool to build the package, and optionally build tests
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage' -DCMAKE_C_FLAGS='-fprofile-arcs -ftest-coverage'
# build and run unit tests
if [ -z "${NO_TEST}" ]; then
if [ ! -z "${PACKAGE_NAMES}" ]; then
colcon build --packages-select ${PACKAGE_NAMES} --cmake-target tests
fi
. ./install/setup.sh
if [ "${TRAVIS_BRANCH}" == "master" ] && [ -d "./dep" ]; then
touch dep/COLCON_IGNORE
fi
set +e
colcon test
set -e
colcon test-result --all --verbose
# get unit test code coverage result
case ${PACKAGE_LANG} in
"cpp")
lcov --capture --directory . --output-file coverage.info
if [ "${ROS_DISTRO}" == "kinetic" ]; then
# kinetic is using xenial, which is using lcov 1.12, which has a bug.
# see https://github.com/linux-test-project/lcov/commit/632c25a0d1f5e4d2f4fd5b28ce7c8b86d388c91f
sudo lcov --remove coverage.info '/usr/*' --output-file coverage.info
else
lcov --remove coverage.info '/usr/*' --output-file coverage.info
fi
lcov --list coverage.info
cd "/${ROS_DISTRO}_ws/"
sudo cp coverage.info /shared/
;;
"python")
# this doesn't actually support multiple packages
cd "/${ROS_DISTRO}_ws/build/${PACKAGE_NAMES}"
coverage xml
sudo cp coverage.xml /shared/coverage.info
;;
esac
fi