Skip to content
Snippets Groups Projects
Commit 1e4836f2 authored by Matthias Käppler's avatar Matthias Käppler :two: Committed by Bob Van Landuyt
Browse files

Update gitlab-dangerfiles to 2.6

parent c9e19af7
No related branches found
No related tags found
1 merge request!86Update gitlab-dangerfiles to 2.6
...@@ -2,10 +2,4 @@ ...@@ -2,10 +2,4 @@
require 'gitlab-dangerfiles' require 'gitlab-dangerfiles'
gitlab_dangerfiles = Gitlab::Dangerfiles::Engine.new(self) Gitlab::Dangerfiles.for_project(self, 'labkit-ruby', &:import_defaults)
gitlab_dangerfiles.import_plugins
gitlab_dangerfiles.import_dangerfiles
danger.import_plugin('danger/plugins/*.rb')
danger.import_dangerfile(path: File.join('danger', 'roulette'))
# frozen_string_literal: true
module Danger
# Common helper functions for danger scripts
class ProjectHelper < ::Danger::Plugin
def changes
# We do not need to categorize files in this code base
helper.changes([])
end
def project_name
"labkit-ruby"
end
end
end
# frozen_string_literal: true
MESSAGE = <<MARKDOWN
## Reviewer roulette
Changes that require review have been detected! A merge request is normally
reviewed by both a reviewer and a maintainer in its primary category and by a
maintainer in all other categories.
MARKDOWN
TABLE_MARKDOWN = <<MARKDOWN
To spread load more evenly across eligible reviewers, Danger has picked a candidate for each
review slot. Feel free to
[override these selections](https://about.gitlab.com/handbook/engineering/projects/#labkit-ruby)
if you think someone else would be better-suited
or request help in the `#labkit` Slack channel.
To read more on how to use the reviewer roulette, please take a look at the
[Engineering workflow](https://about.gitlab.com/handbook/engineering/workflow/#basics)
and [code review guidelines](https://docs.gitlab.com/ee/development/code_review.html).
Once you've decided who will review this merge request, mention them as you
normally would! Danger does not automatically notify them for you.
| Reviewer | Maintainer |
| -------- | ---------- |
MARKDOWN
def note_for_spins_role(spins, role)
spins.each do |spin|
note = note_for_spin_role(spin, role)
return note if note
end
'No %{role} available' % { role: role }
end
def note_for_spin_role(spin, role)
spin.public_send(role)&.markdown_name(author: roulette.team_mr_author) # rubocop:disable GitlabSecurity/PublicSend
end
def markdown_row_for_spins(spins_array)
reviewer_note = note_for_spins_role(spins_array, :reviewer)
maintainer_note = note_for_spins_role(spins_array, :maintainer)
"#{reviewer_note} | #{maintainer_note} |"
end
if project_helper.changes.any?
project = project_helper.project_name
random_roulette_spins = roulette.spin(project, [nil], timezone_experiment: false)
rows = random_roulette_spins.map do |spin|
markdown_row_for_spins([spin])
end
markdown(MESSAGE)
markdown(TABLE_MARKDOWN + rows.join("\n")) unless rows.empty?
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment