language: generic
services:
  - docker

branches:
  except:
    - /^rpm/kinetic/xenial/.*$/  # not testing rpm builds in xenial
    - /^debian/kinetic/xenial/.*$/ # not testing pacakge building here (ROS buildfarm will do it)

  only:
    # We can test release or upstream after patches have been applied
    - /^release/.*$/ 
    - upstream 

# this is a third party package, we check only usual catkin builds.
# Let the ros buildfarm check the actual deb package build.

env:
  global:
    - CONTAINER_NAME=ftputil_docker
  # This will check any ROS distro supported on this OS
  # checking devel and install separately so that they don't influence each other (dependencies, path, env, etc.)
  matrix:
  - ROS_DISTRO=kinetic ROS_FLOW=devel
  - ROS_DISTRO=kinetic ROS_FLOW=install

before_install:
  # Getting docker ros image
  - docker pull ros:${ROS_DISTRO}-ros-core
  # Running as daemon
  - docker run --name ${CONTAINER_NAME} -d -t ros:${ROS_DISTRO}-ros-core /bin/bash | tee container.id
  # Switching to use ros shadow fixed packages
  - docker exec -ti ${CONTAINER_NAME} /bin/bash -c "sed -i.bak -e s,packages.ros.org/ros/ubuntu,packages.ros.org/ros-shadow-fixed/ubuntu, /etc/apt/sources.list.d/ros-latest.list"
  # Checking current container
  - docker ps -a
  - docker exec -ti ${CONTAINER_NAME} hostname
  - docker exec -ti ${CONTAINER_NAME} uname -a
  - docker exec -ti ${CONTAINER_NAME} cat /etc/lsb-release


install:
  # refreshing packages
  - docker exec -ti ${CONTAINER_NAME} apt-get update
  # TMP Patch because rosdep doesnt declare a dependency to sudo yet (2016-08-25) and it doesnt come with xenial
  - docker exec -ti ${CONTAINER_NAME} apt-get install sudo
  - docker exec -ti ${CONTAINER_NAME} rosdep update
  # copying local clone to the running container (volume is currently broken)
  - docker cp . ${CONTAINER_NAME}:/git_clone
  # Installing package dependencies
  - docker exec -ti ${CONTAINER_NAME} rosdep install --default-yes --from-paths /git_clone --rosdistro $ROS_DISTRO

# full ROS setup, build and test
script:
  - CONTAINER_ID=$(cat container.id)
  - docker ps -a
  - docker exec -ti ${CONTAINER_NAME} /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash && rospack profile"
  # Passing env vars here since passing in docker run currently breaks (2016-08-25)
  - docker exec -ti ${CONTAINER_NAME} /bin/bash -c "export ROS_DISTRO=$ROS_DISTRO && export ROS_FLOW=$ROS_FLOW && bash /git_clone/travis_checks.bash"
  - docker stop "${CONTAINER_ID}"


notifications:
  email: false

