Skip to content

Commit d7eb952

Browse files
committed
Cleanup rspec-rails build and fix rubygems issue
1 parent 723167c commit d7eb952

10 files changed

+91
-335
lines changed

BUILD_DETAIL.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ DO NOT modify it by hand as your changes will get lost the next time it is gener
66
# The CI build, in detail
77

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

1111
```
1212
$ script/run_build
1313
```
1414

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

1919
## Specs

example_app_generator/ci_retry_bundle_install.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@ set -e
44
source FUNCTIONS_SCRIPT_FILE
55

66
echo "Starting bundle install using shared bundle path"
7-
if is_mri; then
8-
travis_retry eval "RUBYOPT=$RUBYOPT:' --enable rubygems' bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"
9-
else
10-
travis_retry eval "bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"
11-
fi
7+
ci_retry eval "RUBYOPT=$RUBYOPT:' --enable rubygems' bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"

script/ci_functions.sh

-73
This file was deleted.

script/clone_all_rspec_repos

+8-12
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
set -e
66
source script/functions.sh
77

8-
if is_mri; then
9-
pushd ..
8+
pushd ..
109

11-
clone_repo "rspec"
12-
clone_repo "rspec-core"
13-
clone_repo "rspec-expectations"
14-
clone_repo "rspec-mocks"
15-
clone_repo "rspec-rails"
16-
clone_repo "rspec-support"
10+
clone_repo "rspec"
11+
clone_repo "rspec-core"
12+
clone_repo "rspec-expectations"
13+
clone_repo "rspec-mocks"
14+
clone_repo "rspec-rails"
15+
clone_repo "rspec-support"
1716

18-
popd
19-
else
20-
echo "Not cloning all repos since we are not on MRI and they are only needed for the MRI build"
21-
fi
17+
popd

script/custom_build_functions.sh

-20
This file was deleted.

script/functions.sh

+50-82
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,69 @@
1-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
2-
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
3-
41
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5-
source $SCRIPT_DIR/ci_functions.sh
6-
source $SCRIPT_DIR/predicate_functions.sh
7-
8-
# If JRUBY_OPTS isn't set, use these.
9-
# see https://docs.travis-ci.com/user/ci-environment/
10-
export JRUBY_OPTS=${JRUBY_OPTS:-"--server -Xcompile.invokedynamic=false"}
112
SPECS_HAVE_RUN_FILE=specs.out
123
MAINTENANCE_BRANCH=`cat maintenance-branch`
134

