2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
require 'gitlab-dangerfiles'
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
def ee?
|
|
|
|
# Support former project name for `dev` and support local Danger run
|
|
|
|
%w[gitlab gitlab-ee].include?(ENV['CI_PROJECT_NAME']) || Dir.exist?(File.expand_path('ee', __dir__))
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
project_name = ee? ? 'gitlab' : 'gitlab-foss'
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
Gitlab::Dangerfiles.for_project(self, project_name) do |gitlab_dangerfiles|
|
|
|
|
gitlab_dangerfiles.import_plugins
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
unless helper.release_automation?
|
|
|
|
danger.import_plugin('danger/plugins/*.rb')
|
|
|
|
gitlab_dangerfiles.import_dangerfiles(except: %w[simple_roulette])
|
|
|
|
gitlab_dangerfiles.config.files_to_category = ProjectHelper::CATEGORIES
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return if helper.release_automation?
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
project_helper.rule_names.each do |rule|
|
|
|
|
danger.import_dangerfile(path: File.join('danger', rule))
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
anything_to_post = status_report.values.any? { |data| data.any? }
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
return unless helper.ci?
|
|
|
|
|
|
|
|
def post_labels
|
|
|
|
gitlab.api.update_merge_request(gitlab.mr_json['project_id'],
|
|
|
|
gitlab.mr_json['iid'],
|
|
|
|
add_labels: project_helper.labels_to_add.join(','))
|
|
|
|
rescue Gitlab::Error::Forbidden
|
|
|
|
labels = project_helper.labels_to_add.map { |label| %Q(~"#{label}") }
|
|
|
|
warn("This Merge Request needs to be labelled with #{labels.join(' ')}. Please request a reviewer or maintainer to add them.")
|
|
|
|
end
|
|
|
|
|
|
|
|
if project_helper.labels_to_add.any?
|
|
|
|
post_labels
|
|
|
|
end
|
|
|
|
|
|
|
|
if anything_to_post
|
2020-06-23 00:09:42 +05:30
|
|
|
markdown("**If needed, you can retry the [`danger-review` job](#{ENV['CI_JOB_URL']}) that generated this comment.**")
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|