Skip to content

Commit

Permalink
use docker in travis
Browse files Browse the repository at this point in the history
Former-commit-id: aa044ec
  • Loading branch information
jlblancoc committed Dec 6, 2017
1 parent 66fc969 commit d59f8bb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 66 deletions.
34 changes: 34 additions & 0 deletions .travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -x
set -e

apt-get update
apt-get install -y sudo software-properties-common wget # minimum deps for the commands below

echo "Testing branch $TRAVIS_BRANCH of $REPOSITORY_NAME"
sudo sh -c 'echo "deb http://packages.ros.org/ros-shadow-fixed/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
sudo add-apt-repository $MRPT_PPA -y
sudo apt-get update -qq
sudo apt-get install -qq -y python-rosdep
sudo rosdep init
rosdep update; while [ $? != 0 ]; do sleep 1; rosdep update; done

# Use rosdep to install all dependencies (including ROS itself)
rosdep install --from-paths ./ -i -y --rosdistro $CI_ROS_DISTRO

# ROS env vars:
source /opt/ros/$CI_ROS_DISTRO/setup.bash

# Setup catkin Workspace:
mkdir -p ~/catkin_ws/src
ln -s $CI_SOURCE_PATH ~/catkin_ws/src # Link the repo we are testing to the new workspace
cd ~/catkin_ws/

# Build [and Install] packages, build tests, and run tests
catkin_make_isolated --install --cmake-args -DCMAKE_BUILD_TYPE=Release
catkin_make_isolated --install --cmake-args -DCMAKE_BUILD_TYPE=Release --catkin-make-args tests
catkin_make_isolated --install --cmake-args -DCMAKE_BUILD_TYPE=Release --catkin-make-args run_tests
# Check results
catkin_test_results ./build_isolated
82 changes: 16 additions & 66 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,20 @@
#
# Use ubuntu trusty (14.04) with sudo privileges.
dist: trusty
# We cannot use latest ROS distributions in travis since we are limited to trusty
# So, let's use docker.
sudo: required
language:
- generic
cache:
- apt

# Configuration variables. All variables are global now, but this can be used to
# trigger a build matrix for different ROS distributions if desired.
dist: trusty
language: c++
notifications:
env:
global:
- ROS_DISTRO=indigo
- ROS_CI_DESKTOP="`lsb_release -cs`" # e.g. [precise|trusty|...]
- CI_SOURCE_PATH=$(pwd)
- ROSINSTALL_FILE=$CI_SOURCE_PATH/dependencies.rosinstall
- CATKIN_OPTIONS=$CI_SOURCE_PATH/catkin.options
- ROS_PARALLEL_JOBS='-j1 -l6'

################################################################################

# Install system dependencies, namely a very barebones ROS setup.
before_install:
- sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu $ROS_CI_DESKTOP main\" > /etc/apt/sources.list.d/ros-latest.list"
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
- sudo apt-get update -qq
- sudo apt-get install -y python-catkin-pkg python-rosdep python-wstool ros-$ROS_DISTRO-catkin
- source /opt/ros/$ROS_DISTRO/setup.bash
# Prepare rosdep to install dependencies.
- sudo rosdep init
- rosdep update -qq
- sudo apt-get install -y build-essential pkg-config cmake
- if [[ "$TASK" == "build_mrpt_ppa" ]] ; then sudo add-apt-repository ppa:joseluisblancoc/mrpt -y ; sudo apt-get update -qq ; fi
- sudo apt-get install -y libmrpt-dev

# Create a catkin workspace with the package under integration.
install:
- mkdir -p ~/catkin_ws/src
- cd ~/catkin_ws/src
- catkin_init_workspace
# Create the devel/setup.bash (run catkin_make with an empty workspace) and
# source it to set the path variables.
- cd ~/catkin_ws
- catkin_make
- source devel/setup.bash
# Add the package under integration to the workspace using a symlink.
- cd ~/catkin_ws/src
- ln -s $CI_SOURCE_PATH .

# Install all dependencies, using wstool and rosdep.
# wstool looks for a ROSINSTALL_FILE defined in the environment variables.
matrix:
- CI_ROS_DISTRO=kinetic MRPT_BRANCH="2.0" MRPT_PPA="ppa:joseluisblancoc/mrpt"
- CI_ROS_DISTRO=kinetic MRPT_BRANCH="1.5" MRPT_PPA="ppa:joseluisblancoc/mrpt-1.5"
# - ROS_DISTRO=kinetic BUILDER='catkin_make_isolated' BUILDER='catkin_make'
before_script:
# source dependencies: install using wstool.
- cd ~/catkin_ws/src
- wstool init
- if [[ -f $ROSINSTALL_FILE ]] ; then wstool merge $ROSINSTALL_FILE ; fi
- wstool up
# package depdencies: install using rosdep.
- cd ~/catkin_ws
- rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO

# Compile and test. If the CATKIN_OPTIONS file exists, use it as an argument to
# catkin_make.
- case $CI_ROS_DISTRO in "kinetic") export DISTRO=xenial;; "lunar") export DISTRO=xenial;; esac;
- export DOCKER_IMAGE=ubuntu:$DISTRO
- export CI_SOURCE_PATH=$(pwd)
- export REPOSITORY_NAME=${PWD##*/}
- if [ ! "$ROS_PARALLEL_JOBS" ]; then export ROS_PARALLEL_JOBS="-j8 -l8"; fi
- docker images
script:
- cd ~/catkin_ws
- catkin_make $( [ -f $CATKIN_OPTIONS ] && cat $CATKIN_OPTIONS )
# Testing: Use both run_tests (to see the output) and test (to error out).
- catkin_make run_tests # This always returns 0, but looks pretty.
- catkin_make test # This will return non-zero if a test fails.
- docker run -v $HOME:$HOME -e MRPT_PPA -e CI_SOURCE_PATH -e REPOSITORY_NAME -e HOME -e DISTRO -e CI_ROS_DISTRO -e ROS_PARALLEL_JOBS $DOCKER_IMAGE bash -c 'cd $CI_SOURCE_PATH; source .travis.sh'

0 comments on commit d59f8bb

Please sign in to comment.