diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-22 21:09:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-22 21:09:50 +0000 |
commit | f05ceb978a12b289fe4e3575420b8c9316041e3a (patch) | |
tree | 3c1e7c3cf846e1af0ff0edb5867134ca477b3b58 /danger/roulette | |
parent | 3ce55b46dfae23d14818ed2630891be8aa3e83e0 (diff) | |
download | gitlab-ce-f05ceb978a12b289fe4e3575420b8c9316041e3a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'danger/roulette')
-rw-r--r-- | danger/roulette/Dangerfile | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index 6c192c3a311..bf5c6e4c821 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -42,23 +42,29 @@ OPTIONAL_REVIEW_TEMPLATE = "%{role} review is optional for %{category}".freeze NOT_AVAILABLE_TEMPLATE = 'No %{role} available'.freeze TIMEZONE_EXPERIMENT = true -def mr_author - roulette.team.find { |person| person.username == gitlab.mr_author } +def note_for_spins_role(spins, role) + spins.each do |spin| + note = note_for_spin_role(spin, role) + + return note if note + end + + NOT_AVAILABLE_TEMPLATE % { role: role } end -def note_for_category_role(spin, role) +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(timezone_experiment: TIMEZONE_EXPERIMENT, author: mr_author) || NOT_AVAILABLE_TEMPLATE % { role: role } # rubocop:disable GitlabSecurity/PublicSend + spin.public_send(role)&.markdown_name(timezone_experiment: spin.timezone_experiment, author: roulette.team_mr_author) # rubocop:disable GitlabSecurity/PublicSend end -def markdown_row_for_spin(spin) - reviewer_note = note_for_category_role(spin, :reviewer) - maintainer_note = note_for_category_role(spin, :maintainer) +def markdown_row_for_spins(category, spins_array) + reviewer_note = note_for_spins_role(spins_array, :reviewer) + maintainer_note = note_for_spins_role(spins_array, :maintainer) - "| #{helper.label_for_category(spin.category)} | #{reviewer_note} | #{maintainer_note} |" + "| #{helper.label_for_category(category)} | #{reviewer_note} | #{maintainer_note} |" end changes = helper.changes_by_category @@ -70,26 +76,20 @@ changes.delete(:docs) categories = changes.keys - [:unknown] # Ensure to spin for database reviewer/maintainer when ~database is applied (e.g. to review SQL queries) -categories << :database if gitlab.mr_labels.include?('database') && !categories.include?(:database) +categories << :database if helper.gitlab_helper&.mr_labels&.include?('database') && !categories.include?(:database) if changes.any? project = helper.project_name - branch_name = gitlab.mr_json['source_branch'] - markdown(MESSAGE) + timezone_roulette_spins = roulette.spin(project, categories, timezone_experiment: true) + random_roulette_spins = roulette.spin(project, categories, timezone_experiment: false) - roulette_spins = roulette.spin(project, categories, branch_name, timezone_experiment: TIMEZONE_EXPERIMENT) - rows = roulette_spins.map do |spin| - # MR includes QA changes, but also other changes, and author isn't an SET - if spin.category == :qa && categories.size > 1 && mr_author && !mr_author.reviewer?(project, spin.category, []) - spin.optional_role = :maintainer - end - - spin.optional_role = :maintainer if spin.category == :test - - markdown_row_for_spin(spin) + rows = timezone_roulette_spins.map do |spin| + fallback_spin = random_roulette_spins.find { |random_roulette_spins| random_roulette_spins.category == spin.category } + markdown_row_for_spins(spin.category, [spin, fallback_spin]) end + markdown(MESSAGE) markdown(CATEGORY_TABLE_HEADER + rows.join("\n")) unless rows.empty? unknown = changes.fetch(:unknown, []) |