Loading .gitlab-ci.yml +11 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,17 @@ static-analysis: script: - rake verify danger-review: image: ruby:3.0 stage: test except: - tags - master before_script: - bundle install script: - bundle exec danger --fail-on-errors=true --verbose deploy: stage: deploy script: Loading .gitlab/CODEOWNERS +1 −1 Original line number Diff line number Diff line * @andrewn @ayufan @reprazent * @andrewn @ayufan @reprazent @mkaeppler Dangerfile 0 → 100644 +11 −0 Original line number Diff line number Diff line # frozen_string_literal: true require 'gitlab-dangerfiles' gitlab_dangerfiles = Gitlab::Dangerfiles::Engine.new(self) gitlab_dangerfiles.import_plugins gitlab_dangerfiles.import_dangerfiles danger.import_plugin('danger/plugins/*.rb') danger.import_dangerfile(path: File.join('danger', 'roulette')) danger/plugins/project_helper.rb 0 → 100644 +15 −0 Original line number Diff line number Diff line # 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 danger/roulette/Dangerfile 0 → 100644 +62 −0 Original line number Diff line number Diff line # 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 Loading
.gitlab-ci.yml +11 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,17 @@ static-analysis: script: - rake verify danger-review: image: ruby:3.0 stage: test except: - tags - master before_script: - bundle install script: - bundle exec danger --fail-on-errors=true --verbose deploy: stage: deploy script: Loading
.gitlab/CODEOWNERS +1 −1 Original line number Diff line number Diff line * @andrewn @ayufan @reprazent * @andrewn @ayufan @reprazent @mkaeppler
Dangerfile 0 → 100644 +11 −0 Original line number Diff line number Diff line # frozen_string_literal: true require 'gitlab-dangerfiles' gitlab_dangerfiles = Gitlab::Dangerfiles::Engine.new(self) gitlab_dangerfiles.import_plugins gitlab_dangerfiles.import_dangerfiles danger.import_plugin('danger/plugins/*.rb') danger.import_dangerfile(path: File.join('danger', 'roulette'))
danger/plugins/project_helper.rb 0 → 100644 +15 −0 Original line number Diff line number Diff line # 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
danger/roulette/Dangerfile 0 → 100644 +62 −0 Original line number Diff line number Diff line # 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