Class: Danger::Roulette
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::Roulette
- Defined in:
- lib/danger/plugins/roulette.rb
Overview
Common helper functions for our danger scripts. See Danger::Helper for more details
Constant Summary collapse
- HOURS_WHEN_PERSON_CAN_BE_PICKED =
(6..14).freeze
- HTTPError =
Class.new(StandardError)
Instance Method Summary collapse
- #codeowners_approvals ⇒ Object (also: #required_approvals)
- #prepare_categories(changes_keys) ⇒ Object
-
#spin(project = nil, categories = [:none], ux_fallback_wider_community_reviewer: teammate_pedroms) ⇒ Array<Spin>
Assigns GitLab team members to be reviewer and maintainer for the given
categories
. -
#team_mr_author ⇒ Gitlab::Dangerfiles::Teammate
Finds the
Gitlab::Dangerfiles::Teammate
object whose username matches the MR author username. -
#warnings ⇒ Object
For backward compatibility.
Instance Method Details
#codeowners_approvals ⇒ Object Also known as: required_approvals
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/danger/plugins/roulette.rb', line 64 def codeowners_approvals approval_rules = helper.mr_approval_state["rules"] return [] unless approval_rules required_approval_rules = unique_approval_rules(approval_rules) required_approval_rules.filter_map do |rule| if spin_for_approval_rule?(rule) approver = Gitlab::Dangerfiles::Spinner.new( project: config_project_name.downcase, author: helper., team_author: , random: random ).spin_for_approver(rule) Gitlab::Dangerfiles::Approval.from_approval_rule(rule, approver) end end end |
#prepare_categories(changes_keys) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/danger/plugins/roulette.rb', line 14 def prepare_categories(changes_keys) categories = Set.new(changes_keys) # Ensure to spin for database reviewer/maintainer when ~database is applied (e.g. to review SQL queries) categories << :database if labels.include?("database") # Ensure to spin for Analytics Instrumentation reviewer when ~"analytics instrumentation::review pending" is applied categories << :analytics_instrumentation if labels.include?("analytics instrumentation::review pending") # Skip Analytics Instrumentation reviews for growth experiment MRs categories.delete(:analytics_instrumentation) if labels.include?("growth experiment") prepare_ux_category!(categories) if labels.include?("UX") # Remove disabled categories categories.subtract(helper.config.disabled_roulette_categories) categories end |
#spin(project = nil, categories = [:none], ux_fallback_wider_community_reviewer: teammate_pedroms) ⇒ Array<Spin>
Assigns GitLab team members to be reviewer and maintainer for the given categories
.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/danger/plugins/roulette.rb', line 48 def spin(project = nil, categories = [:none], ux_fallback_wider_community_reviewer: teammate_pedroms) # TODO: Deprecate the project argument. It prevents us from # memorizing Spinner and can cause unexpected results if it's # passing a different project than the merge request project. project = (project || config_project_name).downcase categories = categories.map { |category| category&.downcase || :none } Gitlab::Dangerfiles::Spinner.new( project: project, author: helper., team_author: , labels: labels, categories: categories, random: random, ux_fallback_wider_community_reviewer: ux_fallback_wider_community_reviewer) .spin end |
#team_mr_author ⇒ Gitlab::Dangerfiles::Teammate
Finds the Gitlab::Dangerfiles::Teammate
object whose username matches the MR author username.
37 38 39 |
# File 'lib/danger/plugins/roulette.rb', line 37 def @team_mr_author ||= Gitlab::Dangerfiles::Teammate.find_member(helper.) end |
#warnings ⇒ Object
For backward compatibility
86 87 88 |
# File 'lib/danger/plugins/roulette.rb', line 86 def warnings Gitlab::Dangerfiles::Teammate.warnings end |