diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /tooling/gitlab_danger.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'tooling/gitlab_danger.rb')
-rw-r--r-- | tooling/gitlab_danger.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tooling/gitlab_danger.rb b/tooling/gitlab_danger.rb new file mode 100644 index 00000000000..d20d3499641 --- /dev/null +++ b/tooling/gitlab_danger.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# rubocop:todo Gitlab/NamespacedClass +class GitlabDanger + LOCAL_RULES ||= %w[ + changes_size + commit_messages + database + documentation + duplicate_yarn_dependencies + eslint + karma + pajamas + pipeline + prettier + product_intelligence + utility_css + ].freeze + + CI_ONLY_RULES ||= %w[ + ce_ee_vue_templates + changelog + ci_templates + metadata + feature_flag + roulette + sidekiq_queues + specialization_labels + specs + ].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 |