Commit 94ccdc01 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak Committed by Rémy Coutable

Apply Product Intelligence category in roulette

In order to utilize review roulette automation for product
intelligence reviews, new category has to be applied to MRs
parent ff04877c
......@@ -84,12 +84,7 @@ matching_changed_files = usage_data_changed_files +
if matching_changed_files.any?
mention = if helper.draft_mr?
"`#{ENGINEERS_GROUP}`"
else
ENGINEERS_GROUP
end
mention = "`#{ENGINEERS_GROUP}`"
warn format(CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(matching_changed_files), engineers_group: mention)
fail format(UPDATE_DICTIONARY_MESSAGE) if required_dictionary_update_changed_files.any? && dictionary_changed_file.empty?
......
......@@ -40,16 +40,21 @@ for them.
MARKDOWN
OPTIONAL_REVIEW_TEMPLATE = '%{role} review is optional for %{category}'
NOT_AVAILABLE_TEMPLATE = 'No %{role} available'
NOT_AVAILABLE_TEMPLATES = {
default: 'No %{role} available',
product_intelligence: "No engineer is available for automated assignment, please reach out to `#g_product_intelligence` slack channel or mention `@gitlab-org/growth/product-intelligence/engineers` for assistance."
}.freeze
def note_for_spins_role(spins, role, category)
template = NOT_AVAILABLE_TEMPLATES[category] || NOT_AVAILABLE_TEMPLATES[:default]
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 }
template % { role: role }
end
def note_for_spin_role(spin, role)
......@@ -61,8 +66,8 @@ def note_for_spin_role(spin, role)
end
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)
maintainer_note = note_for_spins_role(spins_array, :maintainer, category)
reviewer_note = note_for_spins_role(spins_array, :reviewer, category)
"| #{helper.label_for_category(category)} | #{reviewer_note} | #{maintainer_note} |"
end
......@@ -77,10 +82,13 @@ changes.delete(:docs)
changes.delete(:changelog)
# No special review for feature flags needed.
changes.delete(:feature_flag)
categories = changes.keys - [:unknown]
categories = Set.new(changes.keys - [:unknown])
# Ensure to spin for database reviewer/maintainer when ~database is applied (e.g. to review SQL queries)
categories << :database if helper.mr_labels.include?('database') && !categories.include?(:database)
categories << :database if helper.mr_labels.include?('database')
# Ensure to spin for Product Intelligence reviewer when ~"product intelligence::review pending" is applied
categories << :product_intelligence if helper.mr_labels.include?("product intelligence::review pending")
if changes.any?
project = project_helper.project_name
......
......@@ -43,7 +43,7 @@ RSpec.describe Tooling::Danger::ProjectHelper do
end
where(:path, :expected_categories) do
'usage_data.rb' | [:database, :backend]
'usage_data.rb' | [:database, :backend, :product_intelligence]
'doc/foo.md' | [:docs]
'CONTRIBUTING.md' | [:docs]
'LICENSE' | [:docs]
......@@ -171,6 +171,21 @@ RSpec.describe Tooling::Danger::ProjectHelper do
'foo/bar.js' | [:frontend]
'foo/bar.txt' | [:none]
'foo/bar.md' | [:none]
'ee/config/metrics/counts_7d/20210216174919_g_analytics_issues_weekly.yml' | [:product_intelligence]
'lib/gitlab/usage_data_counters/aggregated_metrics/common.yml' | [:product_intelligence]
'lib/gitlab/usage_data_counters/hll_redis_counter.rb' | [:backend, :product_intelligence]
'doc/development/usage_ping/dictionary.md' | [:docs, :product_intelligence]
'lib/gitlab/tracking.rb' | [:backend, :product_intelligence]
'spec/lib/gitlab/tracking_spec.rb' | [:backend, :product_intelligence]
'app/helpers/tracking_helper.rb' | [:backend, :product_intelligence]
'spec/helpers/tracking_helper_spec.rb' | [:backend, :product_intelligence]
'lib/generators/rails/usage_metric_definition_generator.rb' | [:backend, :product_intelligence]
'spec/lib/generators/usage_metric_definition_generator_spec.rb' | [:backend, :product_intelligence]
'config/metrics/schema.json' | [:product_intelligence]
'app/assets/javascripts/tracking.js' | [:frontend, :product_intelligence]
'spec/frontend/tracking_spec.js' | [:frontend, :product_intelligence]
'lib/gitlab/usage_database/foo.rb' | [:backend]
end
with_them do
......@@ -181,12 +196,12 @@ RSpec.describe Tooling::Danger::ProjectHelper do
context 'having specific changes' do
where(:expected_categories, :patch, :changed_files) do
[:database, :backend] | '+ count(User.active)' | ['usage_data.rb', 'lib/gitlab/usage_data.rb', 'ee/lib/ee/gitlab/usage_data.rb']
[:database, :backend] | '+ estimate_batch_distinct_count(User.active)' | ['usage_data.rb']
[:backend] | '+ alt_usage_data(User.active)' | ['usage_data.rb']
[:backend] | '+ count(User.active)' | ['user.rb']
[:backend] | '+ count(User.active)' | ['usage_data/topology.rb']
[:backend] | '+ foo_count(User.active)' | ['usage_data.rb']
[:database, :backend, :product_intelligence] | '+ count(User.active)' | ['usage_data.rb', 'lib/gitlab/usage_data.rb', 'ee/lib/ee/gitlab/usage_data.rb']
[:database, :backend, :product_intelligence] | '+ estimate_batch_distinct_count(User.active)' | ['usage_data.rb']
[:backend, :product_intelligence] | '+ alt_usage_data(User.active)' | ['lib/gitlab/usage_data.rb']
[:backend, :product_intelligence] | '+ count(User.active)' | ['lib/gitlab/usage_data/topology.rb']
[:backend, :product_intelligence] | '+ foo_count(User.active)' | ['lib/gitlab/usage_data.rb']
[:backend] | '+ count(User.active)' | ['user.rb']
end
with_them do
......
......@@ -34,16 +34,21 @@ module Tooling
# First-match win, so be sure to put more specific regex at the top...
CATEGORIES = {
[%r{usage_data\.rb}, %r{^(\+|-).*\s+(count|distinct_count|estimate_batch_distinct_count)\(.*\)(.*)$}] => [:database, :backend],
[%r{usage_data\.rb}, %r{^(\+|-).*\s+(count|distinct_count|estimate_batch_distinct_count)\(.*\)(.*)$}] => [:database, :backend, :product_intelligence],
%r{\A(ee/)?config/feature_flags/} => :feature_flag,
%r{\A(ee/)?(changelogs/unreleased)(-ee)?/} => :changelog,
%r{\Adoc/development/usage_ping/dictionary\.md\z} => [:docs, :product_intelligence],
%r{\Adoc/.*(\.(md|png|gif|jpg))\z} => :docs,
%r{\A(CONTRIBUTING|LICENSE|MAINTENANCE|PHILOSOPHY|PROCESS|README)(\.md)?\z} => :docs,
%r{\Adata/whats_new/} => :docs,
%r{\A(
app/assets/javascripts/tracking\.js |
spec/frontend/tracking_spec\.js
)\z}x => [:frontend, :product_intelligence],
%r{\A(ee/)?app/(assets|views)/} => :frontend,
%r{\A(ee/)?public/} => :frontend,
%r{\A(ee/)?spec/(javascripts|frontend)/} => :frontend,
......@@ -95,6 +100,17 @@ module Tooling
%r{\A(ee/)?spec/support/shared_contexts/features/} => :test,
%r{\A(ee/)?spec/support/helpers/features/} => :test,
%r{\A(ee/)?lib/gitlab/usage_data_counters/.*\.yml\z} => [:product_intelligence],
%r{\A(ee/)?config/metrics/((.*\.yml)|(schema\.json))\z} => [:product_intelligence],
%r{\A(ee/)?lib/gitlab/usage_data(_counters)?(/|\.rb)} => [:backend, :product_intelligence],
%r{\A(
lib/gitlab/tracking\.rb |
spec/lib/gitlab/tracking_spec\.rb |
app/helpers/tracking_helper\.rb |
spec/helpers/tracking_helper_spec\.rb |
lib/generators/rails/usage_metric_definition_generator\.rb |
spec/lib/generators/usage_metric_definition_generator_spec\.rb |
generator_templates/usage_metric_definition/metric_definition\.yml)\z}x => [:backend, :product_intelligence],
%r{\A(ee/)?app/(?!assets|views)[^/]+} => :backend,
%r{\A(ee/)?(bin|config|generator_templates|lib|rubocop)/} => :backend,
%r{\A(ee/)?spec/} => :backend,
......
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