-
-
Save meatballhat/dd3b723a25082aea0586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source /etc/profile | |
ANSI_RED="\033[31;1m" | |
ANSI_GREEN="\033[32;1m" | |
ANSI_RESET="\033[0m" | |
ANSI_CLEAR="\033[0K" | |
TRAVIS_TEST_RESULT= | |
TRAVIS_CMD= | |
function travis_cmd() { | |
local assert output display retry timing cmd result | |
cmd=$1 | |
TRAVIS_CMD=$cmd | |
shift | |
while true; do | |
case "$1" in | |
--assert) assert=true; shift ;; | |
--echo) output=true; shift ;; | |
--display) display=$2; shift 2;; | |
--retry) retry=true; shift ;; | |
--timing) timing=true; shift ;; | |
*) break ;; | |
esac | |
done | |
if [[ -n "$timing" ]]; then | |
travis_time_start | |
fi | |
if [[ -n "$output" ]]; then | |
echo "\$ ${display:-$cmd}" | |
fi | |
if [[ -n "$retry" ]]; then | |
travis_retry eval "$cmd" | |
else | |
eval "$cmd" | |
fi | |
result=$? | |
if [[ -n "$timing" ]]; then | |
travis_time_finish | |
fi | |
if [[ -n "$assert" ]]; then | |
travis_assert $result | |
fi | |
return $result | |
} | |
travis_time_start() { | |
travis_timer_id=$(printf %08x $(( RANDOM * RANDOM ))) | |
travis_start_time=$(travis_nanoseconds) | |
echo -en "travis_time:start:$travis_timer_id\r${ANSI_CLEAR}" | |
} | |
travis_time_finish() { | |
local result=$? | |
travis_end_time=$(travis_nanoseconds) | |
local duration=$(($travis_end_time-$travis_start_time)) | |
echo -en "travis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration\r${ANSI_CLEAR}" | |
return $result | |
} | |
function travis_nanoseconds() { | |
local cmd="date" | |
local format="+%s%N" | |
local os=$(uname) | |
if hash gdate > /dev/null 2>&1; then | |
cmd="gdate" # use gdate if available | |
elif [[ "$os" = Darwin ]]; then | |
format="+%s000000000" # fallback to second precision on darwin (does not support %N) | |
fi | |
$cmd -u $format | |
} | |
travis_assert() { | |
local result=${1:-$?} | |
if [ $result -ne 0 ]; then | |
echo -e "\n${ANSI_RED}The command \"$TRAVIS_CMD\" failed and exited with $result during $TRAVIS_STAGE.${ANSI_RESET}\n\nYour build has been stopped." | |
travis_terminate 2 | |
fi | |
} | |
travis_result() { | |
local result=$1 | |
export TRAVIS_TEST_RESULT=$(( ${TRAVIS_TEST_RESULT:-0} | $(($result != 0)) )) | |
if [ $result -eq 0 ]; then | |
echo -e "\n${ANSI_GREEN}The command \"$TRAVIS_CMD\" exited with $result.${ANSI_RESET}" | |
else | |
echo -e "\n${ANSI_RED}The command \"$TRAVIS_CMD\" exited with $result.${ANSI_RESET}" | |
fi | |
} | |
travis_terminate() { | |
pkill -9 -P $$ &> /dev/null || true | |
exit $1 | |
} | |
travis_wait() { | |
local timeout=$1 | |
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="$@" | |
local log_file=travis_wait_$$.log | |
$cmd &>$log_file & | |
local cmd_pid=$! | |
travis_jigger $! $timeout $cmd & | |
local jigger_pid=$! | |
local result | |
{ | |
wait $cmd_pid 2>/dev/null | |
result=$? | |
ps -p$jigger_pid &>/dev/null && kill $jigger_pid | |
} || return 1 | |
if [ $result -eq 0 ]; then | |
echo -e "\n${ANSI_GREEN}The command \"$TRAVIS_CMD\" exited with $result.${ANSI_RESET}" | |
else | |
echo -e "\n${ANSI_RED}The command \"$TRAVIS_CMD\" exited with $result.${ANSI_RESET}" | |
fi | |
echo -e "\n${ANSI_GREEN}Log:${ANSI_RESET}\n" | |
cat $log_file | |
return $result | |
} | |
travis_jigger() { | |
# helper method for travis_wait() | |
local cmd_pid=$1 | |
shift | |
local timeout=$1 # in minutes | |
shift | |
local count=0 | |
# clear the line | |
echo -e "\n" | |
while [ $count -lt $timeout ]; do | |
count=$(($count + 1)) | |
echo -ne "Still running ($count of $timeout): $@\r" | |
sleep 60 | |
done | |
echo -e "\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"$@\"${ANSI_RESET}\n" | |
kill -9 $cmd_pid | |
} | |
travis_retry() { | |
local result=0 | |
local count=1 | |
while [ $count -le 3 ]; do | |
[ $result -ne 0 ] && { | |
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2 | |
} | |
"$@" | |
result=$? | |
[ $result -eq 0 ] && break | |
count=$(($count + 1)) | |
sleep 1 | |
done | |
[ $count -gt 3 ] && { | |
echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2 | |
} | |
return $result | |
} | |
travis_fold() { | |
local action=$1 | |
local name=$2 | |
echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}" | |
} | |
decrypt() { | |
echo $1 | base64 -d | openssl rsautl -decrypt -inkey ~/.ssh/id_rsa.repo | |
} | |
mkdir -p $HOME/build | |
cd $HOME/build | |
travis_fold start system_info | |
echo -e "\033[33;1mBuild system information\033[0m" | |
echo -e "Build language: generic" | |
if [[ -f /usr/share/travis/system_info ]]; then | |
cat /usr/share/travis/system_info | |
fi | |
travis_fold end system_info | |
echo | |
echo "options rotate | |
options timeout:1 | |
nameserver 8.8.8.8 | |
nameserver 8.8.4.4 | |
nameserver 208.67.222.222 | |
nameserver 208.67.220.220 | |
" | sudo tee /etc/resolv.conf &> /dev/null | |
sudo sed -e 's/^\(127\.0\.0\.1.*\)$/\1 '`hostname`'/' -i'.bak' /etc/hosts | |
export GIT_ASKPASS=echo | |
travis_fold start git.checkout | |
if [[ ! -d meatballhat/cloaked-octo-tyrion/.git ]]; then | |
travis_cmd git\ clone\ --depth\=50\ --branch\=master\ git://github.com/meatballhat/cloaked-octo-tyrion.git\ meatballhat/cloaked-octo-tyrion --assert --echo --retry --timing | |
else | |
travis_cmd git\ -C\ meatballhat/cloaked-octo-tyrion\ fetch\ origin --assert --echo --retry --timing | |
travis_cmd git\ -C\ meatballhat/cloaked-octo-tyrion\ reset\ --hard --assert --echo | |
fi | |
travis_cmd cd\ meatballhat/cloaked-octo-tyrion --echo | |
travis_cmd git\ checkout\ -qf\ 1d52e9c1d626c64b29dd4658aac423c1b145d87b --assert --echo | |
travis_fold end git.checkout | |
if [[ -f .gitmodules ]]; then | |
travis_fold start git.submodule | |
echo Host\ github.com' | |
'\ StrictHostKeyChecking\ no' | |
' >> ~/.ssh/config | |
travis_cmd git\ submodule\ init --assert --echo --timing | |
travis_cmd git\ submodule\ update --assert --echo --retry --timing | |
travis_fold end git.submodule | |
fi | |
rm -f ~/.ssh/source_rsa | |
export PS4=+ | |
export TRAVIS=true | |
export CI=true | |
export CONTINUOUS_INTEGRATION=true | |
export HAS_JOSH_K_SEAL_OF_APPROVAL=true | |
export TRAVIS_PULL_REQUEST=false | |
export TRAVIS_SECURE_ENV_VARS=false | |
export TRAVIS_BUILD_ID=54882302 | |
export TRAVIS_BUILD_NUMBER=70 | |
export TRAVIS_BUILD_DIR=$HOME/build/meatballhat/cloaked-octo-tyrion | |
export TRAVIS_JOB_ID=54882303 | |
export TRAVIS_JOB_NUMBER=70.1 | |
export TRAVIS_BRANCH=master | |
export TRAVIS_COMMIT=1d52e9c1d626c64b29dd4658aac423c1b145d87b | |
export TRAVIS_COMMIT_RANGE=6328bc716868...1d52e9c1d626 | |
export TRAVIS_REPO_SLUG=meatballhat/cloaked-octo-tyrion | |
export TRAVIS_OS_NAME=linux | |
export TRAVIS_LANGUAGE=generic | |
export TRAVIS_TAG='' | |
travis_fold start install | |
travis_cmd echo\ install --assert --echo --timing | |
travis_fold end install | |
travis_cmd echo\ script --echo --timing | |
travis_result $? | |
echo -e "\nDone. Your build exited with $TRAVIS_TEST_RESULT." | |
travis_terminate $TRAVIS_TEST_RESULT |
HAS_JOSH_K_SEAL_OF_APPROVAL
is clearly the important bit here 👍
Oups, I didn't see your comments, I will continue here so I don't notify all the followers :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the the script generated by travis-build for https://travis-ci.org/meatballhat/cloaked-octo-tyrion/builds/54882302.