circleci-coverage_reporter 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.config.reek +23 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile +1 -0
- data/Rakefile +13 -1
- data/circle.yml +2 -0
- data/circleci-coverage_reporter.gemspec +1 -0
- data/lib/circleci/coverage_reporter.rb +5 -0
- data/lib/circleci/coverage_reporter/abstract_build_result.rb +24 -0
- data/lib/circleci/coverage_reporter/abstract_current_result.rb +45 -0
- data/lib/circleci/coverage_reporter/abstract_reporter.rb +2 -2
- data/lib/circleci/coverage_reporter/abstract_result.rb +1 -1
- data/lib/circleci/coverage_reporter/client.rb +2 -2
- data/lib/circleci/coverage_reporter/configuration.rb +26 -26
- data/lib/circleci/coverage_reporter/flow/build_result.rb +2 -19
- data/lib/circleci/coverage_reporter/flow/current_result.rb +6 -31
- data/lib/circleci/coverage_reporter/link/current_result.rb +28 -0
- data/lib/circleci/coverage_reporter/link/reporter.rb +35 -0
- data/lib/circleci/coverage_reporter/report.rb +3 -3
- data/lib/circleci/coverage_reporter/rubycritic/build_result.rb +2 -19
- data/lib/circleci/coverage_reporter/rubycritic/current_result.rb +6 -31
- data/lib/circleci/coverage_reporter/runner.rb +6 -6
- data/lib/circleci/coverage_reporter/simplecov/build_result.rb +2 -19
- data/lib/circleci/coverage_reporter/simplecov/current_result.rb +6 -31
- data/lib/circleci/coverage_reporter/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b6110a90fbfd7d2fc4c619c19e3fde834e00f47
|
4
|
+
data.tar.gz: a6a18c2bc9e49123deab1ab7b4fada4716005179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd8c11e4303da250ff42dc38f5fa7ed39d4dda60316c2b71d79c385c7b223d8af8ced3afbde6b1f9f6d16c8f67eb3be868b7c1e125a9ed3ce5504e343dc95245
|
7
|
+
data.tar.gz: 9cd3f642aa61f91e7295769c16bea3af2f8809cfedd5204cf5a671c94055aaa60ff3c1e31a9d1feda998454d7a522de91e30cf7b2767521c4a9856eaf38d6a33
|
data/.config.reek
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
Attribute:
|
3
|
+
enabled: false
|
4
|
+
DuplicateMethodCall:
|
5
|
+
max_calls: 2
|
6
|
+
FeatureEnvy:
|
7
|
+
enabled: false
|
8
|
+
IrresponsibleModule:
|
9
|
+
enabled: false
|
10
|
+
RepeatedConditional:
|
11
|
+
exclude:
|
12
|
+
- "CircleCI::CoverageReporter::Client"
|
13
|
+
TooManyStatements:
|
14
|
+
exclude:
|
15
|
+
- "CircleCI::CoverageReporter::Sandbox#self.sandboxed"
|
16
|
+
UnusedParameters:
|
17
|
+
exclude:
|
18
|
+
- !ruby/regexp /Abstract/
|
19
|
+
- "CircleCI::CoverageReporter::ReportsRenderer#render"
|
20
|
+
UtilityFunction:
|
21
|
+
enabled: false
|
22
|
+
|
23
|
+
# vim:set ft=yaml:
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.5.0] - 2017-05-18
|
10
|
+
### Added
|
11
|
+
- Add Link reporter
|
12
|
+
|
9
13
|
## [0.4.0] - 2017-03-18
|
10
14
|
### Added
|
11
15
|
- Support [RubyCritic](https://github.com/whitesmith/rubycritic) score
|
@@ -56,7 +60,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
56
60
|
### Added
|
57
61
|
- Initial release
|
58
62
|
|
59
|
-
[Unreleased]: https://github.com/increments/circleci-coverage_reporter/compare/v0.
|
63
|
+
[Unreleased]: https://github.com/increments/circleci-coverage_reporter/compare/v0.5.0...HEAD
|
64
|
+
[0.5.0]: https://github.com/increments/circleci-coverage_reporter/compare/v0.4.0...v0.5.0
|
60
65
|
[0.4.0]: https://github.com/increments/circleci-coverage_reporter/compare/v0.3.1...v0.4.0
|
61
66
|
[0.3.1]: https://github.com/increments/circleci-coverage_reporter/compare/v0.3.0...v0.3.1
|
62
67
|
[0.3.0]: https://github.com/increments/circleci-coverage_reporter/compare/v0.2.0...v0.3.0
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -3,6 +3,7 @@ require 'rspec/core/rake_task'
|
|
3
3
|
require 'rubocop/rake_task'
|
4
4
|
require 'yard'
|
5
5
|
require 'circleci/coverage_reporter/rake_task'
|
6
|
+
require 'rubycritic/rake_task'
|
6
7
|
|
7
8
|
RSpec::Core::RakeTask.new do |task|
|
8
9
|
task.verbose = false
|
@@ -12,4 +13,15 @@ RuboCop::RakeTask.new
|
|
12
13
|
|
13
14
|
YARD::Rake::YardocTask.new
|
14
15
|
|
15
|
-
|
16
|
+
CircleCI::CoverageReporter.configure do |config|
|
17
|
+
config.reporters << CircleCI::CoverageReporter::Link::Reporter.new('doc', 'index.html', name: 'YARD')
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Run RubyCritic'
|
21
|
+
task :rubycritic do
|
22
|
+
base_options = "-p #{ENV['CIRCLE_ARTIFACTS'] || '.'}/rubycritic --mode-ci --no-browser"
|
23
|
+
sh "bundle exec rubycritic #{base_options} -f html lib"
|
24
|
+
sh "bundle exec rubycritic #{base_options} -f json lib" if ENV['CIRCLECI']
|
25
|
+
end
|
26
|
+
|
27
|
+
task default: %i[spec rubocop]
|
data/circle.yml
CHANGED
@@ -6,4 +6,6 @@ test:
|
|
6
6
|
- bundle exec rspec --format progress --require rspec_junit_formatter --format RspecJunitFormatter -o $CIRCLE_TEST_REPORTS/rspec/junit.xml
|
7
7
|
- bundle exec rubocop
|
8
8
|
post:
|
9
|
+
- bundle exec rake rubycritic
|
10
|
+
- bundle exec yard doc -o $CIRCLE_ARTIFACTS/doc
|
9
11
|
- bundle exec rake circleci:report_coverage
|
@@ -3,6 +3,11 @@ require_relative 'coverage_reporter/configuration'
|
|
3
3
|
require_relative 'coverage_reporter/errors'
|
4
4
|
require_relative 'coverage_reporter/runner'
|
5
5
|
|
6
|
+
require_relative 'coverage_reporter/flow/reporter'
|
7
|
+
require_relative 'coverage_reporter/link/reporter'
|
8
|
+
require_relative 'coverage_reporter/rubycritic/reporter'
|
9
|
+
require_relative 'coverage_reporter/simplecov/reporter'
|
10
|
+
|
6
11
|
module CircleCI
|
7
12
|
module CoverageReporter
|
8
13
|
class << self
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'abstract_result'
|
2
|
+
|
3
|
+
module CircleCI
|
4
|
+
module CoverageReporter
|
5
|
+
class AbstractBuildResult < AbstractResult
|
6
|
+
# @param path [String]
|
7
|
+
# @param build [Build]
|
8
|
+
def initialize(path, build)
|
9
|
+
@path = path
|
10
|
+
@build = build
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :build, :path
|
16
|
+
|
17
|
+
# @param end_with [String]
|
18
|
+
# @return [Artifact]
|
19
|
+
def find_artifact(end_with)
|
20
|
+
build.artifacts.find { |artifact| artifact.end_with?("#{path}/#{end_with}") }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative 'abstract_result'
|
2
|
+
|
3
|
+
module CircleCI
|
4
|
+
module CoverageReporter
|
5
|
+
class AbstractCurrentResult < AbstractResult
|
6
|
+
# @param path [String] path to coverage directory
|
7
|
+
def initialize(path)
|
8
|
+
@path = path
|
9
|
+
end
|
10
|
+
|
11
|
+
# @note Implement {AbstractResult#url}
|
12
|
+
# @return [String]
|
13
|
+
def url
|
14
|
+
[
|
15
|
+
'https://circle-artifacts.com/gh',
|
16
|
+
configuration.project,
|
17
|
+
configuration.current_build_number,
|
18
|
+
'artifacts',
|
19
|
+
"0#{configuration.artifacts_dir}",
|
20
|
+
path,
|
21
|
+
html_file_name
|
22
|
+
].compact.join('/')
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :path
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
def html_file_name
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return
|
35
|
+
def join(name)
|
36
|
+
File.join(configuration.artifacts_dir, path, name)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Configuration]
|
40
|
+
def configuration
|
41
|
+
CoverageReporter.configuration
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -5,14 +5,14 @@ module CircleCI
|
|
5
5
|
# @abstract Subclass and override {#name}, {#create_build_result} and {#create_current_result}
|
6
6
|
# to implement a custom Reporter class.
|
7
7
|
class AbstractReporter
|
8
|
-
# @param path [String] relative path from artifacts dir to coverage directory
|
8
|
+
# @param path [String, nil] relative path from artifacts dir to coverage directory
|
9
9
|
def initialize(path = self.class::DEFAULT_PATH)
|
10
10
|
@path = path
|
11
11
|
end
|
12
12
|
|
13
13
|
# @return [Boolean] whether it is active
|
14
14
|
def active?
|
15
|
-
File.directory?(File.join(configuration.artifacts_dir, path))
|
15
|
+
File.directory?(File.join(configuration.artifacts_dir, path || ''))
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param base_build [Build, nil]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module CircleCI
|
2
2
|
module CoverageReporter
|
3
|
-
# @abstract Subclass and override {#coverage} to implement a custom Result class.
|
3
|
+
# @abstract Subclass and override {#coverage} and {#url} to implement a custom Result class.
|
4
4
|
class AbstractResult
|
5
5
|
# @return [Float]
|
6
6
|
def coverage
|
@@ -34,7 +34,7 @@ module CircleCI
|
|
34
34
|
# @param branch [String, nil]
|
35
35
|
# @return [Integer, nil]
|
36
36
|
def build_number_by_revision(revision, branch: nil)
|
37
|
-
build = recent_builds(branch).find { |
|
37
|
+
build = recent_builds(branch).find { |recent_build| recent_build.match?(revision) }
|
38
38
|
build ? build.build_number : nil
|
39
39
|
end
|
40
40
|
|
@@ -43,7 +43,7 @@ module CircleCI
|
|
43
43
|
# @return [Faraday::Response]
|
44
44
|
def get(url, params = {})
|
45
45
|
params['circle-token'] = configuration.circleci_token
|
46
|
-
Faraday.get(url + '?' + params.map { |
|
46
|
+
Faraday.get(url + '?' + params.map { |key, value| "#{key}=#{value}" }.join('&'))
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
@@ -10,18 +10,18 @@ module CircleCI
|
|
10
10
|
Flow::Reporter.new,
|
11
11
|
RubyCritic::Reporter.new
|
12
12
|
].freeze
|
13
|
-
DEFAULT_TEMPLATE =
|
14
|
-
<%- reports.each do |report| -%>
|
15
|
-
<%
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
-%>
|
23
|
-
<%= link %>: <%= report.current_result.pretty_coverage %><%= emoji %><%= progress %>
|
24
|
-
<%- end -%>
|
13
|
+
DEFAULT_TEMPLATE = <<~'ERB'.freeze
|
14
|
+
<%- reports.each do |report| -%>
|
15
|
+
<%
|
16
|
+
link = "[#{report.reporter.name}](#{report.current_result.url})"
|
17
|
+
emoji = report.base_diff.nil? || report.base_diff.nan? || report.base_diff.round(2).zero? ? nil : report.base_diff.positive? ? ' :chart_with_upwards_trend:' : ' :chart_with_downwards_trend:'
|
18
|
+
base_progress = report.base_diff ? "[master](#{report.base_result.url}): #{report.pretty_base_diff}" : nil
|
19
|
+
branch_progress = report.branch_diff ? "[previous](#{report.previous_result.url}): #{report.pretty_branch_diff}" : nil
|
20
|
+
progresses = [base_progress, branch_progress].compact
|
21
|
+
progress = progresses.empty? ? nil : " (#{progresses.join(', ')})"
|
22
|
+
-%>
|
23
|
+
<%= link %>: <%= report.current_result.pretty_coverage %><%= emoji %><%= progress %>
|
24
|
+
<%- end -%>
|
25
25
|
ERB
|
26
26
|
DEFAULT_TEMPLATE_TRIM_MODE = '-'.freeze
|
27
27
|
DEFAULT_VCS_TYPE = 'github'.freeze
|
@@ -92,20 +92,20 @@ module CircleCI
|
|
92
92
|
|
93
93
|
# @return [void]
|
94
94
|
def dump # rubocop:disable AbcSize
|
95
|
-
puts
|
96
|
-
Configuration | Value
|
97
|
-
----------------------|----------------------------------------------------------------------------
|
98
|
-
artifacts_dir | #{artifacts_dir.inspect}
|
99
|
-
base_revision | #{base_revision.inspect}
|
100
|
-
circleci_token | #{circleci_token[-4..-1].rjust(40, '*').inspect}
|
101
|
-
current_build_number | #{current_build_number.inspect}
|
102
|
-
current_revision | #{current_revision.inspect}
|
103
|
-
previous_build_number | #{previous_build_number.inspect}
|
104
|
-
reporters | #{reporters.inspect}
|
105
|
-
repository_name | #{repository_name.inspect}
|
106
|
-
user_name | #{user_name.inspect}
|
107
|
-
vcs_token | #{vcs_token[-4..-1].rjust(40, '*').inspect}
|
108
|
-
vcs_type | #{vcs_type.inspect}
|
95
|
+
puts <<~EOF
|
96
|
+
Configuration | Value
|
97
|
+
----------------------|----------------------------------------------------------------------------
|
98
|
+
artifacts_dir | #{artifacts_dir.inspect}
|
99
|
+
base_revision | #{base_revision.inspect}
|
100
|
+
circleci_token | #{circleci_token[-4..-1].rjust(40, '*').inspect}
|
101
|
+
current_build_number | #{current_build_number.inspect}
|
102
|
+
current_revision | #{current_revision.inspect}
|
103
|
+
previous_build_number | #{previous_build_number.inspect}
|
104
|
+
reporters | #{reporters.inspect}
|
105
|
+
repository_name | #{repository_name.inspect}
|
106
|
+
user_name | #{user_name.inspect}
|
107
|
+
vcs_token | #{vcs_token[-4..-1].rjust(40, '*').inspect}
|
108
|
+
vcs_type | #{vcs_type.inspect}
|
109
109
|
EOF
|
110
110
|
end
|
111
111
|
end
|
@@ -1,16 +1,9 @@
|
|
1
|
-
require_relative '../
|
1
|
+
require_relative '../abstract_build_result'
|
2
2
|
|
3
3
|
module CircleCI
|
4
4
|
module CoverageReporter
|
5
5
|
module Flow
|
6
|
-
class BuildResult <
|
7
|
-
# @param path [String]
|
8
|
-
# @param build [Build]
|
9
|
-
def initialize(path, build)
|
10
|
-
@path = path
|
11
|
-
@build = build
|
12
|
-
end
|
13
|
-
|
6
|
+
class BuildResult < AbstractBuildResult
|
14
7
|
# @note Implement {AbstractResult#coverage}
|
15
8
|
# @return [Float]
|
16
9
|
def coverage
|
@@ -24,16 +17,6 @@ module CircleCI
|
|
24
17
|
index_html = find_artifact('index.html') or return '#'
|
25
18
|
index_html.url
|
26
19
|
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_reader :build, :path
|
31
|
-
|
32
|
-
# @param end_with [String]
|
33
|
-
# @return [Artifact]
|
34
|
-
def find_artifact(end_with)
|
35
|
-
build.artifacts.find { |a| a.end_with?("#{path}/#{end_with}") }
|
36
|
-
end
|
37
20
|
end
|
38
21
|
end
|
39
22
|
end
|
@@ -1,46 +1,21 @@
|
|
1
|
-
require_relative '../
|
1
|
+
require_relative '../abstract_current_result'
|
2
2
|
|
3
3
|
module CircleCI
|
4
4
|
module CoverageReporter
|
5
5
|
module Flow
|
6
|
-
class CurrentResult <
|
7
|
-
# @param path [String] path to coverage directory
|
8
|
-
def initialize(path)
|
9
|
-
@path = path
|
10
|
-
end
|
11
|
-
|
6
|
+
class CurrentResult < AbstractCurrentResult
|
12
7
|
# @note Implement {AbstractResult#coverage}
|
13
8
|
# @return [Float]
|
14
9
|
def coverage
|
15
10
|
JSON.parse(File.read(join('flow-coverage.json')))['percent'].to_f
|
16
11
|
end
|
17
12
|
|
18
|
-
# @note Implement {AbstractResult#url}
|
19
|
-
# @return [String]
|
20
|
-
def url
|
21
|
-
[
|
22
|
-
'https://circle-artifacts.com/gh',
|
23
|
-
configuration.project,
|
24
|
-
configuration.current_build_number,
|
25
|
-
'artifacts',
|
26
|
-
"0#{configuration.artifacts_dir}",
|
27
|
-
path,
|
28
|
-
'index.html'
|
29
|
-
].join('/')
|
30
|
-
end
|
31
|
-
|
32
13
|
private
|
33
14
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
File.join(configuration.artifacts_dir, path, name)
|
39
|
-
end
|
40
|
-
|
41
|
-
# @return [Configuration]
|
42
|
-
def configuration
|
43
|
-
CoverageReporter.configuration
|
15
|
+
# @note Implementation for {AbstractCurrentResult#html_file_name}
|
16
|
+
# @return [String]
|
17
|
+
def html_file_name
|
18
|
+
'index.html'
|
44
19
|
end
|
45
20
|
end
|
46
21
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module CircleCI
|
2
|
+
module CoverageReporter
|
3
|
+
module Link
|
4
|
+
class CurrentResult < AbstractCurrentResult
|
5
|
+
# @note Override
|
6
|
+
def initialize(path, html_file_name)
|
7
|
+
@html_file_name = html_file_name
|
8
|
+
super(path)
|
9
|
+
end
|
10
|
+
|
11
|
+
# @note Implement {AbstractResult#coverage}
|
12
|
+
# @return [Float]
|
13
|
+
def coverage
|
14
|
+
Float::NAN
|
15
|
+
end
|
16
|
+
|
17
|
+
# @note Override {AbstractResult#pretty_coverage}
|
18
|
+
def pretty_coverage
|
19
|
+
''
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :html_file_name
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'current_result'
|
2
|
+
|
3
|
+
module CircleCI
|
4
|
+
module CoverageReporter
|
5
|
+
module Link
|
6
|
+
class Reporter < AbstractReporter
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
# @param path [String, nil] relative path from artifacts dir to coverage directory
|
10
|
+
# @param file_name [String] file name
|
11
|
+
# @param name [String] reporter name
|
12
|
+
def initialize(path, file_name, name: nil)
|
13
|
+
@path = path
|
14
|
+
@file_name = file_name
|
15
|
+
@name = name || file_name
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @note Implement {AbstractReporter#create_build_result}
|
21
|
+
# @param _build [Build, nil]
|
22
|
+
# @return [nil]
|
23
|
+
def create_build_result(_build)
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
# @note Implement {AbstractReporter#create_current_result}
|
28
|
+
# @return [CurrentResult]
|
29
|
+
def create_current_result
|
30
|
+
CurrentResult.new(path, @file_name)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -14,9 +14,9 @@ module CircleCI
|
|
14
14
|
attr_reader :previous_result
|
15
15
|
|
16
16
|
# @param reporter [AbstractReporter]
|
17
|
-
# @param current [
|
18
|
-
# @param base [
|
19
|
-
# @param previous [
|
17
|
+
# @param current [AbstractCurrentResult]
|
18
|
+
# @param base [AbstractBuildResult, nil]
|
19
|
+
# @param previous [AbstractBuildResult, nil]
|
20
20
|
def initialize(reporter, current, base: nil, previous: nil)
|
21
21
|
@reporter = reporter
|
22
22
|
@current_result = current
|
@@ -1,16 +1,9 @@
|
|
1
|
-
require_relative '../
|
1
|
+
require_relative '../abstract_build_result'
|
2
2
|
|
3
3
|
module CircleCI
|
4
4
|
module CoverageReporter
|
5
5
|
module RubyCritic
|
6
|
-
class BuildResult <
|
7
|
-
# @param path [String]
|
8
|
-
# @param build [Build]
|
9
|
-
def initialize(path, build)
|
10
|
-
@path = path
|
11
|
-
@build = build
|
12
|
-
end
|
13
|
-
|
6
|
+
class BuildResult < AbstractBuildResult
|
14
7
|
# @note Implement {AbstractResult#coverage}
|
15
8
|
# @return [Float]
|
16
9
|
def coverage
|
@@ -24,16 +17,6 @@ module CircleCI
|
|
24
17
|
index_html = find_artifact('overview.html') or return '#'
|
25
18
|
index_html.url
|
26
19
|
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_reader :build, :path
|
31
|
-
|
32
|
-
# @param end_with [String]
|
33
|
-
# @return [Artifact]
|
34
|
-
def find_artifact(end_with)
|
35
|
-
build.artifacts.find { |a| a.end_with?("#{path}/#{end_with}") }
|
36
|
-
end
|
37
20
|
end
|
38
21
|
end
|
39
22
|
end
|
@@ -1,34 +1,15 @@
|
|
1
|
-
require_relative '../
|
1
|
+
require_relative '../abstract_current_result'
|
2
2
|
|
3
3
|
module CircleCI
|
4
4
|
module CoverageReporter
|
5
5
|
module RubyCritic
|
6
|
-
class CurrentResult <
|
7
|
-
# @param path [String] path to coverage directory
|
8
|
-
def initialize(path)
|
9
|
-
@path = path
|
10
|
-
end
|
11
|
-
|
6
|
+
class CurrentResult < AbstractCurrentResult
|
12
7
|
# @note Implement {AbstractResult#coverage}
|
13
8
|
# @return [Float]
|
14
9
|
def coverage
|
15
10
|
JSON.parse(File.read(join('report.json')))['score'].to_f
|
16
11
|
end
|
17
12
|
|
18
|
-
# @note Implement {AbstractResult#url}
|
19
|
-
# @return [String]
|
20
|
-
def url
|
21
|
-
[
|
22
|
-
'https://circle-artifacts.com/gh',
|
23
|
-
configuration.project,
|
24
|
-
configuration.current_build_number,
|
25
|
-
'artifacts',
|
26
|
-
"0#{configuration.artifacts_dir}",
|
27
|
-
path,
|
28
|
-
'overview.html'
|
29
|
-
].join('/')
|
30
|
-
end
|
31
|
-
|
32
13
|
# @note Override {AbstractResult#pretty_coverage}
|
33
14
|
# @return [String]
|
34
15
|
def pretty_coverage
|
@@ -37,16 +18,10 @@ module CircleCI
|
|
37
18
|
|
38
19
|
private
|
39
20
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
File.join(configuration.artifacts_dir, path, name)
|
45
|
-
end
|
46
|
-
|
47
|
-
# @return [Configuration]
|
48
|
-
def configuration
|
49
|
-
CoverageReporter.configuration
|
21
|
+
# @note Implementation for {AbstractCurrentResult#html_file_name}
|
22
|
+
# @return [String]
|
23
|
+
def html_file_name
|
24
|
+
'overview.html'
|
50
25
|
end
|
51
26
|
end
|
52
27
|
end
|
@@ -12,12 +12,12 @@ module CircleCI
|
|
12
12
|
|
13
13
|
# @return [void]
|
14
14
|
def dump
|
15
|
-
puts
|
16
|
-
Runner | Value
|
17
|
-
------------------|-----------------------------------------------------------------------------------
|
18
|
-
base_build | #{base_build.inspect}
|
19
|
-
base_build_number | #{base_build_number.inspect}
|
20
|
-
previous_build | #{previous_build.inspect}
|
15
|
+
puts <<~EOF
|
16
|
+
Runner | Value
|
17
|
+
------------------|-----------------------------------------------------------------------------------
|
18
|
+
base_build | #{base_build.inspect}
|
19
|
+
base_build_number | #{base_build_number.inspect}
|
20
|
+
previous_build | #{previous_build.inspect}
|
21
21
|
EOF
|
22
22
|
end
|
23
23
|
|
@@ -1,16 +1,9 @@
|
|
1
|
-
require_relative '../
|
1
|
+
require_relative '../abstract_build_result'
|
2
2
|
|
3
3
|
module CircleCI
|
4
4
|
module CoverageReporter
|
5
5
|
module SimpleCov
|
6
|
-
class BuildResult <
|
7
|
-
# @param path [String]
|
8
|
-
# @param build [Build]
|
9
|
-
def initialize(path, build)
|
10
|
-
@path = path
|
11
|
-
@build = build
|
12
|
-
end
|
13
|
-
|
6
|
+
class BuildResult < AbstractBuildResult
|
14
7
|
# @note Implement {AbstractResult#coverage}
|
15
8
|
# @return [Float]
|
16
9
|
def coverage
|
@@ -24,16 +17,6 @@ module CircleCI
|
|
24
17
|
index_html = find_artifact('index.html') or return '#'
|
25
18
|
index_html.url
|
26
19
|
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_reader :build, :path
|
31
|
-
|
32
|
-
# @param end_with [String]
|
33
|
-
# @return [Artifact]
|
34
|
-
def find_artifact(end_with)
|
35
|
-
build.artifacts.find { |a| a.end_with?("#{path}/#{end_with}") }
|
36
|
-
end
|
37
20
|
end
|
38
21
|
end
|
39
22
|
end
|
@@ -1,46 +1,21 @@
|
|
1
|
-
require_relative '../
|
1
|
+
require_relative '../abstract_current_result'
|
2
2
|
|
3
3
|
module CircleCI
|
4
4
|
module CoverageReporter
|
5
5
|
module SimpleCov
|
6
|
-
class CurrentResult <
|
7
|
-
# @param path [String] path to coverage directory
|
8
|
-
def initialize(path)
|
9
|
-
@path = path
|
10
|
-
end
|
11
|
-
|
6
|
+
class CurrentResult < AbstractCurrentResult
|
12
7
|
# @note Implement {AbstractResult#coverage}
|
13
8
|
# @return [Float]
|
14
9
|
def coverage
|
15
10
|
JSON.parse(File.read(join('.last_run.json')))['result']['covered_percent'].to_f
|
16
11
|
end
|
17
12
|
|
18
|
-
# @note Implement {AbstractResult#url}
|
19
|
-
# @return [String]
|
20
|
-
def url
|
21
|
-
[
|
22
|
-
'https://circle-artifacts.com/gh',
|
23
|
-
configuration.project,
|
24
|
-
configuration.current_build_number,
|
25
|
-
'artifacts',
|
26
|
-
"0#{configuration.artifacts_dir}",
|
27
|
-
path,
|
28
|
-
'index.html'
|
29
|
-
].join('/')
|
30
|
-
end
|
31
|
-
|
32
13
|
private
|
33
14
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
File.join(configuration.artifacts_dir, path, name)
|
39
|
-
end
|
40
|
-
|
41
|
-
# @return [Configuration]
|
42
|
-
def configuration
|
43
|
-
CoverageReporter.configuration
|
15
|
+
# @note Implementation for {AbstractCurrentResult#html_file_name}
|
16
|
+
# @return [String]
|
17
|
+
def html_file_name
|
18
|
+
'index.html'
|
44
19
|
end
|
45
20
|
end
|
46
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circleci-coverage_reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuku Takahashi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -45,6 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".config.reek"
|
48
49
|
- ".gitignore"
|
49
50
|
- ".rspec"
|
50
51
|
- ".rubocop.yml"
|
@@ -58,6 +59,8 @@ files:
|
|
58
59
|
- circle.yml
|
59
60
|
- circleci-coverage_reporter.gemspec
|
60
61
|
- lib/circleci/coverage_reporter.rb
|
62
|
+
- lib/circleci/coverage_reporter/abstract_build_result.rb
|
63
|
+
- lib/circleci/coverage_reporter/abstract_current_result.rb
|
61
64
|
- lib/circleci/coverage_reporter/abstract_reporter.rb
|
62
65
|
- lib/circleci/coverage_reporter/abstract_result.rb
|
63
66
|
- lib/circleci/coverage_reporter/abstract_vcs_client.rb
|
@@ -70,6 +73,8 @@ files:
|
|
70
73
|
- lib/circleci/coverage_reporter/flow/current_result.rb
|
71
74
|
- lib/circleci/coverage_reporter/flow/reporter.rb
|
72
75
|
- lib/circleci/coverage_reporter/github_client.rb
|
76
|
+
- lib/circleci/coverage_reporter/link/current_result.rb
|
77
|
+
- lib/circleci/coverage_reporter/link/reporter.rb
|
73
78
|
- lib/circleci/coverage_reporter/rake_task.rb
|
74
79
|
- lib/circleci/coverage_reporter/report.rb
|
75
80
|
- lib/circleci/coverage_reporter/reports_renderer.rb
|
@@ -102,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
107
|
version: '0'
|
103
108
|
requirements: []
|
104
109
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.6.11
|
106
111
|
signing_key:
|
107
112
|
specification_version: 4
|
108
113
|
summary: Report test coverage to your GitHub repository
|