From eacf9bff6a8e9766f5f570a4b9dfa63933ce291d Mon Sep 17 00:00:00 2001 From: Abby Xu Date: Wed, 13 Feb 2019 15:09:07 -0800 Subject: [PATCH] create initial upload of scripts used in aws-robotics Travis CI --- README.md | 7 +++++-- ros1_build.sh | 32 ++++++++++++++++++++++++++++++++ ros1_sa_build.sh | 28 ++++++++++++++++++++++++++++ ros2_build.sh | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 ros1_build.sh create mode 100644 ros1_sa_build.sh create mode 100644 ros2_build.sh diff --git a/README.md b/README.md index 0610402..b0a6d42 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ -## Travis Scripts +# Travis Scripts -contains scripts for building sample applications and AWS ROS cloud extensions. +## Overview +This repository contains scripts used in Travis CIs for [AWS RoboMaker] sample applications and [AWS RoboMaker] ROS Cloud Extensions. ## License This library is licensed under the Apache 2.0 License. + +[AWS RoboMaker]: https://github.com/aws-robotics \ No newline at end of file diff --git a/ros1_build.sh b/ros1_build.sh new file mode 100644 index 0000000..ae45358 --- /dev/null +++ b/ros1_build.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e + +# install dependencies +apt update && apt install -y lcov python3-pip 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 + +# 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 +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 + fi + + # run unit tests + . ./install/setup.sh + colcon test + colcon test-result --all + + # get unit test code coverage result + lcov --capture --directory . --output-file coverage.info + lcov --remove coverage.info '/usr/*' --output-file coverage.info + lcov --list coverage.info + cd /"$ROS_DISTRO"_ws/ + mv coverage.info /shared +fi diff --git a/ros1_sa_build.sh b/ros1_sa_build.sh new file mode 100644 index 0000000..de3a484 --- /dev/null +++ b/ros1_sa_build.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +# install dependencies +apt update && apt install -y python3-pip python3-apt dpkg ros-$ROS_DISTRO-ros-base && rosdep update +apt update && apt install -y python3-colcon-common-extensions && pip3 install -U setuptools +pip3 install colcon-bundle colcon-ros-bundle +. /opt/ros/$ROS_DISTRO/setup.sh + +# use colcon as build tool to build the robot workspace +cd /"$ROS_DISTRO"_ws/"$SA_NAME"/robot_ws/ +rosws update +rosdep install --from-paths src --ignore-src -r -y +colcon build --build-base build --install-base install +colcon bundle --build-base build --install-base install --bundle-base bundle +mv ./bundle/output.tar.gz ./bundle/robot.tar.gz + +# use colcon as build tool to build the simulation workspace +cd /"$ROS_DISTRO"_ws/"$SA_NAME"/simulation_ws/ +rosws update +rosdep install --from-paths src --ignore-src -r -y +colcon build --build-base build --install-base install +colcon bundle --build-base build --install-base install --bundle-base bundle +mv ./bundle/output.tar.gz ./bundle/simulation.tar.gz + +# move the artifacts to a shared mount point +mv /"$ROS_DISTRO"_ws/"$SA_NAME"/robot_ws/bundle/robot.tar.gz /shared/robot.tar.gz +mv /"$ROS_DISTRO"_ws/"$SA_NAME"/simulation_ws/bundle/simulation.tar.gz /shared/simulation.tar.gz diff --git a/ros2_build.sh b/ros2_build.sh new file mode 100644 index 0000000..973d703 --- /dev/null +++ b/ros2_build.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +# 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 + +# 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 +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 + fi + + # run unit tests + . ./install/setup.sh + colcon test + colcon test-result --all + + # get unit test code coverage result + lcov --capture --directory . --output-file coverage.info + lcov --remove coverage.info '/usr/*' --output-file coverage.info + lcov --list coverage.info + cd /"$ROS_DISTRO"_ws/ + mv coverage.info /shared +fi