Last active
August 29, 2015 14:01
-
-
Save rkh/1ee2da1420fa28022fe5 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
curl https://gist.githubusercontent.com/rkh/1ee2da1420fa28022fe5/raw/travis.sh -sSL > travis | |
chmod +x travis | |
./travis install |
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
#!/usr/bin/env bash | |
export LC_CTYPE=en_US.UTF-8 | |
case $(uname) in | |
Darwin) | |
export TRAVIS_OS_NAME="osx" | |
export TRAVIS_OS_VERSION=$(sw_vers -productVersion);; | |
Linux) | |
export TRAVIS_OS_NAME=$(lsb_release -i -s | tr '[:upper:]' '[:lower:]') | |
export TRAVIS_OS_VERSION=$(lsb_release -r -s);; | |
*) | |
echo "$(uname) is currently not supported" | |
exit 1;; | |
esac | |
if [ -z "$TRAVIS_RUBY_VERSION" ]; then | |
case $TRAVIS_OS_NAME in | |
osx|ubuntu) export TRAVIS_RUBY_VERSION="2.1.2";; | |
centos) export TRAVIS_RUBY_VERSION="2.1.0";; | |
*) export TRAVIS_RUBY_VERSION="2.1.1";; | |
esac | |
fi | |
[ -z "$TRAVIS_VERSION" ] && export TRAVIS_VERSION="1.6.11" | |
[ -z "$TRAVIS_RUBY_LIB_VERSION" ] && export TRAVIS_RUBY_LIB_VERSION="2.1.0" | |
[ -z "$TRAVIS_CLI_SERVER" ] && export TRAVIS_CLI_SERVER="https://cli.travis-ci.org" | |
[ -z "$TRAVIS_PATH" ] && export TRAVIS_PATH="$HOME/.travis/$TRAVIS_VERSION" | |
[ $# = 0 ] || quoted_args="$(printf " %q" "$@")" | |
export GEM_HOME="$TRAVIS_PATH/vendor/ruby-$TRAVIS_RUBY_VERSION/lib/ruby/gems/$TRAVIS_RUBY_LIB_VERSION" | |
export GEM_PATH="$GEM_HOME" | |
unset RUBYLIB RUBYOPT | |
ruby="$TRAVIS_PATH/vendor/ruby-$TRAVIS_RUBY_VERSION/bin/ruby" | |
[ -z "$TRAVIS_COMMAND" ] && export TRAVIS_COMMAND=$(basename $0) | |
if [ "$TRAVIS_COMMAND" == "travis" ] && [ "$1" == "install" ]; then | |
rm -rf "$TRAVIS_PATH/vendor" | |
mkdir -p "$TRAVIS_PATH/vendor" | |
curl $TRAVIS_CLI_SERVER/ruby\?os_name\=$TRAVIS_OS_NAME\&os_version\=$TRAVIS_OS_VERSION\&ruby_version\=$TRAVIS_RUBY_VERSION\&os_arch\=$(uname -m) -fL -o "$TRAVIS_PATH/vendor/ruby.tar.bz2" | |
[ $? -eq 0 ] || exit $? | |
cd "$TRAVIS_PATH/vendor" | |
tar -jxPf ruby.tar.bz2 | |
cd - | |
echo 'source "https://rubygems.org"; gem "travis"' > "$TRAVIS_PATH/dependencies.rb" | |
retries=2 | |
while [ $retries -gt 0 ]; do | |
[ $retries -lt 2 ] && echo -e "\n\n\033[31;1m!!! Pay no attention to that man behind the curtain !!!\033[0m\n\n" | |
$ruby -S bundle install --gemfile="$TRAVIS_PATH/dependencies.rb" --standalone --path="$TRAVIS_PATH/vendor/bundle" --jobs=4 --retry=3 --no-cache --clean | |
result=$? | |
[ $result -eq 0 ] && break | |
retries=$(($retries - 1)) | |
done | |
rm -rf "$TRAVIS_PATH/dependencies.rb.lock" "$TRAVIS_PATH/.bundle" "$TRAVIS_PATH/vendor/ruby.tar.bz2" "$TRAVIS_PATH/dependencies.rb" | |
exit $result | |
fi | |
if [ ! -d $GEM_HOME ] || [ ! -d "$TRAVIS_PATH/vendor/bundle" ]; then | |
echo -e "\033[31mdependencies missing, please run \033[1mtravis install\033[0m" | |
exit 1 | |
fi | |
case $TRAVIS_COMMAND in | |
travis) exec "$ruby" --disable=gems -I "$TRAVIS_PATH/vendor/bundle" -r bundler/setup -r travis/cli -e 'Travis::CLI.run(ARGV)' -- $quoted_args;; | |
ruby) exec "$ruby" $quoted_args;; | |
rake|gem) exec "$ruby" -S $TRAVIS_COMMAND $quoted_args;; | |
*) | |
echo "unknown command $TRAVIS_COMMAND" >&2 | |
exit 1;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment