Commit 9ab4328f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch...

Merge branch '247471-mention-telemetry-group-in-danger-bot-when-mr-is-ready-for-for-review' into 'master'

Mention telemetry group in Danger bot when MR is ready for for review

Closes #247471

See merge request gitlab-org/gitlab!42679
parents f29726c5 66382653
......@@ -2,7 +2,7 @@
TELEMETRY_CHANGED_FILES_MESSAGE = <<~MSG
For the following files, a review from the [Data team and Telemetry team](https://gitlab.com/groups/gitlab-org/growth/telemetry/engineers/-/group_members?with_inherited_permissions=exclude) is recommended
Please check the ~telemetry [guide](https://docs.gitlab.com/ee/development/telemetry/usage_ping.html) and reach out to @gitlab-org/growth/telemetry/engineers group for a review.
Please check the ~telemetry [guide](https://docs.gitlab.com/ee/development/telemetry/usage_ping.html) and reach out to %<telemetry_engineers_group>s group for a review.
%<changed_files>s
......@@ -13,6 +13,8 @@ UPDATE_METRICS_DEFINITIONS_MESSAGE = <<~MSG
MSG
TELEMETRY_ENGINEERS_GROUP = '@gitlab-org/growth/telemetry/engineers'
tracking_files = [
'lib/gitlab/tracking.rb',
'spec/lib/gitlab/tracking_spec.rb',
......@@ -28,7 +30,14 @@ snowplow_events_changed_files = git.modified_files & tracking_files
changed_files = (usage_data_changed_files + snowplow_events_changed_files)
if changed_files.any?
warn format(TELEMETRY_CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(changed_files))
mention = if helper.draft_mr?
"`#{TELEMETRY_ENGINEERS_GROUP}`"
else
TELEMETRY_ENGINEERS_GROUP
end
warn format(TELEMETRY_CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(changed_files), telemetry_engineers_group: mention)
warn format(UPDATE_METRICS_DEFINITIONS_MESSAGE) unless helper.changed_files(/usage_ping\.md/).any?
telemetry_labels = ['telemetry']
......
......@@ -214,6 +214,12 @@ module Gitlab
title.gsub(DRAFT_REGEX, '').gsub(/`/, '\\\`')
end
def draft_mr?
return false unless gitlab_helper
DRAFT_REGEX.match?(gitlab_helper.mr_json['title'])
end
def security_mr?
return false unless gitlab_helper
......
......@@ -435,6 +435,28 @@ RSpec.describe Gitlab::Danger::Helper do
end
end
describe '#draft_mr?' do
it 'returns false when `gitlab_helper` is unavailable' do
expect(helper).to receive(:gitlab_helper).and_return(nil)
expect(helper).not_to be_draft_mr
end
it 'returns true for a draft MR' do
expect(fake_gitlab).to receive(:mr_json)
.and_return('title' => 'Draft: My MR title')
expect(helper).to be_draft_mr
end
it 'returns false for non draft MR' do
expect(fake_gitlab).to receive(:mr_json)
.and_return('title' => 'My MR title')
expect(helper).not_to be_draft_mr
end
end
describe '#cherry_pick_mr?' do
it 'returns false when `gitlab_helper` is unavailable' do
expect(helper).to receive(:gitlab_helper).and_return(nil)
......
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