hier #1
@ -6,7 +6,7 @@ branding:
|
|||||||
color: "green"
|
color: "green"
|
||||||
inputs:
|
inputs:
|
||||||
type:
|
type:
|
||||||
description: "lcov | simplecov"
|
description: "lcov | simplecov | phpunit"
|
||||||
required: true
|
required: true
|
||||||
default: "lcov"
|
default: "lcov"
|
||||||
token:
|
token:
|
||||||
|
|||||||
@ -7,6 +7,8 @@ class CoverageReport
|
|||||||
simplecov(report_path, data)
|
simplecov(report_path, data)
|
||||||
elsif type == 'lcov'
|
elsif type == 'lcov'
|
||||||
lcov(report_path, data)
|
lcov(report_path, data)
|
||||||
|
elsif type == 'phpunit'
|
||||||
|
phpunit(report_path, data)
|
||||||
else
|
else
|
||||||
raise 'InvalidCoverageReportType'
|
raise 'InvalidCoverageReportType'
|
||||||
end
|
end
|
||||||
@ -25,6 +27,12 @@ class CoverageReport
|
|||||||
{ 'lines' => { 'covered_percent' => lcov_covered_percent(lcov_result), 'minumum_percent' => minumum_percent } }
|
{ 'lines' => { 'covered_percent' => lcov_covered_percent(lcov_result), 'minumum_percent' => minumum_percent } }
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def lcov_covered_percent(lcov_result)
|
def lcov_covered_percent(lcov_result)
|
||||||
@ -39,6 +47,22 @@ class CoverageReport
|
|||||||
JSON.parse(`node #{bin_path}/lcov-parse.js #{report_path}`)
|
JSON.parse(`node #{bin_path}/lcov-parse.js #{report_path}`)
|
||||||
end
|
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)
|
def read_json(path)
|
||||||
JSON.parse(File.read(path))
|
JSON.parse(File.read(path))
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user