Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci test branch #6

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
61 changes: 61 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
#
# 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
- DOCKER_CI_REL_DIR=.
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_CI_REL_DIR}/docker-setup-ci.bash

# Execute the CI script using the docker container
#
# 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 scripts/run-ci-tests.bash

# Cache the docker container if it was rebuilt above.
before_cache:
- bash ${DOCKER_CI_REL_DIR}/save-docker-cache-ci.bash

cache:
directories:
- $HOME/docker_cache
timeout: 1200
44 changes: 44 additions & 0 deletions scripts/create_catkin_workspace.bash
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions scripts/identify_environment.bash
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 5 additions & 0 deletions scripts/install_deps_for_docker_ci.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

source /scripts/ros_install.bash
source /scripts/create_catkin_workspace.bash
40 changes: 40 additions & 0 deletions scripts/ros_install.bash
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions scripts/run-ci-tests.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/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
source /opt/ros/${ROS_DISTRO}/setup.bash

sudo apt-get update

cd ${CATKIN_DIR}

catkin build --no-status