debian-mirror-gitlab/tooling/gitlab_danger.rb

60 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
2021-03-11 19:13:27 +05:30
# rubocop:todo Gitlab/NamespacedClass
2019-12-04 20:38:33 +05:30
class GitlabDanger
LOCAL_RULES ||= %w[
changes_size
2021-03-11 19:13:27 +05:30
commit_messages
database
2019-12-04 20:38:33 +05:30
documentation
duplicate_yarn_dependencies
eslint
2020-04-08 14:13:33 +05:30
karma
2020-11-24 15:15:51 +05:30
pajamas
2021-02-22 17:27:13 +05:30
pipeline
2021-03-11 19:13:27 +05:30
prettier
product_intelligence
utility_css
2019-12-04 20:38:33 +05:30
].freeze
CI_ONLY_RULES ||= %w[
2021-03-11 19:13:27 +05:30
ce_ee_vue_templates
2019-12-04 20:38:33 +05:30
changelog
2021-03-11 19:13:27 +05:30
ci_templates
metadata
feature_flag
2019-12-04 20:38:33 +05:30
roulette
2020-07-28 23:09:34 +05:30
sidekiq_queues
2020-11-24 15:15:51 +05:30
specialization_labels
2021-03-11 19:13:27 +05:30
specs
2019-12-04 20:38:33 +05:30
].freeze
MESSAGE_PREFIX = '==>'.freeze
attr_reader :gitlab_danger_helper
def initialize(gitlab_danger_helper)
@gitlab_danger_helper = gitlab_danger_helper
end
def self.local_warning_message
"#{MESSAGE_PREFIX} Only the following Danger rules can be run locally: #{LOCAL_RULES.join(', ')}"
end
def self.success_message
"#{MESSAGE_PREFIX} No Danger rule violations!"
end
def rule_names
ci? ? LOCAL_RULES | CI_ONLY_RULES : LOCAL_RULES
end
def html_link(str)
self.ci? ? gitlab_danger_helper.html_link(str) : str
end
def ci?
!gitlab_danger_helper.nil?
end
end