From 988c77c3445c35fce4ac8672e2da5c6425388d06 Mon Sep 17 00:00:00 2001 From: Michael Smart Date: Wed, 29 Mar 2017 15:11:07 -0400 Subject: [PATCH 1/6] Restore previous CI work --- .travis.yml | 61 +++++++++++++++++++++++++ scripts/create_catkin_workspace.bash | 44 ++++++++++++++++++ scripts/identify_environment.bash | 14 ++++++ scripts/install_deps_for_docker_ci.bash | 5 ++ scripts/ros_install.bash | 40 ++++++++++++++++ scripts/run-ci-tests.sh | 12 +++++ 6 files changed, 176 insertions(+) create mode 100644 .travis.yml create mode 100644 scripts/create_catkin_workspace.bash create mode 100644 scripts/identify_environment.bash create mode 100644 scripts/install_deps_for_docker_ci.bash create mode 100644 scripts/ros_install.bash create mode 100644 scripts/run-ci-tests.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e41287f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,61 @@ +# General .travis.yml file for running continuous integration on Travis-CI using +# Docker to test other Ubuntu/ROS versions that just the versions that are +# natively supported by Travis-CI. +# +# Initially based on the .travis.yml file posted by Felix Duvallet for using +# Travis-CI with any ROS package +# +# Almost completely redone by Alex Tomala and Michael Smart. +# +# NOTE: The build lifecycle on Travis.ci is something like this: +# before_install +# install +# before_script +# script +# after_success or after_failure +# after_script +# OPTIONAL before_deploy +# OPTIONAL deploy +# OPTIONAL after_deploy +# +################################################################################ + +# Use ubuntu trusty (14.04) with sudo privileges. +dist: trusty +sudo: required + +# Set build matrix and global CI env variables +env: + global: + - DOCKER_CACHE_DIR=$HOME/docker_cache + matrix: + - DOCKER_DISTRO=trusty + - DOCKER_DISTRO=xenial + +################################################################################ + +# Have to pull git outside of docker as the container doesn't have an ssh key. +before_install: + - git submodule init + - git submodule -q update + +# Load the cached docker container. Otherwise, delete and rebuild it. +install: + - travis_wait 45 bash docker-setup-ci.bash + +# Execute the CI script using the docker container +# +# docker-run-ci.sh takes two arguments: +# {1}: The repository name +# {2}: The relative path to the respository's own CI test script +script: + - bash docker-run-ci.sh ros_docker_ci scripts/run-ci-tests.sh + +# Cache the docker container if it was rebuilt above. +before_cache: + - bash save-docker-cache-ci.bash + +cache: + directories: + - $HOME/docker_cache + timeout: 1200 diff --git a/scripts/create_catkin_workspace.bash b/scripts/create_catkin_workspace.bash new file mode 100644 index 0000000..c5e6827 --- /dev/null +++ b/scripts/create_catkin_workspace.bash @@ -0,0 +1,44 @@ +#!/bin/bash +set -e +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# get UBUNTU_CODENAME, ROS_DISTRO, REPO_DIR, CATKIN_DIR +source $SCRIPT_DIR/identify_environment.bash + +main() +{ + install_catkin_tools + create_catkin_ws +} + +install_catkin_tools() +{ + # Check if already installed + if type catkin > /dev/null 2>&1; then + echo "Catkin tools is already installed" + else + echo "Installing catkin tools ..." + sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list' + wget -qO - http://packages.ros.org/ros.key | sudo apt-key add - + sudo apt-get -qq update + sudo apt-get -qq install python-catkin-tools > /dev/null + echo "Catkin tools installed successfully." + fi +} + +create_catkin_ws() +{ + # Check if workspace exists + if [ -e "$CATKIN_DIR/.catkin_workspace" ] || [ -d "$CATKIN_DIR/.catkin_tools" ]; then + echo "Catkin workspace detected at ~/catkin_ws" + else + echo "Creating catkin workspace in $HOME/catkin_ws ..." + source /opt/ros/$ROS_DISTRO/setup.bash + mkdir -p "$HOME/catkin_ws/src" + cd "$HOME/catkin_ws" + catkin init > /dev/null + catkin build --no-status + echo "Catkin workspace created successfully." + fi +} + +main diff --git a/scripts/identify_environment.bash b/scripts/identify_environment.bash new file mode 100644 index 0000000..f71becb --- /dev/null +++ b/scripts/identify_environment.bash @@ -0,0 +1,14 @@ +#!/bin/bash +set -e +export UBUNTU_CODENAME=$(lsb_release -s -c) +case $UBUNTU_CODENAME in + trusty) + export ROS_DISTRO=indigo;; + xenial) + export ROS_DISTRO=kinetic;; + *) + echo "Unsupported version of Ubuntu detected. Only trusty (14.04.*) and xenial (16.04.*) are currently supported." + exit 1 +esac +export REPO_DIR=$(dirname "$SCRIPT_DIR") +export CATKIN_DIR="$HOME/catkin_ws" diff --git a/scripts/install_deps_for_docker_ci.bash b/scripts/install_deps_for_docker_ci.bash new file mode 100644 index 0000000..8d575e8 --- /dev/null +++ b/scripts/install_deps_for_docker_ci.bash @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +source /scripts/ros_install.bash +source /scripts/create_catkin_workspace.bash diff --git a/scripts/ros_install.bash b/scripts/ros_install.bash new file mode 100644 index 0000000..4023bfd --- /dev/null +++ b/scripts/ros_install.bash @@ -0,0 +1,40 @@ +#!/bin/bash +set -e # exit on first error +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# get UBUNTU_CODENAME, ROS_DISTRO, REPO_DIR, CATKIN_DIR +source $SCRIPT_DIR/identify_environment.bash + +ROSPACKAGES_DIR="$REPO_DIR/rospackages" + +sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu $UBUNTU_CODENAME main\" > /etc/apt/sources.list.d/ros-latest.list" +wget -qO - http://packages.ros.org/ros.key | sudo apt-key add - + +echo "Updating package lists ..." +sudo apt-get -qq update +echo "Installing ROS $ROS_DISTRO ..." +sudo apt-get -qq install python-catkin-pkg python-rosdep python-wstool ros-$ROS_DISTRO-catkin ros-$ROS_DISTRO-desktop > /dev/null +sudo apt-get -qq install ros-$ROS_DISTRO-pcl-ros ros-$ROS_DISTRO-image-transport ros-$ROS_DISTRO-image-transport-plugins ros-$ROS_DISTRO-libg2o > /dev/null + +source /opt/ros/$ROS_DISTRO/setup.bash + +# Prepare rosdep to install dependencies. +echo "Updating rosdep ..." +if [ ! -d /etc/ros/rosdep ]; then + sudo rosdep init > /dev/null +fi + +# Add Dataspeed packages +echo "Setting up Dataspeed apt and rosdep repositories" +bash <(wget -q -O - https://bitbucket.org/DataspeedInc/ros_binaries/raw/default/scripts/setup.bash) + +rosdep update +sudo apt-get -qq install python-rosinstall + +# Install system dependencies listed in ROS packages' package.xml +# Note: dependencies needed on embedded systems must still be included +# separately in the repo or cross-compiled stage. +if [ -d "$ROSPACKAGES_DIR" ]; then + rosdep -q -y install --from-paths "$ROSPACKAGES_DIR" --ignore-src +else + echo "Repository not detected: rosdep did not run" +fi diff --git a/scripts/run-ci-tests.sh b/scripts/run-ci-tests.sh new file mode 100644 index 0000000..df3ab2f --- /dev/null +++ b/scripts/run-ci-tests.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e # exit on first error + +source /opt/ros/${ROS_DISTRO}/setup.bash +source /ros_docker_ci/scripts/identify_environment.bash + +sudo apt-get update + +cd ${CATKIN_DIR} + +catkin build --no-status From d4f7f0179bcc7057c05c026e7abbfd4d08d10124 Mon Sep 17 00:00:00 2001 From: Michael Smart Date: Thu, 30 Mar 2017 17:08:19 -0400 Subject: [PATCH 2/6] Add new env variable DOCKER_CI_REL_DIR to .travis.yml to allow for different locations for the ros_docker_ci repo --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e41287f..ff24640 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,7 @@ sudo: required env: global: - DOCKER_CACHE_DIR=$HOME/docker_cache + - DOCKER_CI_REL_DIR=. matrix: - DOCKER_DISTRO=trusty - DOCKER_DISTRO=xenial @@ -41,7 +42,7 @@ before_install: # Load the cached docker container. Otherwise, delete and rebuild it. install: - - travis_wait 45 bash docker-setup-ci.bash + - travis_wait 45 bash ${DOCKER_CI_REL_DIR}/docker-setup-ci.bash # Execute the CI script using the docker container # @@ -49,11 +50,11 @@ install: # {1}: The repository name # {2}: The relative path to the respository's own CI test script script: - - bash docker-run-ci.sh ros_docker_ci scripts/run-ci-tests.sh + - bash ${DOCKER_CI_REL_DIR}/docker-run-ci.sh ros_docker_ci scripts/run-ci-tests.sh # Cache the docker container if it was rebuilt above. before_cache: - - bash save-docker-cache-ci.bash + - bash ${DOCKER_CI_REL_DIR}/save-docker-cache-ci.bash cache: directories: From 95b351c6ba1f20c65e8e103c1a32bbd2871240fe Mon Sep 17 00:00:00 2001 From: Michael Smart Date: Thu, 30 Mar 2017 17:30:18 -0400 Subject: [PATCH 3/6] Fix rename from .sh to .bash --- .travis.yml | 2 +- scripts/{run-ci-tests.sh => run-ci-tests.bash} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scripts/{run-ci-tests.sh => run-ci-tests.bash} (100%) diff --git a/.travis.yml b/.travis.yml index ff24640..081904c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ install: # {1}: The repository name # {2}: The relative path to the respository's own CI test script script: - - bash ${DOCKER_CI_REL_DIR}/docker-run-ci.sh ros_docker_ci scripts/run-ci-tests.sh + - bash ${DOCKER_CI_REL_DIR}/docker-run-ci.bash ros_docker_ci scripts/run-ci-tests.bash # Cache the docker container if it was rebuilt above. before_cache: diff --git a/scripts/run-ci-tests.sh b/scripts/run-ci-tests.bash similarity index 100% rename from scripts/run-ci-tests.sh rename to scripts/run-ci-tests.bash From 91ac28507b296e18fc2568b3f56e94a73566c13f Mon Sep 17 00:00:00 2001 From: Michael Smart Date: Mon, 10 Apr 2017 13:03:48 -0400 Subject: [PATCH 4/6] Update .travis.yml for change to docker-run-ci.bash --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 081904c..c8c99c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,11 +46,10 @@ install: # Execute the CI script using the docker container # -# docker-run-ci.sh takes two arguments: -# {1}: The repository name -# {2}: The relative path to the respository's own CI test script +# docker-run-ci.sh takes one argument: +# {1}: The relative path to the respository's own CI test script script: - - bash ${DOCKER_CI_REL_DIR}/docker-run-ci.bash ros_docker_ci scripts/run-ci-tests.bash + - bash ${DOCKER_CI_REL_DIR}/docker-run-ci.bash scripts/run-ci-tests.bash # Cache the docker container if it was rebuilt above. before_cache: From cdfbcc6f5156a5ab73ffa1d58c5a3e0d18af7f96 Mon Sep 17 00:00:00 2001 From: Michael Smart Date: Mon, 10 Apr 2017 14:06:49 -0400 Subject: [PATCH 5/6] Fix script to use correct path --- scripts/run-ci-tests.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/run-ci-tests.bash b/scripts/run-ci-tests.bash index df3ab2f..b0615e5 100644 --- a/scripts/run-ci-tests.bash +++ b/scripts/run-ci-tests.bash @@ -1,9 +1,11 @@ #!/bin/bash - set -e # exit on first error +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + source /opt/ros/${ROS_DISTRO}/setup.bash -source /ros_docker_ci/scripts/identify_environment.bash +# get UBUNTU_CODENAME, ROS_DISTRO, REPO_DIR, CATKIN_DIR +source $SCRIPT_DIR/identify_environment.bash sudo apt-get update From 132b0b10035239ef6c8d63d2a3c48ef0bd5bf6c2 Mon Sep 17 00:00:00 2001 From: Michael Smart Date: Tue, 18 Apr 2017 15:25:42 -0400 Subject: [PATCH 6/6] Reorganize test script --- scripts/run-ci-tests.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run-ci-tests.bash b/scripts/run-ci-tests.bash index b0615e5..03ea6bd 100644 --- a/scripts/run-ci-tests.bash +++ b/scripts/run-ci-tests.bash @@ -3,9 +3,9 @@ set -e # exit on first error SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source /opt/ros/${ROS_DISTRO}/setup.bash # get UBUNTU_CODENAME, ROS_DISTRO, REPO_DIR, CATKIN_DIR source $SCRIPT_DIR/identify_environment.bash +source /opt/ros/${ROS_DISTRO}/setup.bash sudo apt-get update