From 8d365c4359a1de47778a91494b3c6f4686fa2c6a Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Sat, 25 Jan 2014 09:32:04 -0800 Subject: [PATCH] Updated travis build scripts (from rspec-dev) --- .travis.yml | 18 +++--- maintenance-branch | 1 + script/clone_all_rspec_repos | 20 ++++++ script/functions.sh | 114 +++++++++++++++++++++++++++++++++++ script/run_build | 19 ++++++ script/test_all | 40 ------------ 6 files changed, 162 insertions(+), 50 deletions(-) create mode 100644 maintenance-branch create mode 100755 script/clone_all_rspec_repos create mode 100644 script/functions.sh create mode 100755 script/run_build delete mode 100755 script/test_all diff --git a/.travis.yml b/.travis.yml index a26555e3d..b5970932f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,23 @@ -before_install: - - gem update bundler - - bundle --version - - gem update --system 2.1.11 - - gem --version -bundler_args: "--standalone --binstubs --without documentation" -script: "script/test_all" +# This file was generated on 2014-01-25T09:32:04-08:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +before_install: "script/clone_all_rspec_repos" +bundler_args: "--binstubs --standalone --without documentation --path ../bundle" +script: "script/run_build" rvm: - 1.8.7 - 1.9.2 - 1.9.3 - 2.0.0 - 2.1.0 + - ruby-head + - ree - jruby-18mode - jruby-19mode - jruby-head - rbx - - ree - - ruby-head matrix: allow_failures: - rvm: jruby-head - rvm: ruby-head fast_finish: true - diff --git a/maintenance-branch b/maintenance-branch new file mode 100644 index 000000000..8b25206ff --- /dev/null +++ b/maintenance-branch @@ -0,0 +1 @@ +master \ No newline at end of file diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos new file mode 100755 index 000000000..12ecda828 --- /dev/null +++ b/script/clone_all_rspec_repos @@ -0,0 +1,20 @@ +#!/bin/bash +# This file was generated on 2014-01-25T09:32:04-08:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +set -e -x +source script/functions.sh + +if is_mri; then + pushd .. + + clone_repo "rspec" + clone_repo "rspec-core" + clone_repo "rspec-expectations" + clone_repo "rspec-mocks" + clone_repo "rspec-support" + + popd +else + echo "Not cloning all repos since we are not on MRI and they are only needed for the MRI build" +fi diff --git a/script/functions.sh b/script/functions.sh new file mode 100644 index 000000000..3855d648c --- /dev/null +++ b/script/functions.sh @@ -0,0 +1,114 @@ +# This file was generated on 2014-01-25T09:32:04-08:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +# idea taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html +export JRUBY_OPTS='-X-C' # disable JIT since these processes are so short lived +SPECS_HAVE_RUN_FILE=specs.out +MAINTENANCE_BRANCH=`cat maintenance-branch` +BUNDLE_INSTALL_FLAGS=`cat .travis.yml | grep bundler_args | tr -d '"' | grep -o " .*"` + +# Taken from: +# https://github.com/travis-ci/travis-build/blob/e9314616e182a23e6a280199cd9070bfc7cae548/lib/travis/build/script/templates/header.sh#L34-L53 +travis_retry() { + local result=0 + local count=1 + while [ $count -le 3 ]; do + [ $result -ne 0 ] && { + echo -e "\n\033[33;1mThe command \"$@\" failed. Retrying, $count of 3.\033[0m\n" >&2 + } + "$@" + result=$? + [ $result -eq 0 ] && break + count=$(($count + 1)) + sleep 1 + done + + [ $count -eq 3 ] && { + echo "\n\033[33;1mThe command \"$@\" failed 3 times.\033[0m\n" >&2 + } + + return $result +} + +function is_mri { + if ruby -e "exit(!defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby')"; then + # RUBY_ENGINE only returns 'ruby' on MRI. + # MRI 1.8.7 lacks the constant but all other rubies have it (including JRuby in 1.8 mode) + return 0 + else + return 1 + fi; +} + +function is_mri_192 { + if is_mri; then + if ruby -e "exit(RUBY_VERSION == '1.9.2')"; then + return 0 + else + return 1 + fi + else + return 1 + fi +} + +function clone_repo { + if [ ! -d $1 ]; then # don't clone if the dir is already there + travis_retry git clone git://github.com/rspec/$1 --depth 1 --branch $MAINTENANCE_BRANCH + fi; +} + +function run_specs_and_record_done { + local rspec_bin=bin/rspec + + # rspec-core needs to run with a special script that loads simplecov first, + # so that it can instrument rspec-core's code before rspec-core has been loaded. + if [ -f script/rspec_with_simplecov ]; then + rspec_bin=script/rspec_with_simplecov + fi; + + $rspec_bin spec --backtrace --format progress --profile --format progress --out $SPECS_HAVE_RUN_FILE +} + +function run_cukes { + if [ -d features ]; then + # force jRuby to use client mode JVM or a compilation mode thats as close as possible, + # idea taken from https://github.com/jruby/jruby/wiki/Improving-startup-time + # + # Note that we delay setting this until we run the cukes because we've seen + # spec failures in our spec suite due to problems with this mode. + export JAVA_OPTS='-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1' + + if is_mri_192; then + # For some reason we get SystemStackError on 1.9.2 when using + # the bin/cucumber approach below. That approach is faster + # (as it avoids the bundler tax), so we use it on rubies where we can. + bundle exec cucumber --strict + else + # Prepare RUBYOPT for scenarios that are shelling out to ruby, + # and PATH for those that are using `rspec` or `rake`. + RUBYOPT="-I${PWD}/../bundle -rbundler/setup" \ + PATH="${PWD}/bin:$PATH" \ + bin/cucumber --strict + fi + fi +} + +function run_specs_one_by_one { + for file in `find spec -iname '*_spec.rb'`; do + bin/rspec $file -b --format progress + done +} + +function run_spec_suite_for { + if [ ! -f ../$1/$SPECS_HAVE_RUN_FILE ]; then # don't rerun specs that have already run + pushd ../$1 + echo + echo "Running specs for $1" + echo + unset BUNDLE_GEMFILE + travis_retry bundle install $BUNDLE_INSTALL_FLAGS + run_specs_and_record_done + popd + fi; +} diff --git a/script/run_build b/script/run_build new file mode 100755 index 000000000..3fbf66dff --- /dev/null +++ b/script/run_build @@ -0,0 +1,19 @@ +#!/bin/bash +# This file was generated on 2014-01-25T09:32:04-08:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +set -e -x +source script/functions.sh + +run_specs_and_record_done +run_cukes + +if is_mri; then + run_specs_one_by_one + run_spec_suite_for "rspec-core" + run_spec_suite_for "rspec-expectations" + run_spec_suite_for "rspec-mocks" + run_spec_suite_for "rspec-support" +else + echo "Skipping the rest of the build on non-MRI rubies" +fi diff --git a/script/test_all b/script/test_all deleted file mode 100755 index 71445f54c..000000000 --- a/script/test_all +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -e -x - -function is_jruby() { - if ruby -e 'exit RUBY_PLATFORM == "java"'; then - return 0 - else - return 1 - fi -} - -# idea taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html -export JRUBY_OPTS='-X-C' # disable JIT since these processes are so short lived - -# force jRuby to use client mode JVM or a compilation mode thats as close as possible, -# idea taken from https://github.com/jruby/jruby/wiki/Improving-startup-time -export JAVA_OPTS='-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1' - -echo "Running all..." -bin/rspec spec --format progress --profile - -echo -echo "--------------------------------------------------------------------" -echo - -if is_jruby; then - echo "Skipping one-by-one spec runs due to expensive JVM load time" -else - for file in `find spec -iname '*_spec.rb'`; do - NO_COVERAGE=1 bin/rspec $file -b --format progress - done -fi - -# TODO: it would be nice to figure out how to run the cukes w/o the overhead of -# bundler, but just running `bin/cucumber` can fail due to the fact that it -# shells out (via aruba) and executes `rspec`--which can pick up the wrong -# rspec version if we're not running with bundler. -bundle exec cucumber --strict -