From c90971cbe582fdb8b04f9dd7bb65a037c24c6e55 Mon Sep 17 00:00:00 2001 From: Francesco Savarese Date: Tue, 2 Jun 2020 15:07:37 +0900 Subject: [PATCH 1/4] added rosinstall file for move_base_flex --- move_base_flex.rosinstall | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 move_base_flex.rosinstall diff --git a/move_base_flex.rosinstall b/move_base_flex.rosinstall new file mode 100644 index 00000000..dc41eda0 --- /dev/null +++ b/move_base_flex.rosinstall @@ -0,0 +1,4 @@ +- git: + local-name: move_base_flex + uri: git@github.com:rapyuta-robotics/move_base_flex.git + version: state_machine From fbf0fcccb3b77609791bce09777b29596ad31018 Mon Sep 17 00:00:00 2001 From: Francesco Savarese Date: Tue, 2 Jun 2020 16:48:22 +0900 Subject: [PATCH 2/4] updated the rosinstall file and changed the name in move_baseflex_CI.rosinstall --- move_base_flex.rosinstall | 4 ---- move_base_flex_CI.rosinstall | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) delete mode 100644 move_base_flex.rosinstall create mode 100644 move_base_flex_CI.rosinstall diff --git a/move_base_flex.rosinstall b/move_base_flex.rosinstall deleted file mode 100644 index dc41eda0..00000000 --- a/move_base_flex.rosinstall +++ /dev/null @@ -1,4 +0,0 @@ -- git: - local-name: move_base_flex - uri: git@github.com:rapyuta-robotics/move_base_flex.git - version: state_machine diff --git a/move_base_flex_CI.rosinstall b/move_base_flex_CI.rosinstall new file mode 100644 index 00000000..58b61839 --- /dev/null +++ b/move_base_flex_CI.rosinstall @@ -0,0 +1,9 @@ +- git: + local-name: forklift_interfaces + uri: git@github.com:rapyuta-robotics/forklift_interfaces.git + version: devel + +- git: + local-name: rr_navigation + uri: git@github.com:rapyuta-robotics/rr_navigation.git + version: devel From c4975cc56a9ea5db7aac5fc8586acc440b934a67 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Tue, 2 Jun 2020 17:42:33 +0900 Subject: [PATCH 3/4] Added travis ci related files and created dockerfile --- .gitignore | 1 - .travis.yml | 34 ++----- .travis/build.sh | 15 +++ .travis/build_in_docker.sh | 11 +++ .travis/util.sh | 182 +++++++++++++++++++++++++++++++++++++ Dockerfile.ci | 31 +++++++ 6 files changed, 248 insertions(+), 26 deletions(-) create mode 100644 .travis/build.sh create mode 100644 .travis/build_in_docker.sh create mode 100644 .travis/util.sh create mode 100644 Dockerfile.ci diff --git a/.gitignore b/.gitignore index 97c429a1..ab1129da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -.* !/.gitignore diff --git a/.travis.yml b/.travis.yml index bcf55a8a..d85d789a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,14 @@ sudo: required language: generic -dist: trusty +dist: bionic -notifications: - email: - recipients: - - spuetz@uos.de - on_success: change - on_failure: change - -matrix: - include: - - name: "Indigo" - env: ROS_DISTRO=indigo - - - name: "Kinetic" - env: ROS_DISTRO=kinetic - - - name: "Lunar" - env: ROS_DISTRO=lunar - - - name: "Melodic" - env: ROS_DISTRO=melodic - -install: - - git clone https://github.com/ros-industrial/industrial_ci.git .ci_config +env: + global: + - ROS_DISTRO=melodic + - CI_SOURCE_PATH=$(pwd) + - CI_PARENT_DIR=.travis + matrix: + - TEST=build DOCKER_IMAGE=mbf_ci:latest script: - - .ci_config/travis.sh + - source $CI_PARENT_DIR/$TEST.sh \ No newline at end of file diff --git a/.travis/build.sh b/.travis/build.sh new file mode 100644 index 00000000..315f9136 --- /dev/null +++ b/.travis/build.sh @@ -0,0 +1,15 @@ +export REPOSITORY_NAME=${PWD##*/} +echo "Testing branch '$TRAVIS_BRANCH' of '$REPOSITORY_NAME' on ROS '$ROS_DISTRO'" + +# Start Docker container +cp ~/.ssh/id_rsa id_rsa && docker build -t $DOCKER_IMAGE -f Dockerfile.ci $CI_SOURCE_PATH +docker_result=$? +rm id_rsa + +# Check if docker ran successfully +if [ $docker_result -ne 0 ]; then + echo "$DOCKER_IMAGE container finished with errors" + exit 1 # error +fi +echo "$DOCKER_IMAGE container finished successfully" +exit 0 \ No newline at end of file diff --git a/.travis/build_in_docker.sh b/.travis/build_in_docker.sh new file mode 100644 index 00000000..625dfa84 --- /dev/null +++ b/.travis/build_in_docker.sh @@ -0,0 +1,11 @@ + +#!/bin/bash +source /opt/ros/melodic/setup.bash +source src/mbf/.travis/util.sh + +travis_run catkin init +travis_run rosdep update --as-root apt:false +travis_run rosdep install --from-paths src --ignore-src --rosdistro melodic -y -r + +travis_run catkin config --extend /opt/ros/melodic --cmake-args -DCMAKE_BUILD_TYPE=Release +travis_run_wait 60 catkin build move_base_flex diff --git a/.travis/util.sh b/.travis/util.sh new file mode 100644 index 00000000..9eacad0f --- /dev/null +++ b/.travis/util.sh @@ -0,0 +1,182 @@ +#!/bin/bash +#******************************************************************** +# Software License Agreement (BSD License) +# +# Copyright (c) 2016, University of Colorado, Boulder +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the Univ of CO, Boulder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +#********************************************************************/ + +# Author: Dave Coleman , Robert Haschke +# Desc: Utility functions used to make CI work better in Travis + +####################################### +export TRAVIS_FOLD_COUNTER=0 + + +####################################### +# Start a Travis fold with timer +# +# Arguments: +# travis_fold_name: name of line +# command: action to run +####################################### +function travis_time_start { + TRAVIS_START_TIME=$(date +%s%N) + TRAVIS_TIME_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1) + TRAVIS_FOLD_NAME=$1 + local COMMAND=${@:2} # all arguments except the first + + # Start fold + echo -e "\e[0Ktravis_fold:start:$TRAVIS_FOLD_NAME" + # Output command being executed + echo -e "\e[0Ktravis_time:start:$TRAVIS_TIME_ID\e[34m$COMMAND\e[0m" +} + +####################################### +# Wraps up the timer section on Travis CI (that's started mostly by travis_time_start function). +# +# Arguments: +# travis_fold_name: name of line +####################################### +function travis_time_end { + if [ -z $TRAVIS_START_TIME ]; then + echo '[travis_time_end] var TRAVIS_START_TIME is not set. You need to call `travis_time_start` in advance.'; + return; + fi + local TRAVIS_END_TIME=$(date +%s%N) + local TIME_ELAPSED_SECONDS=$(( ($TRAVIS_END_TIME - $TRAVIS_START_TIME)/1000000000 )) + + # Output Time + echo -e "travis_time:end:$TRAVIS_TIME_ID:start=$TRAVIS_START_TIME,finish=$TRAVIS_END_TIME,duration=$(($TRAVIS_END_TIME - $TRAVIS_START_TIME))\e[0K" + # End fold + echo -e -n "travis_fold:end:$TRAVIS_FOLD_NAME\e[0m" + + unset TRAVIS_START_TIME + unset TRAVIS_TIME_ID + unset TRAVIS_FOLD_NAME +} + +####################################### +# Display command in Travis console and fold output in dropdown section +# +# Arguments: +# command: action to run +####################################### +function travis_run_impl() { + local command=$@ + + let "TRAVIS_FOLD_COUNTER += 1" + travis_time_start moveit_ci.$TRAVIS_FOLD_COUNTER $command + # actually run command + $command + result=$? + travis_time_end + return $result +} + +####################################### +# Run a command and do folding and timing for it +# Return the exit status of the command +function travis_run() { + travis_run_impl $@ || exit $? +} + +####################################### +# Same as travis_run but return 0 exit status, thus ignoring any error +function travis_run_true() { + travis_run_impl $@ || return 0 +} + +####################################### +# Same as travis_run, but issue some output regularly to indicate that the process is still alive +# from: https://github.com/travis-ci/travis-build/blob/d63c9e95d6a2dc51ef44d2a1d96d4d15f8640f22/lib/travis/build/script/templates/header.sh +function travis_run_wait() { + local timeout=$1 # in minutes + + if [[ $timeout =~ ^[0-9]+$ ]]; then + # looks like an integer, so we assume it's a timeout + shift + else + # default value + timeout=20 + fi + + local cmd=$@ + let "TRAVIS_FOLD_COUNTER += 1" + travis_time_start moveit_ci.$TRAVIS_FOLD_COUNTER $cmd + + # Disable bash's job control messages + set +m + # Run actual command in background + $cmd & + local cmd_pid=$! + + travis_jigger $cmd_pid $timeout $cmd & + local jigger_pid=$! + local result + + { + wait $cmd_pid 2>/dev/null + result=$? + # if process finished before jigger, stop the jigger too + ps -p$jigger_pid 2>&1>/dev/null && kill $jigger_pid + } + + echo + travis_time_end + + return $result +} + +####################################### +function travis_jigger() { + local cmd_pid=$1 + shift + local timeout=$1 + shift + local count=0 + + echo -n "Waiting for process to finish " + while [ $count -lt $timeout ]; do + count=$(($count + 1)) + echo -ne "." + sleep 60 # wait 60s + done + + echo -e "\n\033[31;1mTimeout (${timeout} minutes) reached. Terminating \"$@\"\033[0m\n" + kill -9 $cmd_pid +} + +# unify_list SEPARATORS LIST +# replace all separator chars given as first argument with spaces +unify_list() { + local separators=$1; shift + echo "$*" | tr "$separators" ' ' +} diff --git a/Dockerfile.ci b/Dockerfile.ci new file mode 100644 index 00000000..28d79a19 --- /dev/null +++ b/Dockerfile.ci @@ -0,0 +1,31 @@ +FROM rrdockerhub/ros-base-melodic-amd64:latest + +RUN mkdir -p /root/catkin_ws/src/.travis +WORKDIR /root/catkin_ws + +COPY ./mbf_ci.rosinstall src/.rosinstall +COPY ./.travis src/mbf/.travis + + +# Setup for ssh onto github & bitbucket +# Before running Docker, run locally: `cp ~/.ssh/id_rsa_unsafe id_rsa` +RUN bash -c "source src/mbf/.travis/util.sh && travis_run apt-get update && travis_run apt-get -qq install -y ssh" +RUN mkdir -p /root/.ssh +COPY id_rsa /root/.ssh/id_rsa +RUN chmod 700 /root/.ssh/id_rsa + +RUN ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts +RUN ssh-keyscan -t rsa bitbucket.org >> ~/.ssh/known_hosts + +RUN wstool update -t src --abort-changed-uris + +### Stage 2: Build ### +FROM rrdockerhub/ros-base-melodic-amd64:latest +COPY --from=0 /root/catkin_ws /root/catkin_ws +WORKDIR /root/catkin_ws +COPY . src/mbf + +# Remove this line if we can get python-catkin-tools to be in the base image +RUN bash -c "source src/mbf/.travis/util.sh && travis_run apt-get update && travis_run apt-get -qq install -y python-catkin-tools" + +RUN ./src/mbf/.travis/build_in_docker.sh \ No newline at end of file From db0cfe080282e547361c7b1637f9db2f81e18ae9 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Tue, 2 Jun 2020 17:45:37 +0900 Subject: [PATCH 4/4] updated rosinstall filename in dockerfile --- Dockerfile.ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.ci b/Dockerfile.ci index 28d79a19..8c77bf6f 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -3,7 +3,7 @@ FROM rrdockerhub/ros-base-melodic-amd64:latest RUN mkdir -p /root/catkin_ws/src/.travis WORKDIR /root/catkin_ws -COPY ./mbf_ci.rosinstall src/.rosinstall +COPY ./move_base_flex_CI.rosinstall src/.rosinstall COPY ./.travis src/mbf/.travis