Skip to content

Commit

Permalink
Merge pull request #2726 from rspec/update-rspec-rails-build
Browse files Browse the repository at this point in the history
Cleanup rspec-rails build and fix rubygems issue
  • Loading branch information
JonRowe committed Jan 25, 2024
1 parent f4e6c9f commit b3c17ac
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 341 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ jobs:
- ruby: 3.1
env:
RAILS_VERSION: 'main'
- ruby: '3.0'
env:
RAILS_VERSION: 'main'
- ruby: 2.7
env:
RAILS_VERSION: 'main'

# Rails 7.1 builds >= 2.7
- ruby: 3.2
Expand Down
4 changes: 2 additions & 2 deletions BUILD_DETAIL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ DO NOT modify it by hand as your changes will get lost the next time it is gener
# The CI build, in detail

The CI build runs many verification steps to prevent regressions and
ensure high-quality code. To run the Travis build locally, run:
ensure high-quality code. To run the build locally, run:

```
$ script/run_build
```

It can be useful to run the build steps individually
to repro a failing part of a Travis build. Let's break
to repro a failing part of a build. Let's break
the build down into the individual steps.

## Specs
Expand Down
6 changes: 1 addition & 5 deletions example_app_generator/ci_retry_bundle_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ set -e
source FUNCTIONS_SCRIPT_FILE

echo "Starting bundle install using shared bundle path"
if is_mri; then
travis_retry eval "RUBYOPT=$RUBYOPT:' --enable rubygems' bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"
else
travis_retry eval "bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"
fi
ci_retry eval "RUBYOPT=$RUBYOPT:' --enable rubygems' bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"
73 changes: 0 additions & 73 deletions script/ci_functions.sh

This file was deleted.

20 changes: 8 additions & 12 deletions script/clone_all_rspec_repos
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
set -e
source script/functions.sh

if is_mri; then
pushd ..
pushd ..

clone_repo "rspec"
clone_repo "rspec-core"
clone_repo "rspec-expectations"
clone_repo "rspec-mocks"
clone_repo "rspec-rails"
clone_repo "rspec-support"
clone_repo "rspec"
clone_repo "rspec-core"
clone_repo "rspec-expectations"
clone_repo "rspec-mocks"
clone_repo "rspec-rails"
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
popd
20 changes: 0 additions & 20 deletions script/custom_build_functions.sh

This file was deleted.

132 changes: 50 additions & 82 deletions script/functions.sh
Original file line number Diff line number Diff line change
@@ -1,67 +1,69 @@
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/ci_functions.sh
source $SCRIPT_DIR/predicate_functions.sh

# If JRUBY_OPTS isn't set, use these.
# see https://docs.travis-ci.com/user/ci-environment/
export JRUBY_OPTS=${JRUBY_OPTS:-"--server -Xcompile.invokedynamic=false"}
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; then
export RUBYOPT="--disable=gem"
fi
export RUBYOPT="--disable=gem"

ci_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

function clone_repo {
if [ ! -d $1 ]; then # don't clone if the dir is already there
travis_retry eval "git clone https://github.com/rspec/$1 --depth 1 --branch $MAINTENANCE_BRANCH"
fi;
[ $count -eq 3 ] && {
echo "\n\033[33;1mThe command \"$@\" failed 3 times.\033[0m\n" >&2
}

return $result
}

function run_specs_and_record_done {
local rspec_bin=bin/rspec
fold() {
local name="$1"
local status=0
shift 1
echo "============= Starting $name ==============="

# 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 ] && is_mri; then
rspec_bin=script/rspec_with_simplecov
fi;
"$@"
status=$?

echo "${PWD}/bin/rspec"
$rspec_bin spec --backtrace --format progress --profile --format progress --out $SPECS_HAVE_RUN_FILE
if [ "$status" -eq 0 ]; then
echo "============= Ending $name ==============="
else
STATUS="$status"
fi

return $status
}

function run_cukes {
if [ -d features ]; then
# force jRuby to use client mode JVM or a compilation mode that's 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'

echo "${PWD}/bin/cucumber"

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" \
bin/cucumber --strict
else
# Prepare RUBYOPT for scenarios that are shelling out to ruby,
# and PATH for those that are using `rspec` or `rake`.
RUBYOPT="${RUBYOPT} -I${PWD}/../bundle -rbundler/setup" \
PATH="${PWD}/bin:$PATH" \
bin/cucumber --strict
fi
function documentation_enforced {
if [ -x ./bin/yard ]; then
return 0
else
return 1
fi
}

function clone_repo {
if [ ! -d $1 ]; then # don't clone if the dir is already there
ci_retry eval "git clone https://github.com/rspec/$1 --depth 1 --branch $MAINTENANCE_BRANCH"
fi;
}

function run_specs_and_record_done {
echo "${PWD}/bin/rspec"
bin/rspec spec --backtrace --format progress --profile --format progress --out $SPECS_HAVE_RUN_FILE
}

function run_specs_one_by_one {
echo "Running each spec file, one-by-one..."

Expand All @@ -71,27 +73,6 @@ function run_specs_one_by_one {
done
}

function run_spec_suite_for {
if [ ! -f ../$1/$SPECS_HAVE_RUN_FILE ]; then # don't rerun specs that have already run
if [ -d ../$1 ]; then
echo "Running specs for $1"
pushd ../$1
unset BUNDLE_GEMFILE
bundle_install_flags=`cat .travis.yml | grep bundler_args | tr -d '"' | grep -o " .*"`
travis_retry eval "(unset RUBYOPT; exec bundle install $bundle_install_flags)"
run_specs_and_record_done
popd
else
echo ""
echo "WARNING: The ../$1 directory does not exist. Usually the"
echo "travis build cds into that directory and run the specs to"
echo "ensure the specs still pass with your latest changes, but"
echo "we are going to skip that step."
echo ""
fi;
fi;
}

function check_binstubs {
echo "Checking required binstubs"

Expand Down Expand Up @@ -174,16 +155,3 @@ function check_documentation_coverage {
end
"
}

function check_style_and_lint {
echo "bin/rubocop"
eval "(unset RUBYOPT; rm -rf tmp/*; exec bin/rubocop)"
}

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-rails specs" run_spec_suite_for "rspec-rails"
fold "rspec-support specs" run_spec_suite_for "rspec-support"
}
Loading

0 comments on commit b3c17ac

Please sign in to comment.