diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /danger/roulette/Dangerfile | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'danger/roulette/Dangerfile')
-rw-r--r-- | danger/roulette/Dangerfile | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index 6c192c3a311..80e832da508 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -40,25 +40,30 @@ MARKDOWN 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 +75,18 @@ 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) + 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 = random_roulette_spins.map do |spin| + markdown_row_for_spins(spin.category, [spin]) end + markdown(MESSAGE) markdown(CATEGORY_TABLE_HEADER + rows.join("\n")) unless rows.empty? unknown = changes.fetch(:unknown, []) |