hier #1

Open
einhornimmond wants to merge 3 commits from einhornimmond/master into master
2 changed files with 25 additions and 1 deletions

View File

@ -6,7 +6,7 @@ branding:
color: "green"
inputs:
type:
description: "lcov | simplecov"
description: "lcov | simplecov | phpunit"
required: true
default: "lcov"
token:

View File

@ -7,6 +7,8 @@ class CoverageReport
simplecov(report_path, data)
elsif type == 'lcov'
lcov(report_path, data)
elsif type == 'phpunit'
phpunit(report_path, data)
else
raise 'InvalidCoverageReportType'
end
@ -25,6 +27,12 @@ class CoverageReport
{ 'lines' => { 'covered_percent' => lcov_covered_percent(lcov_result), 'minumum_percent' => minumum_percent } }
end
def phpunit(report_path, data)
phpunit_result = execute_phpunit_parse(report_path)
minumum_percent = data[:min]
{ 'lines' => { 'covered_percent' => phpunit_covered_percent(phpunit_result), 'minumum_percent' => minumum_percent} }
end
private
def lcov_covered_percent(lcov_result)
@ -39,6 +47,22 @@ class CoverageReport
JSON.parse(`node #{bin_path}/lcov-parse.js #{report_path}`)
end
def phpunit_covered_percent(phpunit_result)
# example for
# phpunit --coverage-text
# Summary:
# Classes: 10.14% (14/138)
# Methods: 16.67% (107/642)
# Lines: 13.95% (1059/7591)
/Lines: * ([0-9\.]*)%/.match(phpunit_result)[1].to_f
end
def execute_phpunit_parse(report_path)
File.read(report_path)
end
def read_json(path)
JSON.parse(File.read(path))
end