Skip to content

Commit 0a8bec7

Browse files
authored
Merge pull request #290 from rspec/dont-run-rubocop-on-ruby-head
Dont run rubocop on ruby head
2 parents 1101525 + 2dc7279 commit 0a8bec7

File tree

6 files changed

+35
-19
lines changed

6 files changed

+35
-19
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ source "https://rubygems.org"
22

33
gem "rake", "~> 12.3.2"
44
gem "thor", "~> 0.14.6"
5-
gem "octokit", "~> 2.7"
5+
gem "octokit", "~> 4.2"

Rakefile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ namespace :git do
224224
desc 'git push on all the repos'
225225
task :push, :force do |t, args|
226226
branch = `git rev-parse --abbrev-ref HEAD`
227-
if args[:force]
227+
if should_force?(args)
228228
run_command "git push origin #{branch} --force-with-lease"
229229
else
230230
run_command "git push origin #{branch}"
@@ -396,8 +396,8 @@ namespace :ci do
396396

397397
desc "Updates the CI files and creates a PR"
398398
task :create_pr_with_updates, :custom_pr_comment, :force do |t, args|
399-
opts = { except: %w[ rspec-rails ] }
400-
force_update(update_ci_files_in_repos(opts), args[:custom_pr_comment], args[:force] == "force", opts)
399+
opts = { except: %w[ rspec-rails ], force: should_force?(args) }
400+
force_update(update_ci_files_in_repos(opts), args[:custom_pr_comment], opts[:force], opts)
401401
end
402402
end
403403

@@ -488,7 +488,7 @@ namespace :common_plaintext_files do
488488

489489
desc "Updates the common plaintext files files and creates a PR"
490490
task :create_pr_with_updates, :custom_pr_comment, :force do |_t, args|
491-
force_update(update_common_plaintext_files_in_repos, args[:custom_pr_comment], args[:force] == "force")
491+
force_update(update_common_plaintext_files_in_repos, args[:custom_pr_comment], should_force?(args))
492492
end
493493
end
494494

@@ -555,9 +555,14 @@ def assert_clean_git_status(name)
555555
end
556556
end
557557

558-
def confirm_branch_name(name)
558+
def confirm_branch_name(name, opts={})
559559
return name unless system("git show-branch #{name} > /dev/null 2>&1")
560560

561+
if opts[:force]
562+
`git branch -D #{name}`
563+
return name
564+
end
565+
561566
puts "Branch #{name} already exists, delete? [Y/n] or rename new branch? [r[ename] <name>]"
562567
case input = STDIN.gets.downcase
563568
when /^y/i
@@ -598,6 +603,14 @@ def force_update(branch, custom_pr_comment, skip_confirmation=false, opts={})
598603
end
599604
end
600605

606+
def should_force?(opts = {})
607+
force = opts[:force]
608+
%w[force t true].each do |text|
609+
return true if force == text || ENV['FORCE'] == text
610+
end
611+
return false
612+
end
613+
601614
def update_files_in_repos(purpose, suffix='', opts={})
602615
suffix = [BASE_BRANCH, ENV['BRANCH_SUFFIX']].compact.join('-')
603616
branch_name = "update-#{purpose.gsub ' ', '-'}-#{ENV.fetch('BRANCH_DATE',Date.today.iso8601)}-for-#{suffix}"
@@ -612,7 +625,7 @@ def update_files_in_repos(purpose, suffix='', opts={})
612625
end
613626

614627
each_project_with_common_build(opts) do |name|
615-
branch_name = confirm_branch_name(branch_name)
628+
branch_name = confirm_branch_name(branch_name, opts)
616629
sh "git checkout -b #{branch_name}"
617630

618631
yield name

ci/.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ jobs:
5757
- uses: actions/checkout@v2
5858
- uses: ruby/setup-ruby@v1
5959
with:
60-
bundler: ${{ matrix.bundler || 2 }}
60+
bundler: ${{ matrix.bundler || '2.2.22' }}
6161
ruby-version: ${{ matrix.ruby }}
6262
- run: script/update_rubygems_and_install_bundler
6363
- run: script/clone_all_rspec_repos
64-
- run: bundle install --binstubs --standalone
64+
- run: bundle install --standalone
65+
- run: bundle binstubs --all
6566
- run: script/run_build
6667

6768
legacy:
@@ -122,7 +123,7 @@ jobs:
122123
- uses: actions/checkout@v2
123124
- uses: ruby/setup-ruby@v1
124125
with:
125-
bundler: 2
126+
bundler: '2.2.22'
126127
ruby-version: ${{ matrix.ruby }}
127128
bundler-cache: true
128129
- run: cinst ansicon

ci/script/functions.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function run_spec_suite_for {
8787
unset BUNDLE_GEMFILE
8888
bundle_install_flags=`cat .github/workflows/ci.yml | grep "bundle install" | sed 's/.* bundle install//'`
8989
travis_retry eval "(unset RUBYOPT; exec bundle install $bundle_install_flags)"
90+
travis_retry eval "(unset RUBYOPT; exec bundle binstubs --all)"
9091
run_specs_and_record_done
9192
popd
9293
else
@@ -136,10 +137,7 @@ function check_binstubs {
136137
echo " $ bundle binstubs$gems"
137138
echo
138139
echo " # To binstub all gems"
139-
echo " $ bundle install --binstubs"
140-
echo
141-
echo " # To binstub all gems and avoid loading bundler"
142-
echo " $ bundle install --binstubs --standalone"
140+
echo " $ bundle binstubs --all"
143141
fi
144142

145143
return $success

ci/script/predicate_functions.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,13 @@ function documentation_enforced {
126126
}
127127

128128
function style_and_lint_enforced {
129-
if [ -x ./bin/rubocop ]; then
130-
return 0
131-
else
129+
if is_ruby_head; then
132130
return 1
131+
else
132+
if [ -x ./bin/rubocop ]; then
133+
return 0
134+
else
135+
return 1
136+
fi
133137
fi
134138
}

ci/script/update_rubygems_and_install_bundler

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ set -e
33
source script/functions.sh
44

55
if is_ruby_23_plus; then
6-
yes | gem update --system
7-
yes | gem install bundler
6+
yes | gem update --system '3.2.22'
7+
yes | gem install bundler -v '2.2.22'
88
else
99
echo "Warning installing older versions of Rubygems / Bundler"
1010
gem update --system '2.7.8'

0 commit comments

Comments
 (0)