From 0c47fceef9b7affd83229683d95c13a4483609fa Mon Sep 17 00:00:00 2001 From: Reuben Pereira Date: Thu, 13 Jan 2022 22:59:52 +0530 Subject: [PATCH] Add Slack icons to the diff components message --- lib/release_tools/project/base_project.rb | 2 ++ lib/release_tools/project/gitaly.rb | 4 ++++ lib/release_tools/project/gitlab_ee.rb | 4 ++++ lib/release_tools/project/omnibus_gitlab.rb | 4 ++++ .../slack/coordinated_pipeline_diffs_notification.rb | 8 ++++++-- .../slack/coordinated_pipeline_diffs_notification_spec.rb | 6 +++--- 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/release_tools/project/base_project.rb b/lib/release_tools/project/base_project.rb index 0d04ddb3d..2942be770 100644 --- a/lib/release_tools/project/base_project.rb +++ b/lib/release_tools/project/base_project.rb @@ -108,6 +108,8 @@ module ReleaseTools end private_class_method :extract_path_from_remote + + def self.slack_emoji; end end end end diff --git a/lib/release_tools/project/gitaly.rb b/lib/release_tools/project/gitaly.rb index 91fe2d70d..f34f478f8 100644 --- a/lib/release_tools/project/gitaly.rb +++ b/lib/release_tools/project/gitaly.rb @@ -12,6 +12,10 @@ module ReleaseTools def self.version_file 'GITALY_SERVER_VERSION' end + + def self.slack_emoji + ':gitaly:' + end end end end diff --git a/lib/release_tools/project/gitlab_ee.rb b/lib/release_tools/project/gitlab_ee.rb index 19b768faa..4b247cea5 100644 --- a/lib/release_tools/project/gitlab_ee.rb +++ b/lib/release_tools/project/gitlab_ee.rb @@ -46,6 +46,10 @@ module ReleaseTools def self.metadata_project_name 'gitlab-ee' end + + def self.slack_emoji + ':gitlab:' + end end end end diff --git a/lib/release_tools/project/omnibus_gitlab.rb b/lib/release_tools/project/omnibus_gitlab.rb index 7dda0fe64..96881d14f 100644 --- a/lib/release_tools/project/omnibus_gitlab.rb +++ b/lib/release_tools/project/omnibus_gitlab.rb @@ -12,6 +12,10 @@ module ReleaseTools def self.metadata_project_name 'omnibus-gitlab-ee' end + + def self.slack_emoji + ':omnibus:' + end end end end diff --git a/lib/release_tools/slack/coordinated_pipeline_diffs_notification.rb b/lib/release_tools/slack/coordinated_pipeline_diffs_notification.rb index 99b319159..1519d586a 100644 --- a/lib/release_tools/slack/coordinated_pipeline_diffs_notification.rb +++ b/lib/release_tools/slack/coordinated_pipeline_diffs_notification.rb @@ -86,15 +86,19 @@ module ReleaseTools end def diff_text(project_compare, source_sha, target_sha, project) + text = +"#{project.slack_emoji} #{project.project_name} - " + if target_sha == source_sha commit_link = "" - "#{project.project_name} - No diff - #{commit_link} (Last running commit)" + text << "No diff - #{commit_link} (Last running commit)" else compare_link = "<#{project_compare.web_url}|#{target_sha[0..10]}...#{source_sha[0..10]}>" - "#{project.project_name} - #{compare_link}" + text << compare_link.to_s end + + text.freeze end def context_block(blocks) diff --git a/spec/lib/release_tools/slack/coordinated_pipeline_diffs_notification_spec.rb b/spec/lib/release_tools/slack/coordinated_pipeline_diffs_notification_spec.rb index 2bd7ececb..73714f54f 100644 --- a/spec/lib/release_tools/slack/coordinated_pipeline_diffs_notification_spec.rb +++ b/spec/lib/release_tools/slack/coordinated_pipeline_diffs_notification_spec.rb @@ -73,9 +73,9 @@ describe ReleaseTools::Slack::CoordinatedPipelineDiffsNotification do block_content = [ slack_header_block(text: header_text), - slack_section_block(text: "gitlab - "), - slack_section_block(text: "omnibus-gitlab - "), - slack_section_block(text: "gitaly - No diff - <#{gitaly_commit_url}|#{trucated_gitaly_sha}> (Last running commit)"), + slack_section_block(text: ":gitlab: gitlab - "), + slack_section_block(text: ":omnibus: omnibus-gitlab - "), + slack_section_block(text: ":gitaly: gitaly - No diff - <#{gitaly_commit_url}|#{trucated_gitaly_sha}> (Last running commit)"), slack_divider_block, slack_context_block(elements: [{ type: 'mrkdwn', text: context_text }]) ] -- GitLab