Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Updated ci build scripts (from rspec-dev) #2790

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2020-11-22T07:41:13+00:00 from the rspec-dev repo.
# This file was generated on 2020-12-07T01:07:10+03:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

name: RSpec CI
Expand Down Expand Up @@ -26,8 +26,6 @@ jobs:
- 2.5
- 2.4
- 2.3
- 2.2
- 2.1.9
- ruby-head
env:
-
Expand Down Expand Up @@ -74,8 +72,6 @@ jobs:
- 2.5
- 2.4
- 2.3
- 2.2
- 2.1.9
fail-fast: false
steps:
- uses: actions/checkout@v2
Expand Down
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion script/ci_functions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2020-11-22T07:41:13+00:00 from the rspec-dev repo.
# This file was generated on 2020-12-07T01:07:10+03:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

# Taken from:
Expand Down
7 changes: 2 additions & 5 deletions script/clone_all_rspec_repos
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# This file was generated on 2020-11-22T07:41:13+00:00 from the rspec-dev repo.
# This file was generated on 2020-12-07T01:07:10+03: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
Expand All @@ -13,10 +13,7 @@ if is_mri; then
clone_repo "rspec-expectations"
clone_repo "rspec-mocks"
clone_repo "rspec-rails" "main"

if rspec_support_compatible; then
clone_repo "rspec-support"
fi
clone_repo "rspec-support"

