diff options
Diffstat (limited to 'danger')
-rw-r--r-- | danger/roulette/Dangerfile | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index d83b7788d73..0e6af5792cd 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'digest/md5' - REVIEW_ROULETTE_SECTION = <<MARKDOWN ## Reviewer roulette MARKDOWN @@ -62,29 +60,22 @@ NOT_AVAILABLE_TEMPLATES = { integrations_fe: group_not_available_template('#g_ecosystem_integrations', '@gitlab-org/ecosystem-stage/integrations') }.freeze -def note_for_spins_role(spins, role, category) +def note_for_spin_role(spin, role, category) template = NOT_AVAILABLE_TEMPLATES[category] || NOT_AVAILABLE_TEMPLATES[:default] - spins.each do |spin| - note = note_for_spin_role(spin, role) - - return note if note - end + note = + if spin.optional_role == role + OPTIONAL_REVIEW_TEMPLATE % { role: role.capitalize, category: helper.label_for_category(spin.category) } + else + spin.public_send(role)&.markdown_name(author: roulette.team_mr_author) # rubocop:disable GitlabSecurity/PublicSend + end - template % { role: role } + note || template % { role: role } end -def note_for_spin_role(spin, role) - if spin.optional_role == role - return OPTIONAL_REVIEW_TEMPLATE % { role: role.capitalize, category: helper.label_for_category(spin.category) } - end - - spin.public_send(role)&.markdown_name(author: roulette.team_mr_author) # rubocop:disable GitlabSecurity/PublicSend -end - -def markdown_row_for_spins(category, spins_array) - maintainer_note = note_for_spins_role(spins_array, :maintainer, category) - reviewer_note = note_for_spins_role(spins_array, :reviewer, category) +def markdown_row_for_spin(category, spin) + maintainer_note = note_for_spin_role(spin, :maintainer, category) + reviewer_note = note_for_spin_role(spin, :reviewer, category) "| #{helper.label_for_category(category)} | #{reviewer_note} | #{maintainer_note} |" end @@ -117,7 +108,11 @@ if changes.any? random_roulette_spins = roulette.spin(nil, categories, timezone_experiment: false) rows = random_roulette_spins.map do |spin| - markdown_row_for_spins(spin.category, [spin]) + markdown_row_for_spin(spin.category, spin) + end + + roulette.required_approvals.each do |approval| + rows << markdown_row_for_spin(approval.category, approval.spin) end markdown(REVIEW_ROULETTE_SECTION) |