Class: Kennel::GithubReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/kennel/github_reporter.rb

Constant Summary collapse

MAX_COMMENT_SIZE =
65536
TRUNCATED_MSG =

finish the code block so it look nice

"\n```\n... (truncated)"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ GithubReporter

Returns a new instance of GithubReporter.



14
15
16
17
18
19
# File 'lib/kennel/github_reporter.rb', line 14

def initialize(token)
  @token = token
  @git_sha = Utils.capture_sh("git rev-parse HEAD").strip
  origin = ENV["PROJECT_REPOSITORY"] || Utils.capture_sh("git remote -v").split("\n").first
  @repo_part = origin[%r{github\.com[:/](.+?)(\.git|$)}, 1] || raise("no origin found")
end

Class Method Details

.report(token, &block) ⇒ Object



8
9
10
11
# File 'lib/kennel/github_reporter.rb', line 8

def report(token, &block)
  return yield unless token
  new(token).report(&block)
end

Instance Method Details

#report(&block) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/kennel/github_reporter.rb', line 21

def report(&block)
  output = Utils.strip_shell_control(Utils.tee_output(&block).strip)
rescue StandardError
  output = "Error:\n#{$ERROR_INFO.message}"
  raise
ensure
  comment "```\n#{output || "Error"}\n```"
end