Commit 6c6fe36b authored by Jarka Košanová's avatar Jarka Košanová

Merge branch '295639-add-warning-for-file-addition-of-controller-specs-to-danger' into 'master'

Add warning for file addition of controller specs to Danger

See merge request gitlab-org/gitlab!50566
parents 3e647338 eeb0a338
...@@ -7,12 +7,12 @@ NO_SPECS_LABELS = [ ...@@ -7,12 +7,12 @@ NO_SPECS_LABELS = [
'documentation', 'documentation',
'QA' 'QA'
].freeze ].freeze
NO_NEW_SPEC_MESSAGE = <<~MSG NO_NEW_SPEC_MESSAGE = <<~MSG.freeze
You've made some app changes, but didn't add any tests. You've made some app changes, but didn't add any tests.
That's OK as long as you're refactoring existing code, That's OK as long as you're refactoring existing code,
but please consider adding any of the %<labels>s labels. but please consider adding any of the %<labels>s labels.
MSG MSG
EE_CHANGE_WITH_FOSS_SPEC_CHANGE_MESSAGE = <<~MSG EE_CHANGE_WITH_FOSS_SPEC_CHANGE_MESSAGE = <<~MSG.freeze
You've made some EE-specific changes, but only made changes to FOSS tests. You've made some EE-specific changes, but only made changes to FOSS tests.
This could be a sign that you're testing an EE-specific behavior in a FOSS test. This could be a sign that you're testing an EE-specific behavior in a FOSS test.
...@@ -24,6 +24,14 @@ Please make sure the spec files pass in AS-IF-FOSS mode either: ...@@ -24,6 +24,14 @@ Please make sure the spec files pass in AS-IF-FOSS mode either:
MSG MSG
CONTROLLER_SPEC_DEPRECATION_MESSAGE = <<~MSG.freeze
Do not add new controller specs. We are moving from controller specs to
request specs (and/or feature specs). Please add request specs under
`/spec/requests` and/or `/ee/spec/requests` instead.
See https://gitlab.com/groups/gitlab-org/-/epics/5076 for information.
MSG
has_app_changes = helper.all_changed_files.grep(%r{\A(app|lib|db/(geo/)?(post_)?migrate)/}).any? has_app_changes = helper.all_changed_files.grep(%r{\A(app|lib|db/(geo/)?(post_)?migrate)/}).any?
has_ee_app_changes = helper.all_changed_files.grep(%r{\Aee/(app|lib|db/(geo/)?(post_)?migrate)/}).any? has_ee_app_changes = helper.all_changed_files.grep(%r{\Aee/(app|lib|db/(geo/)?(post_)?migrate)/}).any?
spec_changes = helper.all_changed_files.grep(%r{\Aspec/}) spec_changes = helper.all_changed_files.grep(%r{\Aspec/})
...@@ -39,3 +47,8 @@ end ...@@ -39,3 +47,8 @@ end
if has_ee_app_changes && has_spec_changes && !(has_app_changes || has_ee_spec_changes) if has_ee_app_changes && has_spec_changes && !(has_app_changes || has_ee_spec_changes)
warn format(EE_CHANGE_WITH_FOSS_SPEC_CHANGE_MESSAGE, spec_files: spec_changes.join(" "), mr_title: gitlab.mr_json['title']), sticky: false warn format(EE_CHANGE_WITH_FOSS_SPEC_CHANGE_MESSAGE, spec_files: spec_changes.join(" "), mr_title: gitlab.mr_json['title']), sticky: false
end end
# Forbidding a new file addition under `/spec/controllers` or `/ee/spec/controllers`
if git.added_files.grep(%r{^(ee/)?spec/controllers/}).any?
warn CONTROLLER_SPEC_DEPRECATION_MESSAGE
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment