circleci-coverage_reporter 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b4cdc92e39f53cc9d6feca7e80de243b47f373d
4
- data.tar.gz: 0d7a2a515139c2d88821453c9452df4b6b5a6abf
3
+ metadata.gz: f7d215064f144f89d7c7cb0eaf5fc46f6a90c591
4
+ data.tar.gz: dffd6d1a3c59adff8223915cb69c2075c90c33be
5
5
  SHA512:
6
- metadata.gz: 985c37b0a460c358fc0f7d3b4e4af999a04654bdef2b45d024c659d927c3d9da827cf403c38ea1096eb35968913db93b8627581008480490018fafd4a0dc2d61
7
- data.tar.gz: 820d20ebb038e4c2200dd487508cd990a032ee26bcc615d81544b655c25f87c90c58f0d29eb5785fbc332dbd77852ea7c3e1eaa95bd507d6682cc99ef5b98935
6
+ metadata.gz: a98704328e56f06af1e9261770406151aaf7bc87ffa86d3ddc0fd4aa310f9c7b3651e1b1b73767c7252244f7bfbc395fdb762f48d55fcce41580f6b3aed0711f
7
+ data.tar.gz: 238d8434cb7748191201f59da63f20baf77c88bb6b5145c7ad5987b0f40572833eb14d122e164583874e0d4db9507d3e29111b239db9d1a69f25b53c646db722
data/CHANGELOG.md CHANGED
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2017-03-18
10
+ ### Added
11
+ - Support [RubyCritic](https://github.com/whitesmith/rubycritic) score
12
+ - Enable to change score unit
13
+
14
+ ### Changed
15
+ - Round coverage by default
16
+
17
+ ### Fixed
18
+ - Make sure that `#coverage` methods return a `Float` object
19
+
9
20
  ## [0.3.1] - 2017-03-17
10
21
  ### Fixed
11
22
  - Suppress emoji if base diff is NaN or zero
@@ -22,7 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
22
33
 
23
34
  ## [0.2.0] - 2017-03-14
24
35
  ### Added
25
- - Support [Flow](flowtype.org) coverage reported by [flow-coverage-report](https://github.com/rpl/flow-coverage-report)
36
+ - Support [Flow](https://flowtype.org) coverage reported by [flow-coverage-report](https://github.com/rpl/flow-coverage-report)
26
37
 
27
38
  ### Fixed
28
39
  - Disable inactive reporters
@@ -45,7 +56,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
45
56
  ### Added
46
57
  - Initial release
47
58
 
48
- [Unreleased]: https://github.com/increments/circleci-coverage_reporter/compare/v0.3.1...HEAD
59
+ [Unreleased]: https://github.com/increments/circleci-coverage_reporter/compare/v0.4.0...HEAD
60
+ [0.4.0]: https://github.com/increments/circleci-coverage_reporter/compare/v0.3.1...v0.4.0
49
61
  [0.3.1]: https://github.com/increments/circleci-coverage_reporter/compare/v0.3.0...v0.3.1
50
62
  [0.3.0]: https://github.com/increments/circleci-coverage_reporter/compare/v0.2.0...v0.3.0
51
63
  [0.2.0]: https://github.com/increments/circleci-coverage_reporter/compare/v0.1.3...v0.2.0
data/README.md CHANGED
@@ -97,6 +97,18 @@ CircleCI::CoverageReporter.configure do |config|
97
97
  end
98
98
  ```
99
99
 
100
+ ### RubyCritic
101
+
102
+ `CircleCI::CoverageReporter::RubyCritic::Reporter` handles code quality files generated by
103
+ [rubycritic](https://github.com/whitesmith/rubycritic)
104
+
105
+ At least json format report is required:
106
+
107
+ ```bash
108
+ bundle exec rubycritic -p $CIRCLE_ARTIFACTS/rubycritic -f json --no-browser --mode-ci app
109
+ bundle exec rubycritic -p $CIRCLE_ARTIFACTS/rubycritic -f html --no-browser --mode-ci app # optional
110
+ ```
111
+
100
112
  ## Configuring
101
113
  ### Template
102
114
 
@@ -11,6 +11,11 @@ module CircleCI
11
11
  def url
12
12
  raise NotImplementedError
13
13
  end
14
+
15
+ # @return [String]
16
+ def pretty_coverage
17
+ "#{coverage.round(2)}%"
18
+ end
14
19
  end
15
20
  end
16
21
  end
@@ -1,4 +1,5 @@
1
1
  require_relative 'flow/reporter'
2
+ require_relative 'rubycritic/reporter'
2
3
  require_relative 'simplecov/reporter'
3
4
 
4
5
  module CircleCI
@@ -6,7 +7,8 @@ module CircleCI
6
7
  class Configuration
7
8
  DEFAULT_REPORTERS = [
8
9
  SimpleCov::Reporter.new,
9
- Flow::Reporter.new
10
+ Flow::Reporter.new,
11
+ RubyCritic::Reporter.new
10
12
  ].freeze
11
13
  DEFAULT_TEMPLATE = <<-'ERB'.freeze
12
14
  <%- reports.each do |report| -%>
@@ -18,7 +20,7 @@ module CircleCI
18
20
  progresses = [base_progress, branch_progress].compact
19
21
  progress = progresses.empty? ? nil : " (#{progresses.join(', ')})"
20
22
  -%>
21
- <%= link %>: <%= report.current_result.coverage %>%<%= emoji %><%= progress %>
23
+ <%= link %>: <%= report.current_result.pretty_coverage %><%= emoji %><%= progress %>
22
24
  <%- end -%>
23
25
  ERB
24
26
  DEFAULT_TEMPLATE_TRIM_MODE = '-'.freeze
@@ -15,7 +15,7 @@ module CircleCI
15
15
  # @return [Float]
16
16
  def coverage
17
17
  flow_coverage_json = find_artifact('flow-coverage.json') or return Float::NAN
18
- JSON.parse(flow_coverage_json.body)['percent']
18
+ JSON.parse(flow_coverage_json.body)['percent'].to_f
19
19
  end
20
20
 
21
21
  # @note Implement {AbstractResult#url}
@@ -12,7 +12,7 @@ module CircleCI
12
12
  # @note Implement {AbstractResult#coverage}
13
13
  # @return [Float]
14
14
  def coverage
15
- JSON.parse(File.read(join('flow-coverage.json')))['percent']
15
+ JSON.parse(File.read(join('flow-coverage.json')))['percent'].to_f
16
16
  end
17
17
 
18
18
  # @note Implement {AbstractResult#url}
@@ -29,6 +29,11 @@ module CircleCI
29
29
  reporter.name
30
30
  end
31
31
 
32
+ # @return [String]
33
+ def pretty_coverage
34
+ current_result.pretty_coverage
35
+ end
36
+
32
37
  # @return [Float] coverage percent of the current build result
33
38
  def coverage
34
39
  current_result.coverage
@@ -0,0 +1,40 @@
1
+ require_relative '../abstract_result'
2
+
3
+ module CircleCI
4
+ module CoverageReporter
5
+ module RubyCritic
6
+ class BuildResult < AbstractResult
7
+ # @param path [String]
8
+ # @param build [Build]
9
+ def initialize(path, build)
10
+ @path = path
11
+ @build = build
12
+ end
13
+
14
+ # @note Implement {AbstractResult#coverage}
15
+ # @return [Float]
16
+ def coverage
17
+ last_run_json = find_artifact('report.json') or return Float::NAN
18
+ JSON.parse(last_run_json.body)['score'].to_f
19
+ end
20
+
21
+ # @note Implement {AbstractResult#url}
22
+ # @return [String]
23
+ def url
24
+ index_html = find_artifact('overview.html') or return '#'
25
+ index_html.url
26
+ 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
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,54 @@
1
+ require_relative '../abstract_result'
2
+
3
+ module CircleCI
4
+ module CoverageReporter
5
+ module RubyCritic
6
+ class CurrentResult < AbstractResult
7
+ # @param path [String] path to coverage directory
8
+ def initialize(path)
9
+ @path = path
10
+ end
11
+
12
+ # @note Implement {AbstractResult#coverage}
13
+ # @return [Float]
14
+ def coverage
15
+ JSON.parse(File.read(join('report.json')))['score'].to_f
16
+ end
17
+
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
+ # @note Override {AbstractResult#pretty_coverage}
33
+ # @return [String]
34
+ def pretty_coverage
35
+ "#{coverage.round(2)}pt"
36
+ end
37
+
38
+ private
39
+
40
+ attr_reader :path
41
+
42
+ # @return
43
+ def join(name)
44
+ File.join(configuration.artifacts_dir, path, name)
45
+ end
46
+
47
+ # @return [Configuration]
48
+ def configuration
49
+ CoverageReporter.configuration
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,37 @@
1
+ require 'json'
2
+
3
+ require_relative '../abstract_reporter'
4
+ require_relative 'build_result'
5
+ require_relative 'current_result'
6
+
7
+ module CircleCI
8
+ module CoverageReporter
9
+ module RubyCritic
10
+ class Reporter < AbstractReporter
11
+ DEFAULT_PATH = 'rubycritic'.freeze
12
+
13
+ # @note Implement {AbstractReporter#name}
14
+ # @return [String]
15
+ def name
16
+ 'RubyCritic'
17
+ end
18
+
19
+ private
20
+
21
+ # @note Implement {AbstractReporter#create_build_result}
22
+ # @param build [Build, nil]
23
+ # @return [BuildResult, nil]
24
+ def create_build_result(build)
25
+ return unless build
26
+ BuildResult.new(path, build)
27
+ end
28
+
29
+ # @note Implement {AbstractReporter#create_current_result}
30
+ # @return [CurrentResult]
31
+ def create_current_result
32
+ CurrentResult.new(path)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -15,7 +15,7 @@ module CircleCI
15
15
  # @return [Float]
16
16
  def coverage
17
17
  last_run_json = find_artifact('.last_run.json') or return Float::NAN
18
- JSON.parse(last_run_json.body)['result']['covered_percent']
18
+ JSON.parse(last_run_json.body)['result']['covered_percent'].to_f
19
19
  end
20
20
 
21
21
  # @note Implement {AbstractResult#url}
@@ -12,7 +12,7 @@ module CircleCI
12
12
  # @note Implement {AbstractResult#coverage}
13
13
  # @return [Float]
14
14
  def coverage
15
- JSON.parse(File.read(join('.last_run.json')))['result']['covered_percent']
15
+ JSON.parse(File.read(join('.last_run.json')))['result']['covered_percent'].to_f
16
16
  end
17
17
 
18
18
  # @note Implement {AbstractResult#url}
@@ -2,8 +2,8 @@ module CircleCI
2
2
  module CoverageReporter
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 3
6
- PATCH = 1
5
+ MINOR = 4
6
+ PATCH = 0
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, PATCH].join('.')
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.3.1
4
+ version: 0.4.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-03-16 00:00:00.000000000 Z
11
+ date: 2017-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -73,6 +73,9 @@ files:
73
73
  - lib/circleci/coverage_reporter/rake_task.rb
74
74
  - lib/circleci/coverage_reporter/report.rb
75
75
  - lib/circleci/coverage_reporter/reports_renderer.rb
76
+ - lib/circleci/coverage_reporter/rubycritic/build_result.rb
77
+ - lib/circleci/coverage_reporter/rubycritic/current_result.rb
78
+ - lib/circleci/coverage_reporter/rubycritic/reporter.rb
76
79
  - lib/circleci/coverage_reporter/runner.rb
77
80
  - lib/circleci/coverage_reporter/sandbox.rb
78
81
  - lib/circleci/coverage_reporter/simplecov/build_result.rb