Skip to content

Commit

Permalink
Limit travis_run_wait timeout to actually remaining time
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Jan 25, 2019
1 parent 6bd687a commit 13e9106
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion check_clang_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ COUNTER=0
) &
cmd_pid=$! # main cmd PID

timeout=$(( $TRAVIS_GLOBAL_TIMEOUT - ($(date +%s) - $TRAVIS_GLOBAL_START_TIME) / 60 ))
# Use travis_jigger to generate some '.' outputs to convince Travis, we are not stuck.
travis_jigger $cmd_pid 10 "clang-tidy" &
travis_jigger $cmd_pid $timeout "clang-tidy" &
jigger_pid=$!

# Wait for main command to finish
Expand Down
2 changes: 2 additions & 0 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export CI_SOURCE_PATH=$(pwd) # The repository code in this pull request that we
export CI_PARENT_DIR=.moveit_ci # This is the folder name that is used in downstream repositories in order to point to this repo.
export REPOSITORY_NAME=${PWD##*/}
export CATKIN_WS=/root/ws_moveit
export TRAVIS_GLOBAL_TIMEOUT=49 # 50min minus slack
export TRAVIS_GLOBAL_START_TIME=$(date +%s)
echo "---"
echo "Testing branch '$TRAVIS_BRANCH' of '$REPOSITORY_NAME' on ROS '$ROS_DISTRO'"

Expand Down
7 changes: 6 additions & 1 deletion util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

#######################################
export TRAVIS_FOLD_COUNTER=0
TRAVIS_GLOBAL_TIMEOUT=${TRAVIS_GLOBAL_TIMEOUT:-49} # 50min minus slack
TRAVIS_GLOBAL_START_TIME=${TRAVIS_GLOBAL_START_TIME:-$(date +%s)}


#######################################
Expand Down Expand Up @@ -71,7 +73,6 @@ function travis_time_end {
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"
Expand Down Expand Up @@ -126,6 +127,9 @@ function travis_run_wait() {
# default value
timeout=20
fi
# limit to remaining time
local remaining=$(( $TRAVIS_GLOBAL_TIMEOUT - ($(date +%s) - $TRAVIS_GLOBAL_START_TIME) / 60 ))
if [ $remaining -le $timeout ] ; then timeout=$remaining; fi

local commands=$@
let "TRAVIS_FOLD_COUNTER += 1"
Expand Down Expand Up @@ -169,5 +173,6 @@ function travis_jigger() {
done

echo -e "\n\033[31;1mTimeout (${timeout} minutes) reached. Terminating \"$@\"\033[0m\n"
echo -e "\033[33;1mTry again. Having saved cache results, Travis will probably succeed next time.\033[0m\n"
kill -9 $cmd_pid
}

0 comments on commit 13e9106

Please sign in to comment.