summaryrefslogtreecommitdiff
path: root/danger
diff options
context:
space:
mode:
Diffstat (limited to 'danger')
-rw-r--r--danger/gitlab_ui_wg/Dangerfile29
-rw-r--r--danger/roulette/Dangerfile8
-rw-r--r--danger/single_codebase/Dangerfile14
3 files changed, 29 insertions, 22 deletions
diff --git a/danger/gitlab_ui_wg/Dangerfile b/danger/gitlab_ui_wg/Dangerfile
index 02d94fa5ab7..672b1deecb3 100644
--- a/danger/gitlab_ui_wg/Dangerfile
+++ b/danger/gitlab_ui_wg/Dangerfile
@@ -1,29 +1,36 @@
+FRONTEND_MAINTAINERS = %w[filipa iamphill psimyn sarahghp mishunov].freeze
+UX_MAINTAINERS = %w[tauriedavis rverissimo].freeze
+NO_REVIEWER = 'No reviewer available'.freeze
+
def mention_single_codebase_approvers
- frontend_maintainers = %w(@filipa @iamphill @psimyn @sarahghp @mishunov)
- ux_maintainers = %w(@tauriedavis @rverissimo)
+ canonical_branch_name =
+ roulette.canonical_branch_name(gitlab.mr_json['source_branch'])
+
+ random = roulette.new_random(canonical_branch_name)
+
+ frontend_maintainers = helper.new_teammates(FRONTEND_MAINTAINERS)
+ ux_maintainers = helper.new_teammates(UX_MAINTAINERS)
rows = []
- users = []
if gitlab.mr_labels.include?('frontend')
- frontend_maintainer = frontend_maintainers.sample
+ frontend_maintainer =
+ roulette.spin_for_person(frontend_maintainers, random: random)
- rows << "| ~frontend | `#{frontend_maintainer}`"
- users << frontend_maintainer
+ rows << "| ~frontend | #{frontend_maintainer&.markdown_name || NO_REVIEWER}"
end
if gitlab.mr_labels.include?('UX')
- ux_maintainers = ux_maintainers.sample
+ ux_maintainers =
+ roulette.spin_for_person(ux_maintainers, random: random)
- rows << "| ~UX | `#{ux_maintainers}`"
- users << ux_maintainers
+ rows << "| ~UX | #{ux_maintainers&.markdown_name || NO_REVIEWER}"
end
if rows.empty?
backup_maintainer = frontend_maintainers.sample
- rows << "| ~frontend / ~UX | `#{backup_maintainer}`"
- users << backup_maintainer
+ rows << "| ~frontend / ~UX | #{backup_maintainer.markdown_name}"
end
markdown(<<~MARKDOWN.strip)
diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile
index a0f1447e76a..6718e218233 100644
--- a/danger/roulette/Dangerfile
+++ b/danger/roulette/Dangerfile
@@ -31,6 +31,9 @@ Please consider creating a merge request to
for them.
MARKDOWN
+NO_REVIEWER = 'No reviewer available'.freeze
+NO_MAINTAINER = 'No maintainer available'.freeze
+
def spin_for_category(team, project, category, branch_name)
random = roulette.new_random(branch_name)
labels = gitlab.mr_labels
@@ -49,7 +52,7 @@ def spin_for_category(team, project, category, branch_name)
reviewer = roulette.spin_for_person(reviewers + traintainers + traintainers, random: random)
maintainer = roulette.spin_for_person(maintainers, random: random)
- "| #{helper.label_for_category(category)} | #{reviewer&.markdown_name} | #{maintainer&.markdown_name} |"
+ "| #{helper.label_for_category(category)} | #{reviewer&.markdown_name || NO_REVIEWER} | #{maintainer&.markdown_name || NO_MAINTAINER} |"
end
def build_list(items)
@@ -85,9 +88,6 @@ if changes.any? && !gitlab.mr_labels.include?('single codebase') && !gitlab.mr_l
[]
end
- # Exclude the MR author from the team for selection purposes
- team.delete_if { |teammate| teammate.username == gitlab.mr_author }
-
project = helper.project_name
unknown = changes.fetch(:unknown, [])
diff --git a/danger/single_codebase/Dangerfile b/danger/single_codebase/Dangerfile
index d1f538bec7f..f371a42e9b1 100644
--- a/danger/single_codebase/Dangerfile
+++ b/danger/single_codebase/Dangerfile
@@ -1,6 +1,6 @@
-def new_teammates(usernames)
- usernames.map { |u| ::Gitlab::Danger::Teammate.new('username' => u) }
-end
+FRONTEND_MAINTAINERS = %w[filipa iamphill].freeze
+BACKEND_MAINTAINERS = %w[rspeicher rymai yorickpeterse godfat].freeze
+NO_REVIEWER = 'No reviewer available'.freeze
def mention_single_codebase_approvers
canonical_branch_name =
@@ -8,8 +8,8 @@ def mention_single_codebase_approvers
random = roulette.new_random(canonical_branch_name)
- frontend_maintainers = new_teammates(%w[filipa iamphill])
- backend_maintainers = new_teammates(%w[rspeicher rymai yorickpeterse godfat])
+ frontend_maintainers = helper.new_teammates(FRONTEND_MAINTAINERS)
+ backend_maintainers = helper.new_teammates(BACKEND_MAINTAINERS)
rows = []
@@ -17,14 +17,14 @@ def mention_single_codebase_approvers
frontend_maintainer =
roulette.spin_for_person(frontend_maintainers, random: random)
- rows << "| ~frontend | #{frontend_maintainer.markdown_name}"
+ rows << "| ~frontend | #{frontend_maintainer&.markdown_name || NO_REVIEWER}"
end
if gitlab.mr_labels.include?('backend')
backend_maintainer =
roulette.spin_for_person(backend_maintainers, random: random)
- rows << "| ~backend | #{backend_maintainer.markdown_name}"
+ rows << "| ~backend | #{backend_maintainer&.markdown_name || NO_REVIEWER}"
end
if rows.empty?