145
# Don't allow rubygems to pollute what's loaded. Also, things boot faster
156
# without the extra load time of rubygems. Only works on MRI Ruby 1.9+
16-
if is_mri; then
17-
export RUBYOPT="--disable=gem"
18-
fi
7+
export RUBYOPT="--disable=gem"
8+
9+
ci_retry() {
10+
local result=0
11+
local count=1
12+
while [ $count -le 3 ]; do
13+
[ $result -ne 0 ] && {
14+
echo -e "\n\033[33;1mThe command \"$@\" failed. Retrying, $count of 3.\033[0m\n" >&2
15+
}
16+
"$@"
17+
result=$?
18+
[ $result -eq 0 ] && break
19+
count=$(($count + 1))
20+
sleep 1
21+
done
1922

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

26-
function run_specs_and_record_done {
27-
local rspec_bin=bin/rspec
30+
fold() {
31+
local name="$1"
32+
local status=0
33+
shift 1
34+
echo "============= Starting $name ==============="
2835

29-
# rspec-core needs to run with a special script that loads simplecov first,
30-
# so that it can instrument rspec-core's code before rspec-core has been loaded.
31-
if [ -f script/rspec_with_simplecov ] && is_mri; then
32-
rspec_bin=script/rspec_with_simplecov
33-
fi;
36+
"$@"
37+
status=$?
3438

35-
echo "${PWD}/bin/rspec"
36-
$rspec_bin spec --backtrace --format progress --profile --format progress --out $SPECS_HAVE_RUN_FILE
39+
if [ "$status" -eq 0 ]; then
40+
echo "============= Ending $name ==============="
41+
else
42+
STATUS="$status"
43+
fi
44+
45+
return $status
3746
}
3847

39-
function run_cukes {
40-
if [ -d features ]; then
41-
# force jRuby to use client mode JVM or a compilation mode that's as close as possible,
42-
# idea taken from https://github.com/jruby/jruby/wiki/Improving-startup-time
43-
#
44-
# Note that we delay setting this until we run the cukes because we've seen
45-
# spec failures in our spec suite due to problems with this mode.
46-
export JAVA_OPTS='-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1'
47-
48-
echo "${PWD}/bin/cucumber"
49-
50-
if is_jruby; then
51-
# For some reason JRuby doesn't like our improved bundler setup
52-
RUBYOPT="-I${PWD}/../bundle -rbundler/setup" \
53-
PATH="${PWD}/bin:$PATH" \
54-
bin/cucumber --strict
55-
else
56-
# Prepare RUBYOPT for scenarios that are shelling out to ruby,
57-
# and PATH for those that are using `rspec` or `rake`.
58-
RUBYOPT="${RUBYOPT} -I${PWD}/../bundle -rbundler/setup" \
59-
PATH="${PWD}/bin:$PATH" \
60-
bin/cucumber --strict
61-
fi
48+
function documentation_enforced {
49+
if [ -x ./bin/yard ]; then
50+
return 0
51+
else
52+
return 1
6253
fi
6354
}
6455

56+
function clone_repo {
57+
if [ ! -d $1 ]; then # don't clone if the dir is already there
58+
ci_retry eval "git clone https://github.com/rspec/$1 --depth 1 --branch $MAINTENANCE_BRANCH"
59+
fi;
60+
}
61+
62+
function run_specs_and_record_done {
63+
echo "${PWD}/bin/rspec"
64+
bin/rspec spec --backtrace --format progress --profile --format progress --out $SPECS_HAVE_RUN_FILE
65+
}
66+
6567
function run_specs_one_by_one {
6668
echo "Running each spec file, one-by-one..."
6769

@@ -71,27 +73,6 @@ function run_specs_one_by_one {
7173
done
7274
}
7375

74-
function run_spec_suite_for {
75-
if [ ! -f ../$1/$SPECS_HAVE_RUN_FILE ]; then # don't rerun specs that have already run
76-
if [ -d ../$1 ]; then
77-
echo "Running specs for $1"
78-
pushd ../$1
79-
unset BUNDLE_GEMFILE
80-
bundle_install_flags=`cat .travis.yml | grep bundler_args | tr -d '"' | grep -o " .*"`
81-
travis_retry eval "(unset RUBYOPT; exec bundle install $bundle_install_flags)"
82-
run_specs_and_record_done
83-
popd
84-
else
85-
echo ""
86-
echo "WARNING: The ../$1 directory does not exist. Usually the"
87-
echo "travis build cds into that directory and run the specs to"
88-
echo "ensure the specs still pass with your latest changes, but"
89-
echo "we are going to skip that step."
90-
echo ""
91-
fi;
92-
fi;
93-
}
94-
9576
function check_binstubs {
9677
echo "Checking required binstubs"
9778

@@ -174,16 +155,3 @@ function check_documentation_coverage {
174155
end
175156
"
176157
}
177-
178-
function check_style_and_lint {
179-
echo "bin/rubocop"
180-
eval "(unset RUBYOPT; rm -rf tmp/*; exec bin/rubocop)"
181-
}
182-
183-
function run_all_spec_suites {
184-
fold "rspec-core specs" run_spec_suite_for "rspec-core"
185-
fold "rspec-expectations specs" run_spec_suite_for "rspec-expectations"
186-
fold "rspec-mocks specs" run_spec_suite_for "rspec-mocks"
187-
fold "rspec-rails specs" run_spec_suite_for "rspec-rails"
188-
fold "rspec-support specs" run_spec_suite_for "rspec-support"
189-
}

0 commit comments

Comments
 (0)