2017-04-09 08:42:16 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-02-19 17:39:05 +00:00
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
|
2016-02-19 08:00:59 +00:00
|
|
|
ANSI_RED="\033[31;1m"
|
2017-04-09 08:42:16 +00:00
|
|
|
# shellcheck disable=SC2034
|
2016-02-19 08:00:59 +00:00
|
|
|
ANSI_GREEN="\033[32;1m"
|
|
|
|
ANSI_RESET="\033[0m"
|
2017-04-09 08:42:16 +00:00
|
|
|
# shellcheck disable=SC2034
|
2016-02-19 08:00:59 +00:00
|
|
|
ANSI_CLEAR="\033[0K"
|
|
|
|
|
|
|
|
travis_retry() {
|
2017-04-11 09:28:01 +00:00
|
|
|
local result=0
|
|
|
|
local count=1
|
|
|
|
set +e
|
2016-02-19 17:39:05 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
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
|
2016-02-19 08:00:59 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
[ $count -gt 3 ] && {
|
|
|
|
echo -e "\n${ANSI_RED}The command \"$*\" failed 3 times.${ANSI_RESET}\n" >&2
|
|
|
|
}
|
2016-02-19 08:00:59 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
set -e
|
|
|
|
return $result
|
2016-02-19 08:00:59 +00:00
|
|
|
}
|
|
|
|
|
2016-02-26 08:23:03 +00:00
|
|
|
retry_cmd() {
|
2017-04-11 09:28:01 +00:00
|
|
|
local result=0
|
|
|
|
local count=1
|
|
|
|
set +e
|
2016-02-26 08:23:03 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
retry_cnt=$1
|
|
|
|
shift 1
|
2016-02-26 08:23:03 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
while [ $count -le "${retry_cnt}" ]; do
|
|
|
|
[ $result -ne 0 ] && {
|
|
|
|
echo -e "\n${ANSI_RED}The command \"$*\" failed. Retrying, $count of ${retry_cnt}${ANSI_RESET}\n" >&2
|
|
|
|
}
|
|
|
|
"$@"
|
|
|
|
result=$?
|
|
|
|
[ $result -eq 0 ] && break
|
|
|
|
count=$((count + 1))
|
|
|
|
sleep 1
|
|
|
|
done
|
2016-02-26 08:23:03 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
[ $count -gt "${retry_cnt}" ] && {
|
|
|
|
echo -e "\n${ANSI_RED}The command \"$*\" failed ${retry_cnt} times.${ANSI_RESET}\n" >&2
|
|
|
|
}
|
2016-02-26 08:23:03 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
set -e
|
|
|
|
return $result
|
2016-02-26 08:23:03 +00:00
|
|
|
}
|
|
|
|
|
2017-09-07 04:26:20 +00:00
|
|
|
# export CI_BUILD_DIR=${TRAVIS_BUILD_DIR}
|
|
|
|
# use eval to get fully expanded path
|
|
|
|
eval CI_BUILD_DIR="${CIRCLE_WORKING_DIRECTORY}"
|
|
|
|
export CI_BUILD_DIR
|
|
|
|
|
|
|
|
test -e "${HOME}/bin" || mkdir "${HOME}/bin"
|
|
|
|
export PATH=$PWD/bin:$HOME/bin:$PATH
|
|
|
|
export PATH=$PATH:${CI_BUILD_DIR}/install/bin
|
|
|
|
if [ -f "${CI_BUILD_DIR}/install/bin/luarocks" ]; then
|
2016-02-19 08:00:59 +00:00
|
|
|
# add local rocks to $PATH
|
2017-04-09 08:42:16 +00:00
|
|
|
eval "$(luarocks path --bin)"
|
2016-02-19 08:00:59 +00:00
|
|
|
fi
|