2018-10-23 10:27:25 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-18 11:08:45 -04:00
|
|
|
NO_SPECS_LABELS = [
|
|
|
|
'tooling',
|
|
|
|
'tooling::pipelines',
|
|
|
|
'tooling::workflow',
|
|
|
|
'documentation',
|
|
|
|
'QA'
|
|
|
|
].freeze
|
2021-01-05 07:10:36 -05:00
|
|
|
NO_NEW_SPEC_MESSAGE = <<~MSG.freeze
|
2018-07-10 06:10:54 -04:00
|
|
|
You've made some app changes, but didn't add any tests.
|
|
|
|
That's OK as long as you're refactoring existing code,
|
2018-07-16 13:23:45 -04:00
|
|
|
but please consider adding any of the %<labels>s labels.
|
2018-07-10 06:10:54 -04:00
|
|
|
MSG
|
2021-01-05 07:10:36 -05:00
|
|
|
EE_CHANGE_WITH_FOSS_SPEC_CHANGE_MESSAGE = <<~MSG.freeze
|
2020-06-03 11:08:05 -04:00
|
|
|
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.
|
2018-07-10 06:10:54 -04:00
|
|
|
|
2020-06-03 11:08:05 -04:00
|
|
|
Please make sure the spec files pass in AS-IF-FOSS mode either:
|
|
|
|
|
|
|
|
1. Locally with `FOSS_ONLY=1 bin/rspec -- %<spec_files>s`.
|
|
|
|
1. In the MR pipeline by verifying that the `rspec foss-impact` job has passed.
|
|
|
|
1. In the MR pipelines by including `RUN AS-IF-FOSS` in the MR title (you can do it with the ``/title %<mr_title>s [RUN AS-IF-FOSS]`` quick action) and start a new MR pipeline.
|
|
|
|
|
|
|
|
MSG
|
|
|
|
|
2021-01-05 07:10:36 -05:00
|
|
|
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
|
|
|
|
|
2020-06-03 11:08:05 -04:00
|
|
|
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?
|
|
|
|
spec_changes = helper.all_changed_files.grep(%r{\Aspec/})
|
|
|
|
has_spec_changes = spec_changes.any?
|
|
|
|
has_ee_spec_changes = helper.all_changed_files.grep(%r{\Aee/spec/}).any?
|
2018-07-16 13:23:45 -04:00
|
|
|
new_specs_needed = (gitlab.mr_labels & NO_SPECS_LABELS).empty?
|
2018-05-21 12:41:21 -04:00
|
|
|
|
2020-06-03 11:08:05 -04:00
|
|
|
if (has_app_changes || has_ee_app_changes) && !(has_spec_changes || has_ee_spec_changes) && new_specs_needed
|
2020-04-28 14:09:35 -04:00
|
|
|
warn format(NO_NEW_SPEC_MESSAGE, labels: helper.labels_list(NO_SPECS_LABELS)), sticky: false
|
2018-05-21 12:41:21 -04:00
|
|
|
end
|
2020-06-03 11:08:05 -04:00
|
|
|
|
|
|
|
# The only changes outside `ee/` are in `spec/`
|
|
|
|
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
|
|
|
|
end
|
2021-01-05 07:10:36 -05:00
|
|
|
|
|
|
|
# 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
|