Class: Audition::Report::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/audition/report/github.rb

Overview

GitHub Actions renderer: workflow-command annotations that land on the PR diff, plus a markdown table for the job summary page ($GITHUB_STEP_SUMMARY).

Constant Summary collapse

LEVELS =
{
  error: "error", warning: "warning", info: "notice"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ Github

Returns a new instance of Github.



13
14
15
# File 'lib/audition/report/github.rb', line 13

def initialize(report)
  @report = report
end

Instance Method Details

#render ⇒ String

Returns one ::error/::warning/::notice line per finding plus a verdict line.

Returns:

  • (String) —

    one ::error/::warning/::notice line per finding plus a verdict line



19
20
21
22
23
24
# File 'lib/audition/report/github.rb', line 19

def render
  lines = @report.findings.map { |f| annotation(f) }
  lines <<
    "Audition verdict: #{VERDICTS.fetch(@report.verdict)}"
  lines.join("\n")
end

#summary ⇒ String

Returns verdict heading plus a counts table.

Returns:

  • (String) —

    verdict heading plus a counts table



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/audition/report/github.rb', line 27

def summary
  c = @report.counts
  <<~MARKDOWN
    ## Audition: #{VERDICTS.fetch(@report.verdict)}

    | findings | count |
    | --- | --- |
    | errors | #{c[:error]} |
    | dependency errors | #{c[:dep_error]} |
    | warnings | #{c[:warning]} |
    | info | #{c[:info]} |
    | test findings | #{c[:test_error] + c[:test_warning] + c[:test_info]} |
    | fixable | #{c[:fixable]} |
  MARKDOWN
end