popd
else
Expand Down
7 changes: 1 addition & 6 deletions script/custom_build_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ function run_cukes {
if [ -d features ]; then
echo "${PWD}/bin/cucumber"

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
elif is_jruby; then
if is_jruby; then
echo "WARNING: Cucumber is skipped on JRuby on rspec-core due to" \
"excessive build times (>45 minutes) causing timeouts on Travis"
return 0
Expand Down
30 changes: 16 additions & 14 deletions script/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ SPECS_HAVE_RUN_FILE=specs.out
MAINTENANCE_BRANCH=`cat maintenance-branch`

# Don't allow rubygems to pollute what's loaded. Also, things boot faster
# without the extra load time of rubygems. Only works on MRI Ruby 1.9+
if is_mri_192_plus; then
# without the extra load time of rubygems. Only works on MRI.
if is_mri; then
export RUBYOPT="--disable=gem"
fi

Expand Down Expand Up @@ -53,12 +53,7 @@ function run_cukes {

echo "${PWD}/bin/cucumber"

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
elif is_jruby; then
if is_jruby; then
# For some reason JRuby doesn't like our improved bundler setup
RUBYOPT="-I${PWD}/../bundle -rbundler/setup" \
PATH="${PWD}/bin:$PATH" \
Expand Down Expand Up @@ -88,7 +83,7 @@ function run_spec_suite_for {
echo "Running specs for $1"
pushd ../$1
unset BUNDLE_GEMFILE
bundle_install_flags=`cat .travis.yml | grep bundler_args | tr -d '"' | grep -o " .*"`
bundle_install_flags="--binstubs --standalone --without documentation --path ../bundle"
travis_retry eval "(unset RUBYOPT; exec bundle install $bundle_install_flags)"
run_specs_and_record_done
popd
Expand All @@ -103,6 +98,16 @@ function run_spec_suite_for {
fi;
}

function run_spec_suite_for_rspec_rails {
echo "Running specs for rspec-rails"
pushd ../rspec-rails
unset BUNDLE_GEMFILE
unset RUBYOPT
travis_retry eval "(unset RUBYOPT; exec bundle install)"
bundle exec rspec spec --backtrace --format progress --profile --format progress --out $SPECS_HAVE_RUN_FILE
Copy link
Member Author

@pirj pirj Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JonRowe I've tried many options, and this one, the most straightforward, is the only one that worked.

Without unset RUBYOPT Rails is complaining that uninitialized constant Gem.
With --binstubs --standalone --path=../bundle and subsequent bin/rspec the binstub apparently ceases to find ../bundle:

# Gem::MissingSpecError:
#   Could not find 'sqlite3' (~> 1.4) among 30 total gem(s)
#   Checked in 'GEM_PATH=/home/runner/.gem/ruby/2.5.0:/opt/hostedtoolcache/Ruby/2.5.8/x64/lib/ruby/gems/2.5.0', execute `gem env` for more information

Would you agree for such a change?

  • Yes, surely we're shaving some fractions of a second by using standalone, but is it worth such a complication?
  • SPECS_HAVE_RUN_FILE is quite an odd flag to prevent duplicate runs, I can't think of a scenario where specs are started twice for the same repo
  • [ -d ../$1 ] is useless - we do clone it, and if we don't - we don't run_spec_suite_for for this dir

To my huge surprise, the problem with uninitialized constant Gem can be reproduced with a small single commit comparing to the green 4-0-dev. That very commit that drops .travis.yml and barely does anything else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its the ffi version, I had to fix rspec-core for main too, I've applied that patch to 4-0-dev and opened simplified PRs to see how they go

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!
I'll close this series for now, we can address the removal of .travis.yml later.

popd
}

function check_binstubs {
echo "Checking required binstubs"

Expand Down Expand Up @@ -193,11 +198,8 @@ function run_all_spec_suites {
fold "rspec-core specs" run_spec_suite_for "rspec-core"
fold "rspec-expectations specs" run_spec_suite_for "rspec-expectations"
fold "rspec-mocks specs" run_spec_suite_for "rspec-mocks"
fold "rspec-support specs" run_spec_suite_for "rspec-support"
if rspec_rails_compatible; then
fold "rspec-rails specs" run_spec_suite_for "rspec-rails"
fi

if rspec_support_compatible; then
fold "rspec-support specs" run_spec_suite_for "rspec-support"
fold "rspec-rails specs" run_spec_suite_for_rspec_rails
fi
}
66 changes: 6 additions & 60 deletions script/predicate_functions.sh
Original file line number Diff line number Diff line change
@@ -1,70 +1,24 @@
# This file was generated on 2020-11-22T07:41:13+00:00 from the rspec-dev repo.
# This file was generated on 2020-12-07T01:07:10+03:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

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)
# RUBY_ENGINE only returns 'ruby' on MRI.
if ruby -e "exit(RUBY_ENGINE == 'ruby')"; then
return 0
else
return 1
fi;
}

function is_jruby {
if ruby -e "exit(defined?(RUBY_PLATFORM) && RUBY_PLATFORM == 'java')"; 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)
# RUBY_PLATFORM only returns 'java' on JRuby.
if ruby -e "exit(RUBY_PLATFORM == 'java')"; then
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 is_mri_192_plus {
if is_mri; then
if ruby -e "exit(RUBY_VERSION.to_f > 1.8)"; then
return 0
else
return 1
fi
else
return 1
fi
}

function is_mri_2plus {
if is_mri; then
if ruby -e "exit(RUBY_VERSION.to_f > 2.0)"; then
return 0
else
return 1
fi
else
return 1
fi
}

function is_ruby_23_plus {
if ruby -e "exit(RUBY_VERSION.to_f >= 2.3)"; then
return 0
else
return 1
fi
}

function is_ruby_25_plus {
if ruby -e "exit(RUBY_VERSION.to_f >= 2.5)"; then
return 0
Expand All @@ -81,22 +35,14 @@ function rspec_rails_compatible {
fi
}

function rspec_support_compatible {
if [ "$MAINTENANCE_BRANCH" != "2-99-maintenance" ] && [ "$MAINTENANCE_BRANCH" != "2-14-maintenance" ]; then
return 0
else
return 1
fi
}

function additional_specs_available {
type run_additional_specs > /dev/null 2>&1
return $?
}

function documentation_enforced {
if [ -x ./bin/yard ]; then
if is_mri_2plus; then
if is_mri; then
return 0
else
return 1
Expand Down
2 changes: 1 addition & 1 deletion script/run_build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# This file was generated on 2020-11-22T07:41:13+00:00 from the rspec-dev repo.
# This file was generated on 2020-12-07T01:07:10+03: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
Expand Down
12 changes: 3 additions & 9 deletions script/update_rubygems_and_install_bundler
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#!/bin/bash
# This file was generated on 2020-11-22T07:41:13+00:00 from the rspec-dev repo.
# This file was generated on 2020-12-07T01:07:10+03: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
source script/functions.sh

if is_ruby_23_plus; then
yes | gem update --system
yes | gem install bundler
else
echo "Warning installing older versions of Rubygems / Bundler"
gem update --system '2.7.8'
gem install bundler -v '1.17.3'
fi
yes | gem update --system
yes | gem install bundler