diff --git a/.gitlab/ci/gitlab-gems.gitlab-ci.yml b/.gitlab/ci/gitlab-gems.gitlab-ci.yml index 802ad9a5a8a924c3fd6f508aa9143c3895fa38c7..c590512039629a89aa4e966b730d8b8d6e3c0755 100644 --- a/.gitlab/ci/gitlab-gems.gitlab-ci.yml +++ b/.gitlab/ci/gitlab-gems.gitlab-ci.yml @@ -41,3 +41,6 @@ include: - local: .gitlab/ci/templates/gem.gitlab-ci.yml inputs: gem_name: "gitlab-database-lock_retries" + - local: .gitlab/ci/templates/gem.gitlab-ci.yml + inputs: + gem_name: "gitlab-housekeeper" diff --git a/gems/gitlab-housekeeper/gitlab-housekeeper.gemspec b/gems/gitlab-housekeeper/gitlab-housekeeper.gemspec index ca78d3136b7c6886026f4e014ed721104f9c6d8f..192b9d9b9f49ed68913fa4ec5a97db70053412e6 100644 --- a/gems/gitlab-housekeeper/gitlab-housekeeper.gemspec +++ b/gems/gitlab-housekeeper/gitlab-housekeeper.gemspec @@ -20,9 +20,9 @@ Gem::Specification.new do |spec| spec.executables = ['gitlab-housekeeper'] spec.add_runtime_dependency 'activesupport' + spec.add_runtime_dependency 'awesome_print' spec.add_runtime_dependency 'httparty' spec.add_runtime_dependency 'rubocop' - spec.add_runtime_dependency 'awesome_print' spec.add_development_dependency 'gitlab-styles' spec.add_development_dependency 'rspec-rails' diff --git a/gems/gitlab-housekeeper/lib/gitlab/housekeeper/keeps/rubocop_fixer.rb b/gems/gitlab-housekeeper/lib/gitlab/housekeeper/keeps/rubocop_fixer.rb index 06f13b792136553993ba50494e6bfedecffb7905..5a78e7c584c7c468e129ec31f5f264905a3a1b82 100644 --- a/gems/gitlab-housekeeper/lib/gitlab/housekeeper/keeps/rubocop_fixer.rb +++ b/gems/gitlab-housekeeper/lib/gitlab/housekeeper/keeps/rubocop_fixer.rb @@ -70,7 +70,7 @@ def each_allowed_rubocop_rule end end - def remove_first_exclusions(rule, file, remove_count) + def remove_first_exclusions(_rule, file, remove_count) content = File.read(file) skipped = 0 diff --git a/gems/gitlab-housekeeper/spec/gitlab/housekeeper/git_spec.rb b/gems/gitlab-housekeeper/spec/gitlab/housekeeper/git_spec.rb index df4f815928733cd066172d1e379647046bdd78dd..524c0fa21c21f23d9ecb9cd46c082d1f0b6c529b 100644 --- a/gems/gitlab-housekeeper/spec/gitlab/housekeeper/git_spec.rb +++ b/gems/gitlab-housekeeper/spec/gitlab/housekeeper/git_spec.rb @@ -17,6 +17,7 @@ def setup_master_branch File.write(file_in_master, 'File already in master!') ::Gitlab::Housekeeper::Shell.execute('git', 'init') + ::Gitlab::Housekeeper::Shell.execute('git', 'config', '--local', 'user.email', 'test@example.com') ::Gitlab::Housekeeper::Shell.execute('git', 'checkout', '-b', 'master') ::Gitlab::Housekeeper::Shell.execute('git', 'add', file_in_master) ::Gitlab::Housekeeper::Shell.execute('git', 'commit', '-m', 'Initial commit!') diff --git a/gems/gitlab-housekeeper/spec/gitlab/housekeeper/keeps/rubocop_fixer_spec.rb b/gems/gitlab-housekeeper/spec/gitlab/housekeeper/keeps/rubocop_fixer_spec.rb index 2b145794f5818fac5183081c13ad405d613925d2..80dad94dc4f7d9d3a8f2fbdde201756512e50cef 100644 --- a/gems/gitlab-housekeeper/spec/gitlab/housekeeper/keeps/rubocop_fixer_spec.rb +++ b/gems/gitlab-housekeeper/spec/gitlab/housekeeper/keeps/rubocop_fixer_spec.rb @@ -2,26 +2,10 @@ require 'spec_helper' +# rubocop:disable RSpec/MultipleMemoizedHelpers RSpec.describe ::Gitlab::Housekeeper::Keeps::RubocopFixer do let(:todo_dir) { Dir.mktmpdir } - let(:rule1_file) { Pathname(todo_dir).join('rule1.yml').to_s } - let(:rule2_file) { Pathname(todo_dir).join('rule2.yml').to_s } - let(:not_autocorrectable_file) { Pathname(todo_dir).join('not_autocorrectable.yml').to_s } - let(:todo_dir_pattern) { Pathname(todo_dir).join('**/*.yml').to_s } - - before do - dir = Pathname.new(todo_dir) - FileUtils.cp('spec/fixtures/rubocop_todo1.yml', rule1_file) - FileUtils.cp('spec/fixtures/rubocop_todo2.yml', rule2_file) - FileUtils.cp('spec/fixtures/rubocop_todo_not_autocorrectable.yml', not_autocorrectable_file) - end - - after do - FileUtils.remove_entry(todo_dir) - end - let(:rubocop_fixer) { described_class.new(todo_dir_pattern: todo_dir_pattern, limit_fixes: 5) } - let(:rule1_violating_files) do [ 'rule1_violation1.rb', @@ -45,6 +29,22 @@ ] end + let(:rule1_file) { Pathname(todo_dir).join('rule1.yml').to_s } + let(:rule2_file) { Pathname(todo_dir).join('rule2.yml').to_s } + let(:not_autocorrectable_file) { Pathname(todo_dir).join('not_autocorrectable.yml').to_s } + let(:todo_dir_pattern) { Pathname(todo_dir).join('**/*.yml').to_s } + + before do + Pathname.new(todo_dir) + FileUtils.cp('spec/fixtures/rubocop_todo1.yml', rule1_file) + FileUtils.cp('spec/fixtures/rubocop_todo2.yml', rule2_file) + FileUtils.cp('spec/fixtures/rubocop_todo_not_autocorrectable.yml', not_autocorrectable_file) + end + + after do + FileUtils.remove_entry(todo_dir) + end + describe '#each_change' do it 'iterates over todo_dir_pattern files' do yielded_times = 0 @@ -116,3 +116,4 @@ end end end +# rubocop:enable RSpec/MultipleMemoizedHelpers