Skip to content
代码片段 群组 项目
未验证 提交 7f21d193 编辑于 作者: Rémy Coutable's avatar Rémy Coutable 提交者: GitLab
浏览文件

Merge branch 'add-gitlab-housekeeper-gem-to-ci' into 'master'

Add gitlab-housekeper CI template to run in CI

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144676



Merged-by: default avatarRémy Coutable <remy@rymai.me>
Approved-by: default avatarTiger Watson <twatson@gitlab.com>
Approved-by: default avatarRémy Coutable <remy@rymai.me>
Co-authored-by: default avatarDylan Griffith <dyl.griffith@gmail.com>
Co-authored-by: default avatarDylan Griffith <test@example.com>
No related branches found
No related tags found
无相关合并请求
...@@ -41,3 +41,6 @@ include: ...@@ -41,3 +41,6 @@ include:
- local: .gitlab/ci/templates/gem.gitlab-ci.yml - local: .gitlab/ci/templates/gem.gitlab-ci.yml
inputs: inputs:
gem_name: "gitlab-database-lock_retries" gem_name: "gitlab-database-lock_retries"
- local: .gitlab/ci/templates/gem.gitlab-ci.yml
inputs:
gem_name: "gitlab-housekeeper"
...@@ -20,9 +20,9 @@ Gem::Specification.new do |spec| ...@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
spec.executables = ['gitlab-housekeeper'] spec.executables = ['gitlab-housekeeper']
spec.add_runtime_dependency 'activesupport' spec.add_runtime_dependency 'activesupport'
spec.add_runtime_dependency 'awesome_print'
spec.add_runtime_dependency 'httparty' spec.add_runtime_dependency 'httparty'
spec.add_runtime_dependency 'rubocop' spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'awesome_print'
spec.add_development_dependency 'gitlab-styles' spec.add_development_dependency 'gitlab-styles'
spec.add_development_dependency 'rspec-rails' spec.add_development_dependency 'rspec-rails'
......
...@@ -70,7 +70,7 @@ def each_allowed_rubocop_rule ...@@ -70,7 +70,7 @@ def each_allowed_rubocop_rule
end end
end end
def remove_first_exclusions(rule, file, remove_count) def remove_first_exclusions(_rule, file, remove_count)
content = File.read(file) content = File.read(file)
skipped = 0 skipped = 0
......
...@@ -17,6 +17,7 @@ def setup_master_branch ...@@ -17,6 +17,7 @@ def setup_master_branch
File.write(file_in_master, 'File already in master!') File.write(file_in_master, 'File already in master!')
::Gitlab::Housekeeper::Shell.execute('git', 'init') ::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', 'checkout', '-b', 'master')
::Gitlab::Housekeeper::Shell.execute('git', 'add', file_in_master) ::Gitlab::Housekeeper::Shell.execute('git', 'add', file_in_master)
::Gitlab::Housekeeper::Shell.execute('git', 'commit', '-m', 'Initial commit!') ::Gitlab::Housekeeper::Shell.execute('git', 'commit', '-m', 'Initial commit!')
......
...@@ -2,26 +2,10 @@ ...@@ -2,26 +2,10 @@
require 'spec_helper' require 'spec_helper'
# rubocop:disable RSpec/MultipleMemoizedHelpers
RSpec.describe ::Gitlab::Housekeeper::Keeps::RubocopFixer do RSpec.describe ::Gitlab::Housekeeper::Keeps::RubocopFixer do
let(:todo_dir) { Dir.mktmpdir } 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(:rubocop_fixer) { described_class.new(todo_dir_pattern: todo_dir_pattern, limit_fixes: 5) }
let(:rule1_violating_files) do let(:rule1_violating_files) do
[ [
'rule1_violation1.rb', 'rule1_violation1.rb',
...@@ -45,6 +29,22 @@ ...@@ -45,6 +29,22 @@
] ]
end 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 describe '#each_change' do
it 'iterates over todo_dir_pattern files' do it 'iterates over todo_dir_pattern files' do
yielded_times = 0 yielded_times = 0
...@@ -116,3 +116,4 @@ ...@@ -116,3 +116,4 @@
end end
end end
end end
# rubocop:enable RSpec/MultipleMemoizedHelpers
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册