Skip to content

Commit

Permalink
ROS2 CI adjustments (#42)
Browse files Browse the repository at this point in the history
* Port master build (rosws update) functionality from ros1

* Missing debug print for ros2 build

* Set REPO_NAME in ros2 build

* ros2 build: preinstall python3-rosinstall, remove gtest build

* ros2 build: increase verbosity of colcon test-result

* Remove ROS1-specific calls from ros2_build.sh and ignore tests of dependencies
  • Loading branch information
AAlon authored Jul 15, 2019
1 parent fa80375 commit 80ac4a5
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions ros2_build.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
#!/bin/bash
set -e
set -xe

# install dependencies
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 421C365BD9FF1F717815A3895523BAEEB01FA116
echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list
apt update && apt install -y python3 python3-pip libgtest-dev lcov cmake && rosdep update
cd /usr/src/gtest && cmake CMakeLists.txt && make && cp *.a /usr/lib
apt update && apt install -y python3-colcon-common-extensions && pip3 install -U setuptools
apt update && apt install -y python3 python3-pip lcov cmake && rosdep update
apt update && apt install -y python3-rosinstall python3-colcon-common-extensions && pip3 install -U setuptools

REPO_NAME=$(basename -- ${TRAVIS_BUILD_DIR})
echo "repo: ${REPO_NAME} branch: ${TRAVIS_BRANCH}"

# use colcon as build tool to build the package, and optionally build tests
. "/opt/ros/${ROS_DISTRO}/setup.sh"
cd "/${ROS_DISTRO}_ws/"
rosdep install --from-paths src --ignore-src --rosdistro "${ROS_DISTRO}" -r -y
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

colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage' -DCMAKE_C_FLAGS='-fprofile-arcs -ftest-coverage'

if [ -z "${NO_TEST}" ]; then
if [ ! -z "${PACKAGE_NAMES}" ] && [ "${ROS_VERSION}" == "1" ]; then
colcon build --packages-select ${PACKAGE_NAMES} --cmake-target tests
fi

# run unit tests
. ./install/setup.sh
if [ "${TRAVIS_BRANCH}" == "master" ] && [ -d "./dep" ]; then
touch dep/COLCON_IGNORE
fi
colcon test
colcon test-result --all
colcon test-result --all --verbose

# get unit test code coverage result
lcov --capture --directory . --output-file coverage.info
Expand Down

0 comments on commit 80ac4a5

Please sign in to comment.