36 lines
1.0 KiB
Ruby
36 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# https://developer.github.com/v3/checks/runs/#output-object
|
|
class ReportAdapter
|
|
class << self
|
|
CONCLUSION_TYPES = { failure: 'failure', success: 'success' }.freeze
|
|
ANNOTATION_LEVEL = { notice: 'notice', warning: 'warning', failure: 'failure' }.freeze
|
|
|
|
def conslusion(report)
|
|
lines_covered_percent(report) >= lines_minimum_percent(report).to_f ? CONCLUSION_TYPES[:success] : CONCLUSION_TYPES[:failure]
|
|
end
|
|
|
|
def summary(report)
|
|
"**Coverage**:\n\n#{table_head}\n| Lines | #{lines_covered_percent(report)}% | #{lines_minimum_percent(report)}% |\n"
|
|
end
|
|
|
|
def annotations(_report)
|
|
[]
|
|
end
|
|
|
|
private
|
|
|
|
def table_head
|
|
"| Type | covered | minimum |\n| ----- | ------- | ------- |"
|
|
end
|
|
|
|
def lines_covered_percent(report)
|
|
@lines_covered_percent ||= report.dig('lines', 'covered_percent')
|
|
end
|
|
|
|
def lines_minimum_percent(report)
|
|
@lines_minimum_percent ||= report.dig('lines', 'minumum_percent')
|
|
end
|
|
end
|
|
end
|