omnibus-gitlab/danger/template/Dangerfile

51 lines
2.1 KiB
Ruby

# frozen_string_literal: true
# All the files/directories that could contain a user facing configuration change.
ATTRIBUTE_FILES = [
'files/gitlab-cookbooks/consul/attributes/default.rb',
'files/gitlab-cookbooks/consul/attributes/services.rb',
'files/gitlab-cookbooks/consul/attributes/watchers.rb',
'files/gitlab-cookbooks/consul/libraries/',
'files/gitlab-cookbooks/crond/attributes/default.rb',
'files/gitlab-cookbooks/gitaly/attributes/default.rb',
'files/gitlab-cookbooks/gitaly/libraries/',
'files/gitlab-cookbooks/gitlab/attributes/default.rb',
'files/gitlab-cookbooks/gitlab/libraries/',
'files/gitlab-cookbooks/gitlab-ee/attributes/default.rb',
'files/gitlab-cookbooks/gitlab-ee/libraries/',
'files/gitlab-cookbooks/letsencrypt/attributes/default.rb',
'files/gitlab-cookbooks/letsencrypt/libraries/',
'files/gitlab-cookbooks/mattermost/attributes/default.rb',
'files/gitlab-cookbooks/mattermost/libraries/',
'files/gitlab-cookbooks/package/attributes/default.rb',
'files/gitlab-cookbooks/package/libraries/',
'files/gitlab-cookbooks/registry/attributes/default.rb',
'files/gitlab-cookbooks/runit/attributes/external.rb'
].freeze
def user_configuration_paths_requiring_review(files)
to_review = []
files.each do |file|
review = ATTRIBUTE_FILES.any? do |pattern|
file.start_with?(pattern)
end
to_review << file if review
end
to_review
end
configuration_paths_to_review = user_configuration_paths_requiring_review(helper.all_changed_files)
NO_TEMPLATE_CHANGE_MESSAGE = <<~MSG
You've made some changes at the locations which contain user facing configuration.
That's OK as long as you're refactoring existing code and not adding any new
configuration. If you are adding new user facing configuration, consider adding
to gitlab.rb.template located in files/gitlab-config-template/gitlab.rb.template .
Otherwise, please consider adding the ~"type::maintenance" label in that case.
MSG
warn NO_TEMPLATE_CHANGE_MESSAGE, sticky: false if !helper.changes.modified.files.include?('files/gitlab-config-template/gitlab.rb.template') && !configuration_paths_to_review.empty?