From b8506db951460f68be5b736c0099e57ad7bb920e Mon Sep 17 00:00:00 2001 From: Abimael Martell Date: Sun, 4 Oct 2020 10:10:13 -0700 Subject: [PATCH] Add percentage on result title (#4) * Add percentage to action name * Test with percentage in output title --- lib/github_check_run_service.rb | 3 ++- lib/report_adapter.rb | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/github_check_run_service.rb b/lib/github_check_run_service.rb index 509e81f..6d8feca 100644 --- a/lib/github_check_run_service.rb +++ b/lib/github_check_run_service.rb @@ -18,6 +18,7 @@ class GithubCheckRunService @summary = @report_adapter.summary(@report) @annotations = @report_adapter.annotations(@report) @conclusion = @report_adapter.conslusion(@report) + @percent = @report_adapter.lines_covered_percent(@report) @client.patch( "#{endpoint_url}/#{id}", @@ -48,7 +49,7 @@ class GithubCheckRunService completed_at: Time.now.iso8601, conclusion: @conclusion, output: { - title: CHECK_NAME, + title: "#{CHECK_NAME} #{@percent}%", summary: @summary, annotations: @annotations } diff --git a/lib/report_adapter.rb b/lib/report_adapter.rb index ded4ac0..c82843d 100644 --- a/lib/report_adapter.rb +++ b/lib/report_adapter.rb @@ -18,16 +18,16 @@ class ReportAdapter [] end + def lines_covered_percent(report) + @lines_covered_percent ||= report.dig('lines', 'covered_percent') + 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