Commit 7d1f00b6 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch...

Merge branch 'team-tasks-559-reviewer-roulette-quality-maintainer-is-required-for-qa-mrs' into 'master'

Make QA maintainer mandatory if MR is only QA and author is an SET

Closes gitlab-org/quality/team-tasks#559

See merge request gitlab-org/gitlab!36044
parents 0dab993a b1c6535f
...@@ -39,6 +39,10 @@ MARKDOWN ...@@ -39,6 +39,10 @@ MARKDOWN
OPTIONAL_REVIEW_TEMPLATE = "%{role} review is optional for %{category}".freeze OPTIONAL_REVIEW_TEMPLATE = "%{role} review is optional for %{category}".freeze
NOT_AVAILABLE_TEMPLATE = 'No %{role} available'.freeze NOT_AVAILABLE_TEMPLATE = 'No %{role} available'.freeze
def mr_author
roulette.team.find { |person| person.username == gitlab.mr_author }
end
def note_for_category_role(spin, role) def note_for_category_role(spin, role)
if spin.optional_role == role if spin.optional_role == role
return OPTIONAL_REVIEW_TEMPLATE % { role: role.capitalize, category: helper.label_for_category(spin.category) } return OPTIONAL_REVIEW_TEMPLATE % { role: role.capitalize, category: helper.label_for_category(spin.category) }
...@@ -68,7 +72,16 @@ if changes.any? ...@@ -68,7 +72,16 @@ if changes.any?
branch_name = gitlab.mr_json['source_branch'] branch_name = gitlab.mr_json['source_branch']
roulette_spins = roulette.spin(project, categories, branch_name) roulette_spins = roulette.spin(project, categories, branch_name)
rows = roulette_spins.map { |spin| markdown_row_for_spin(spin) } 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.reviewer?(project, spin.category, [])
spin.optional_role = :maintainer
end
spin.optional_role = :maintainer if spin.category == :test
markdown_row_for_spin(spin)
end
unknown = changes.fetch(:unknown, []) unknown = changes.fetch(:unknown, [])
......
...@@ -6,7 +6,6 @@ module Gitlab ...@@ -6,7 +6,6 @@ module Gitlab
module Danger module Danger
module Roulette module Roulette
ROULETTE_DATA_URL = 'https://gitlab-org.gitlab.io/gitlab-roulette/roulette.json' ROULETTE_DATA_URL = 'https://gitlab-org.gitlab.io/gitlab-roulette/roulette.json'
OPTIONAL_CATEGORIES = [:qa, :test].freeze
Spin = Struct.new(:category, :reviewer, :maintainer, :optional_role) Spin = Struct.new(:category, :reviewer, :maintainer, :optional_role)
...@@ -119,11 +118,7 @@ module Gitlab ...@@ -119,11 +118,7 @@ module Gitlab
reviewer = spin_for_person(reviewers + traintainers + traintainers, random: random) reviewer = spin_for_person(reviewers + traintainers + traintainers, random: random)
maintainer = spin_for_person(maintainers, random: random) maintainer = spin_for_person(maintainers, random: random)
Spin.new(category, reviewer, maintainer).tap do |spin| Spin.new(category, reviewer, maintainer)
if OPTIONAL_CATEGORIES.include?(category)
spin.optional_role = :maintainer
end
end
end end
end end
end end
......
...@@ -155,8 +155,8 @@ RSpec.describe Gitlab::Danger::Roulette do ...@@ -155,8 +155,8 @@ RSpec.describe Gitlab::Danger::Roulette do
context 'when change contains QA category' do context 'when change contains QA category' do
let(:categories) { [:qa] } let(:categories) { [:qa] }
it 'assigns QA reviewer and sets optional QA maintainer' do it 'assigns QA reviewer' do
expect(spins).to contain_exactly(matching_spin(:qa, reviewer: software_engineer_in_test, optional: :maintainer)) expect(spins).to contain_exactly(matching_spin(:qa, reviewer: software_engineer_in_test))
end end
end end
...@@ -171,8 +171,8 @@ RSpec.describe Gitlab::Danger::Roulette do ...@@ -171,8 +171,8 @@ RSpec.describe Gitlab::Danger::Roulette do
context 'when change contains test category' do context 'when change contains test category' do
let(:categories) { [:test] } let(:categories) { [:test] }
it 'assigns corresponding SET and sets optional test maintainer' do it 'assigns corresponding SET' do
expect(spins).to contain_exactly(matching_spin(:test, reviewer: software_engineer_in_test, optional: :maintainer)) expect(spins).to contain_exactly(matching_spin(:test, reviewer: software_engineer_in_test))
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment