Class: CiToolkit::PrMessengerText

Inherits:
Object
  • Object
show all
Defined in:
lib/ci_toolkit/pr_messenger_text.rb

Overview

Utilities to create markdown text from build messages

Instance Method Summary collapse

Constructor Details

#initialize(build = CiToolkit::Build.new, env = CiToolkit::BitriseEnv.new) ⇒ PrMessengerText

Returns a new instance of PrMessengerText.



6
7
8
9
10
11
12
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 6

def initialize(
  build = CiToolkit::Build.new,
  env = CiToolkit::BitriseEnv.new
)
  @build = build
  @app_url = env.app_url
end

Instance Method Details

#big_pr_warning_titleObject



55
56
57
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 55

def big_pr_warning_title
  warning_with_message("Big PR")
end

#body(text) ⇒ Object



79
80
81
82
83
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 79

def body(text)
  formatted_text = "```\n#{text.to_s[0...60_000]}\n```"
  formatted_text = "<details>\n<summary>Details</summary>\n\n#{formatted_text}\n</details>" if text.lines.count > 6
  "#{formatted_text}\n"
end

#build_failure_titleObject



32
33
34
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 32

def build_failure_title
  "#### Build failed ⛔"
end

#certificate_pinning_logic_modified_android_titleObject



48
49
50
51
52
53
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 48

def certificate_pinning_logic_modified_android_title
  warning_with_message("Detected modifications in Certificate pinning related files " \
                       "(HttpClientFactory / SecurePreferences / CertificatePinningConfiguration / " \
                       "SSLPinner / CertificateDateChecker). If you are doing temporary changes " \
                       "to pinning, do not merge this MR until you revert them!")
end

#create_duplicate_files_report(finder) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 67

def create_duplicate_files_report(finder)
  report = ""
  finder.duplicate_groups.each do |dups|
    report = "#{report}\n#{dups.join("\n")}\n"
  end
  report
end

#duplicated_files_titleObject



36
37
38
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 36

def duplicated_files_title
  warning_with_message("There are duplicated files found")
end


75
76
77
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 75

def footer
  "###### 🔮 _Comment via [CI](#{@app_url}) on build [#{@build.number}](#{@build.url})_"
end

#for_build_failure(reason) ⇒ Object



20
21
22
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 20

def for_build_failure(reason)
  "#{build_failure_title}️\n#{body(reason.to_s)}"
end

#for_duplicated_files_report(report) ⇒ Object



24
25
26
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 24

def for_duplicated_files_report(report)
  "#{duplicated_files_title}\n#{body(report)}"
end

#for_lint_report(report) ⇒ Object



28
29
30
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 28

def for_lint_report(report)
  "#{lint_report_title}\n#{body(report)}"
end

#for_new_build(name, version_name, tag) ⇒ Object



14
15
16
17
18
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 14

def for_new_build(name, version_name, tag)
  "#### New `#{name}` build deployed 🚀\nVersion **#{version_name}** with\
 build number **#{@build.number}** on tag **#{tag}** deployed\
 from [this](#{@build.url}) build"
end

#lint_report_titleObject



40
41
42
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 40

def lint_report_title
  "#### Swiftlint report 🕵️‍♀️"
end

#realm_modified_warning_titleObject



44
45
46
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 44

def realm_modified_warning_title
  warning_with_message("Realm module modified. Did you remember to add migrations?")
end

#warning_with_message(message) ⇒ Object



63
64
65
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 63

def warning_with_message(message)
  "Warning: #{message} ⚠️"
end

#work_in_progress_titleObject



59
60
61
# File 'lib/ci_toolkit/pr_messenger_text.rb', line 59

def work_in_progress_title
  "PR is Work in Progress 🚧"
end