codeclimate-test-reporter 1.0.3 → 1.0.4
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/README.md +19 -62
- data/bin/codeclimate-test-reporter +14 -17
- data/lib/code_climate/test_reporter/formatter.rb +22 -8
- data/lib/code_climate/test_reporter/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8288228e25163162b6b30325990ffbc7b5b665a2
|
4
|
+
data.tar.gz: 65905735dfec5e174f58a603673f7f12814c36f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
19
|
-
|
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
|
-
|
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(
|
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
|
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.
|
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-
|
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.
|
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.
|