Improve danger/specs/Dangerfile by not requiring new specs if specific labels are applied

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2018-07-16 19:23:45 +02:00
parent 3e573142b7
commit 8ce6381f3c
No known key found for this signature in database
GPG key ID: 98DFFD1C0C62B70B

View file

@ -1,12 +1,18 @@
NO_SPECS_LABELS = %w[backstage Documentation QA].freeze
NO_NEW_SPEC_MESSAGE = <<~MSG.freeze 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 the ~backstage label in that case. but please consider adding any of the %<labels>s labels.
MSG MSG
has_app_changes = !git.modified_files.grep(%r{\A(ee/)?(app|lib|db/(geo/)?(post_)?migrate)/}).empty? def presented_no_changelog_labels
has_spec_changes = !git.modified_files.grep(/spec/).empty? NO_SPECS_LABELS.map { |label| "~#{label}" }.join(', ')
end
if has_app_changes && !has_spec_changes
warn NO_NEW_SPEC_MESSAGE, sticky: false has_app_changes = !git.modified_files.grep(%r{\A(ee/)?(app|lib|db/(geo/)?(post_)?migrate)/}).empty?
has_spec_changes = !git.modified_files.grep(%r{\A(ee/)?spec/}).empty?
new_specs_needed = (gitlab.mr_labels & NO_SPECS_LABELS).empty?
if has_app_changes && !has_spec_changes && new_specs_needed
warn format(NO_NEW_SPEC_MESSAGE, labels: presented_no_changelog_labels), sticky: false
end end