From f8e7ca46df97fa93e0745f90fd4389be581e25da Mon Sep 17 00:00:00 2001 From: Jared Szechy Date: Tue, 30 Mar 2021 19:21:44 -0400 Subject: [PATCH] Fix for new simplecov results file --- lib/coverage_report.rb | 2 +- lib/github_check_run_service.rb | 2 +- lib/report_adapter.rb | 2 +- spec/fixtures/simplecov.json | 2 +- spec/report_adapter_spec.rb | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/coverage_report.rb b/lib/coverage_report.rb index 8752daa..a2c702e 100644 --- a/lib/coverage_report.rb +++ b/lib/coverage_report.rb @@ -15,7 +15,7 @@ def generate(type, report_path, data) def simplecov(report_path, data) report = read_json(report_path) minumum_percent = data[:min] - covered_percent = report.dig('result', 'covered_percent') + covered_percent = report.dig('result', 'line') || report.dig('result', 'covered_percent') { 'lines' => { 'covered_percent' => covered_percent, 'minumum_percent' => minumum_percent } } end diff --git a/lib/github_check_run_service.rb b/lib/github_check_run_service.rb index 6d8feca..8cb2355 100644 --- a/lib/github_check_run_service.rb +++ b/lib/github_check_run_service.rb @@ -17,7 +17,7 @@ def run )['id'] @summary = @report_adapter.summary(@report) @annotations = @report_adapter.annotations(@report) - @conclusion = @report_adapter.conslusion(@report) + @conclusion = @report_adapter.conclusion(@report) @percent = @report_adapter.lines_covered_percent(@report) @client.patch( diff --git a/lib/report_adapter.rb b/lib/report_adapter.rb index c82843d..58d51db 100644 --- a/lib/report_adapter.rb +++ b/lib/report_adapter.rb @@ -6,7 +6,7 @@ class << self CONCLUSION_TYPES = { failure: 'failure', success: 'success' }.freeze ANNOTATION_LEVEL = { notice: 'notice', warning: 'warning', failure: 'failure' }.freeze - def conslusion(report) + def conclusion(report) lines_covered_percent(report) >= lines_minimum_percent(report).to_f ? CONCLUSION_TYPES[:success] : CONCLUSION_TYPES[:failure] end diff --git a/spec/fixtures/simplecov.json b/spec/fixtures/simplecov.json index c2e594c..30d5080 100644 --- a/spec/fixtures/simplecov.json +++ b/spec/fixtures/simplecov.json @@ -1,5 +1,5 @@ { "result": { - "covered_percent": 80.5 + "line": 80.5 } } diff --git a/spec/report_adapter_spec.rb b/spec/report_adapter_spec.rb index 137c0e8..6324cd1 100644 --- a/spec/report_adapter_spec.rb +++ b/spec/report_adapter_spec.rb @@ -13,8 +13,8 @@ let(:adapter) { ReportAdapter } - it '.conslusion' do - result = adapter.conslusion(report) + it '.conclusion' do + result = adapter.conclusion(report) expect(result).to eq('success') end