omnibus-gitlab/scripts/support/metadata/Dangerfile

33 lines
1.4 KiB
Ruby

# rubocop:disable Style/SignalException
WORKTYPE_LABELS = [
'type::bug',
'type::feature',
'type::maintenance'
].freeze
fail "Please provide a proper merge request description." if gitlab.mr_body.size < 5
fail "Please add labels to this merge request." if gitlab.mr_labels.empty?
warn "You may want to add ~group::distribution label to this MR for gitlab-insights" unless gitlab.mr_labels.any? { |label| label.start_with?("group::") }
warn "This merge request does not have any assignee yet. Setting an assignee clarifies who needs to take action on the merge request at any given time." unless gitlab.mr_json["assignee"]
has_milestone = !gitlab.mr_json["milestone"].nil?
warn "This merge request does not refer to an existing milestone.", sticky: false unless has_milestone
has_pick_into_stable_label = gitlab.mr_labels.find { |label| label.start_with?('Pick into') }
# rubocop:disable Style/IfUnlessModifier
if gitlab.branch_for_base != "master" && !has_pick_into_stable_label
warn "Most of the time, all merge requests should target `master`. Otherwise, please set the relevant `Pick into X.Y` label."
end
if (gitlab.mr_labels & WORKTYPE_LABELS).empty?
warn "This merge request is missing any [engineering metrics labels](https://about.gitlab.com/handbook/engineering/metrics/#work-type-classification)."
end
# rubocop:enable Style/IfUnlessModifier
# rubocop:enable Style/SignalException