Skip to content

Commit

Permalink
Update travis-scripts (#40)
Browse files Browse the repository at this point in the history
* allow multiple PACKAGE_NAMEs

Signed-off-by: Miaofei <miaofei@amazon.com>

* fix bug that prevented use of rosws update

Signed-off-by: Miaofei <miaofei@amazon.com>

* stop manually building libgtest as catkin should do it automatically

Signed-off-by: Miaofei <miaofei@amazon.com>
  • Loading branch information
mm318 authored Jun 26, 2019
1 parent a117647 commit d760da7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
8 changes: 4 additions & 4 deletions ce_build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
set -xe

if [ ! -z "${TRAVIS_TAG}" ]; then
# Do not run for builds triggered by tagging.
Expand All @@ -23,17 +23,17 @@ else
fi

echo "using Build script, ${BUILD_SCRIPT_NAME}"
DOCKER_BUILD_SCRIPT="/shared/$(basename ${SCRIPT_DIR})/${BUILD_SCRIPT_NAME}"
DOCKER_BUILD_SCRIPT="/shared/$(basename -- ${SCRIPT_DIR})/${BUILD_SCRIPT_NAME}"
# get a docker container from OSRF's docker hub
docker pull "ros:${ROS_DISTRO}-ros-core"
# run docker container
docker run -v "${PWD}/shared:/shared" \
-e ROS_DISTRO="${ROS_DISTRO}" \
-e PACKAGE_NAME="${PACKAGE_NAME}" \
-e PACKAGE_NAMES="${PACKAGE_NAMES}" \
-e ROS_VERSION="${ROS_VERSION}" \
-e NO_TEST="${NO_TEST}" \
-e TRAVIS_BUILD_DIR="${TRAVIS_BUILD_DIR}" \
-e $TRAVIS_BRANCH="${TRAVIS_BRANCH}" \
-e TRAVIS_BRANCH="${TRAVIS_BRANCH}" \
-e PACKAGE_LANG="${PACKAGE_LANG:-cpp}" \
-e GAZEBO_VERSION="${GAZEBO_VERSION:-7}" \
-e DOCKER_BUILD_SCRIPT="${DOCKER_BUILD_SCRIPT}" \
Expand Down
29 changes: 14 additions & 15 deletions ros1_build.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#!/bin/bash
set -e
set -xe

# install dependencies
apt update && apt install -y lcov python3-pip python-rosinstall libgtest-dev 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
# nosetests needs coverage for Python 2
apt-get install python-pip -y && 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

. "/opt/ros/${ROS_DISTRO}/setup.sh"
REPO_NAME=`echo $TRAVIS_BUILD_DIR | cut -c 33-`
cd "/${ROS_DISTRO}_ws/"
REPO_NAME=$(basename -- ${TRAVIS_BUILD_DIR})
echo "repo: ${REPO_NAME} branch: ${TRAVIS_BRANCH}"

cd "/${ROS_DISTRO}_ws/"
# use colcon as build tool to build the package, and optionally build tests
if [ "${TRAVIS_BRANCH}" == "master" ] && [ -f "./src/${REPO_NAME}/.rosinstall.master" ];
then
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
Expand All @@ -27,19 +25,19 @@ else
rosdep install --from-paths src --ignore-src --rosdistro "${ROS_DISTRO}" -r -y
fi

. "/opt/ros/${ROS_DISTRO}/setup.sh"

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_NAME}" ];
then
colcon build --packages-select "${PACKAGE_NAME}" --cmake-target tests

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

# run unit tests
. ./install/setup.sh

if [ "${TRAVIS_BRANCH}" == "master" ];
then
if [ "${TRAVIS_BRANCH}" == "master" ]; then
touch dep/COLCON_IGNORE
fi

Expand All @@ -56,7 +54,8 @@ then
mv coverage.info /shared
;;
"python")
cd "/${ROS_DISTRO}_ws/build/${PACKAGE_NAME}"
# this doesn't actually support multiple packages
cd "/${ROS_DISTRO}_ws/build/${PACKAGE_NAMES}"
coverage xml
cp coverage.xml /shared/coverage.info
;;
Expand Down
18 changes: 9 additions & 9 deletions ros2_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ 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

# 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
. "/opt/ros/${ROS_DISTRO}/setup.sh"
cd "/${ROS_DISTRO}_ws/"
rosdep install --from-paths src --ignore-src --rosdistro "${ROS_DISTRO}" -r -y

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_NAME}" ] && [ "$ROS_VERSION" == "1" ];
then
colcon build --packages-select $PACKAGE_NAME --cmake-target tests

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
Expand All @@ -29,6 +29,6 @@ then
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
cd /"$ROS_DISTRO"_ws/
cd "/${ROS_DISTRO}_ws/"
mv coverage.info /shared
fi

0 comments on commit d760da7

Please sign in to comment.