Skip to content

Dont run rubocop on ruby head #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 15, 2021
Merged
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ source "https://rubygems.org"

gem "rake", "~> 12.3.2"
gem "thor", "~> 0.14.6"
gem "octokit", "~> 2.7"
gem "octokit", "~> 4.2"
25 changes: 19 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ namespace :git do
desc 'git push on all the repos'
task :push, :force do |t, args|
branch = `git rev-parse --abbrev-ref HEAD`
if args[:force]
if should_force?(args)
run_command "git push origin #{branch} --force-with-lease"
else
run_command "git push origin #{branch}"
Expand Down Expand Up @@ -396,8 +396,8 @@ namespace :ci do

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

Expand Down Expand Up @@ -488,7 +488,7 @@ namespace :common_plaintext_files do

desc "Updates the common plaintext files files and creates a PR"
task :create_pr_with_updates, :custom_pr_comment, :force do |_t, args|
force_update(update_common_plaintext_files_in_repos, args[:custom_pr_comment], args[:force] == "force")
force_update(update_common_plaintext_files_in_repos, args[:custom_pr_comment], should_force?(args))
end
end

Expand Down Expand Up @@ -555,9 +555,14 @@ def assert_clean_git_status(name)
end
end

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

if opts[:force]
`git branch -D #{name}`
return name
end

puts "Branch #{name} already exists, delete? [Y/n] or rename new branch? [r[ename] <name>]"
case input = STDIN.gets.downcase
when /^y/i
Expand Down Expand Up @@ -598,6 +603,14 @@ def force_update(branch, custom_pr_comment, skip_confirmation=false, opts={})
end
end

def should_force?(opts = {})
force = opts[:force]
%w[force t true].each do |text|
return true if force == text || ENV['FORCE'] == text
end
return false
end

def update_files_in_repos(purpose, suffix='', opts={})
suffix = [BASE_BRANCH, ENV['BRANCH_SUFFIX']].compact.join('-')
branch_name = "update-#{purpose.gsub ' ', '-'}-#{ENV.fetch('BRANCH_DATE',Date.today.iso8601)}-for-#{suffix}"
Expand All @@ -612,7 +625,7 @@ def update_files_in_repos(purpose, suffix='', opts={})
end

each_project_with_common_build(opts) do |name|
branch_name = confirm_branch_name(branch_name)
branch_name = confirm_branch_name(branch_name, opts)
sh "git checkout -b #{branch_name}"

yield name
Expand Down
7 changes: 4 additions & 3 deletions ci/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ jobs:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
bundler: ${{ matrix.bundler || 2 }}
bundler: ${{ matrix.bundler || '2.2.22' }}
ruby-version: ${{ matrix.ruby }}
- run: script/update_rubygems_and_install_bundler
- run: script/clone_all_rspec_repos
- run: bundle install --binstubs --standalone
- run: bundle install --standalone
- run: bundle binstubs --all
- run: script/run_build

legacy:
Expand Down Expand Up @@ -122,7 +123,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
bundler: 2
bundler: '2.2.22'
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: cinst ansicon
Expand Down
6 changes: 2 additions & 4 deletions ci/script/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function run_spec_suite_for {
unset BUNDLE_GEMFILE
bundle_install_flags=`cat .github/workflows/ci.yml | grep "bundle install" | sed 's/.* bundle install//'`
travis_retry eval "(unset RUBYOPT; exec bundle install $bundle_install_flags)"
travis_retry eval "(unset RUBYOPT; exec bundle binstubs --all)"
run_specs_and_record_done
popd
else
Expand Down Expand Up @@ -136,10 +137,7 @@ function check_binstubs {
echo " $ bundle binstubs$gems"
echo
echo " # To binstub all gems"
echo " $ bundle install --binstubs"
echo
echo " # To binstub all gems and avoid loading bundler"
echo " $ bundle install --binstubs --standalone"
echo " $ bundle binstubs --all"
fi

return $success
Expand Down
10 changes: 7 additions & 3 deletions ci/script/predicate_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ function documentation_enforced {
}

function style_and_lint_enforced {
if [ -x ./bin/rubocop ]; then
return 0
else
if is_ruby_head; then
return 1
else
if [ -x ./bin/rubocop ]; then
return 0
else
return 1
fi
fi
}
4 changes: 2 additions & 2 deletions ci/script/update_rubygems_and_install_bundler
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e
source script/functions.sh

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