codeclimate-test-reporter 1.0.3 → 1.0.4

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: d2f0e7b87f4bc69171433370ccf94daad9e76fbc
4
- data.tar.gz: 163b2bea6c8a18aaedb6d9b87b082759d90b1980
3
+ metadata.gz: 8288228e25163162b6b30325990ffbc7b5b665a2
4
+ data.tar.gz: 65905735dfec5e174f58a603673f7f12814c36f7
5
5
  SHA512:
6
- metadata.gz: 396899f8c5af9bb10709879343ac12ded0c1868b776833d41c67046df2d9953f7468f5e948732f86bc96f6b60928839d21aac235a79fc1279da7a942152d717f
7
- data.tar.gz: 94df47b0ef15d9f5687d9621a75555fa634844bc108e44cb86d748571d61758c9f777a3afc1d7c5ba44e4e7038004206ac87bc0a35ea7c19e7ac187a3313cae8
6
+ metadata.gz: b521cd941110f5cf514d272ce80c1f85da62058ac9f42ec6668bf96400893eba8f3d792cc20954fad4db622e6cbcd254a86e363f03866b2a4ee760f2d995c3fc
7
+ data.tar.gz: f10dc131ba15d256e90bee8c482819b0801a800e28a9dc8b05f470108bbe3840f3082f85d516302e5c091b7863c0c44011391f80e6e5a42a0e38da0d53c2ebdf
data/README.md CHANGED
@@ -11,34 +11,8 @@ Code Climate - [https://codeclimate.com](https://codeclimate.com)
11
11
 
12
12
  This gem requires a user, but not necessarily a paid account, on Code Climate,
13
13
  so if you don't have one the first step is to signup at:
14
- [https://codeclimate.com](https://codeclimate.com). Then:
15
-
16
- * Add this to your Gemfile:
17
-
18
- ```ruby
19
- group :test do
20
- gem "simplecov"
21
- gem "codeclimate-test-reporter", "~> 1.0.0"
22
- end
23
- ```
24
-
25
- * Start [SimpleCov](https://github.com/colszowka/simplecov) right at the top of
26
- your `spec/spec_helper.rb`, `test/test_helper.rb`, or cucumber `env.rb`.
27
-
28
- ```ruby
29
- require 'simplecov'
30
- SimpleCov.start
31
- ```
32
-
33
- * Set the `CODECLIMATE_REPO_TOKEN` environment variable (provided after you add
34
- your repo to your Code Climate account by clicking on "Setup Test Coverage" on
35
- the right hand side of your feed)
36
- * Run the `codeclimate-test-reporter` executable after your test suite
37
-
38
- ```
39
- bundle exec rake
40
- bundle exec codeclimate-test-reporter
41
- ```
14
+ [https://codeclimate.com](https://codeclimate.com). Then follow the
15
+ instructions on our [documentation site](https://docs.codeclimate.com/docs/ruby)
42
16
 
43
17
  Please contact hello@codeclimate.com if you need any assistance setting this up.
44
18
 
@@ -51,42 +25,11 @@ documentation here: https://docs.codeclimate.com/docs/setting-up-test-coverage
51
25
 
52
26
  ## Upgrading from pre-1.0 Versions
53
27
 
54
- Version `1.0` of the this gem introduces new, breaking changes to the way the
28
+ Version `1.0` of this gem introduced new, breaking changes to the way the
55
29
  test reporter is meant to be executed. The following list summarizes the major
56
30
  differences:
57
31
 
58
- * Previously, this gem extended `Simplecov` with a custom formatter which posted
59
- results to Code Climate. Now, you are responsible for executing `Simplecov`
60
- yourself.
61
-
62
- * If you already have the following in your test/test_helper.rb
63
- (or spec_helper.rb, cucumber env.rb, etc)
64
-
65
- ```ruby
66
- require 'codeclimate-test-reporter'
67
- CodeClimate::TestReporter.start
68
- ```
69
-
70
- then you should replace it with
71
-
72
- ```ruby
73
- require 'simplecov'
74
- SimpleCov.start
75
- ```
76
-
77
- * Previously, the `codeclimate-test-reporter` automatically uploaded results at
78
- the end of your test suite. Now, you are responsible for running
79
- `codeclimate-test-reporter` as a separate step in your build.
80
- * Previously, this gem added some exclusion rules tuned according to feedback
81
- from its users, and now these no longer happen automatically. *If you are
82
- experiencing a discrepancy in test coverage % after switching to the new gem
83
- version, it may be due to missing exclusions. Filtering `vendor`, `spec`, or
84
- `test` directories may fix this issue.*
85
- * Previously, during the execution of multiple test suites, this gem would send
86
- results from the first suite completed. You are now expected to run an
87
- executable packaged with this gem as a separate build step, which means that
88
- whatever results are there (likely the results from the last suite) will be
89
- posted to Code Climate.
32
+ See [the changelog entry for v1.0.0](CHANGELOG.md#v100-2016-11-03) for details.
90
33
 
91
34
  ## Contributions
92
35
 
@@ -94,7 +37,21 @@ Patches, bug fixes, feature requests, and pull requests are welcome on the
94
37
  GitHub page for this project:
95
38
  [https://github.com/codeclimate/ruby-test-reporter](https://github.com/codeclimate/ruby-test-reporter)
96
39
 
97
- This gem is maintained by Bryan Helmkamp (bryan@codeclimate.com).
40
+ When making a pull request, please update the [changelog](CHANGELOG.md).
41
+
42
+ This gem is maintained by Code Climate (hello@codeclimate.com).
43
+
44
+ ### Release Process
45
+
46
+ * Update the changelog to mark the unreleased changes as part of the new release.
47
+ * Update the version.rb with the new version number
48
+ * Make a pull request with those changes
49
+ * Merge those changes to master
50
+ * Check out and pull down the latest master locally
51
+ * `rake release` which will
52
+ * tag the latest commit based on version.rb
53
+ * push to github
54
+ * push to rubygems
98
55
 
99
56
  ## Copyright
100
57
 
@@ -2,23 +2,20 @@
2
2
 
3
3
  require "codeclimate-test-reporter"
4
4
 
5
- COVERAGE_FILE = "coverage/.resultset.json".freeze
5
+ repo_token = ENV["CODECLIMATE_REPO_TOKEN"]
6
+ if repo_token.nil? || repo_token.empty?
7
+ STDERR.puts "Cannot post results: environment variable CODECLIMATE_REPO_TOKEN must be set."
8
+ exit
9
+ end
10
+
11
+ COVERAGE_FILE = ARGV.first || "coverage/.resultset.json"
6
12
 
7
- if (repo_token = ENV["CODECLIMATE_REPO_TOKEN"]) && !repo_token.empty?
8
- if File.exist?(COVERAGE_FILE)
9
- begin
10
- results = JSON.parse(File.read(COVERAGE_FILE))
11
- rescue JSON::ParserError => e
12
- $stderr.puts "Error encountered while parsing #{COVERAGE_FILE}: #{e}"
13
- exit(1)
14
- end
13
+ abort "Coverage results not found" unless File.exist?(COVERAGE_FILE)
15
14
 
16
- CodeClimate::TestReporter.run(results)
17
- else
18
- $stderr.puts "Coverage results not found"
19
- exit(1)
20
- end
21
- else
22
- $stderr.puts "Cannot post results: environment variable CODECLIMATE_REPO_TOKEN must be set."
23
- exit(0)
15
+ begin
16
+ results = JSON.parse(File.read(COVERAGE_FILE))
17
+ rescue JSON::ParserError => e
18
+ abort "Error encountered while parsing #{COVERAGE_FILE}: #{e}"
24
19
  end
20
+
21
+ CodeClimate::TestReporter.run(results)
@@ -12,18 +12,19 @@ require "code_climate/test_reporter/payload_validator"
12
12
  module CodeClimate
13
13
  module TestReporter
14
14
  class Formatter
15
- class InvalidSimpleCovResultError < StandardError; end
16
-
17
15
  def format(results)
18
- begin
19
- validated_results = results.values.fetch(0).fetch("coverage")
20
- rescue NoMethodError, KeyError => ex
21
- raise InvalidSimpleCovResultError, ex.message
16
+ simplecov_results = results.map do |command_name, data|
17
+ SimpleCov::Result.from_hash(command_name => data)
22
18
  end
23
19
 
24
- simplecov_results = SimpleCov::Result.new(validated_results)
20
+ simplecov_result =
21
+ if simplecov_results.size == 1
22
+ simplecov_results.first
23
+ else
24
+ merge_results(simplecov_results)
25
+ end
25
26
 
26
- payload = to_payload(simplecov_results)
27
+ payload = to_payload(simplecov_result)
27
28
  PayloadValidator.validate(payload)
28
29
 
29
30
  payload
@@ -85,6 +86,19 @@ module CodeClimate
85
86
  def round(numeric, precision)
86
87
  Float(numeric).round(precision)
87
88
  end
89
+
90
+ # Re-implementation of Simplecov::ResultMerger#merged_result, which is
91
+ # needed because calling it directly gets you into caching land with files
92
+ # on disk.
93
+ def merge_results(results)
94
+ merged = {}
95
+ results.each do |result|
96
+ merged = result.original_result.merge_resultset(merged)
97
+ end
98
+ result = SimpleCov::Result.new(merged)
99
+ result.command_name = results.map(&:command_name).sort.join(", ")
100
+ result
101
+ end
88
102
  end
89
103
  end
90
104
  end
@@ -1,5 +1,5 @@
1
1
  module CodeClimate
2
2
  module TestReporter
3
- VERSION = "1.0.3".freeze
3
+ VERSION = "1.0.4".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate-test-reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
8
+ - Code Climate
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
12
+ date: 2016-12-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: simplecov
@@ -98,6 +99,7 @@ description: Collects test coverage data from your Ruby test suite and sends it
98
99
  Code Climate's hosted, automated code review service. Based on SimpleCov.
99
100
  email:
100
101
  - bryan@brynary.com
102
+ - hello@codeclimate.com
101
103
  executables:
102
104
  - cc-tddium-post-worker
103
105
  - codeclimate-test-reporter
@@ -143,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
145
  version: '0'
144
146
  requirements: []
145
147
  rubyforge_project:
146
- rubygems_version: 2.4.5
148
+ rubygems_version: 2.6.8
147
149
  signing_key:
148
150
  specification_version: 4
149
151
  summary: Uploads Ruby test coverage data to Code Climate.