codeclimate-test-reporter 0.6.0 → 1.0.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -118
- data/bin/cc-tddium-post-worker +1 -1
- data/bin/codeclimate-test-reporter +24 -0
- data/lib/code_climate/test_reporter.rb +25 -8
- data/lib/code_climate/test_reporter/calculate_blob.rb +1 -3
- data/lib/code_climate/test_reporter/client.rb +2 -3
- data/lib/code_climate/test_reporter/exception_message.rb +8 -9
- data/lib/code_climate/test_reporter/formatter.rb +18 -51
- data/lib/code_climate/test_reporter/git.rb +4 -6
- data/lib/code_climate/test_reporter/payload_validator.rb +1 -1
- data/lib/code_climate/test_reporter/post_results.rb +30 -0
- data/lib/code_climate/test_reporter/shorten_filename.rb +24 -0
- data/lib/code_climate/test_reporter/version.rb +1 -1
- data/lib/codeclimate-test-reporter.rb +2 -0
- metadata +12 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08921de545ca6789aaad9546a08c077a4ae10f05
|
4
|
+
data.tar.gz: c23c5e94c1d64063616484ba416276aa03f5dd24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46ba88ff210d1e46cbf827e346bedb1e265a8f74dc57195884361c02ad63afb79f24ad744d0ad59a68c5825d4c4a776a405d83c4d1b082c968209190fc36b94a
|
7
|
+
data.tar.gz: 8d78f59904fce2fc618ea4cbe911ef13c091d6f4283e44f7630021d6b5fcdb92bfc7f649ae2defb97c003e2c5122f81275b8808b97df919eaed5700ea1f48f8d
|
data/README.md
CHANGED
@@ -2,23 +2,10 @@
|
|
2
2
|
|
3
3
|
[![Code Climate](https://codeclimate.com/github/codeclimate/ruby-test-reporter/badges/gpa.svg)](https://codeclimate.com/github/codeclimate/ruby-test-reporter)
|
4
4
|
|
5
|
-
|
6
|
-
Climate's hosted, automated code review service. Based on SimpleCov.
|
5
|
+
Posts SimpleCov test coverage data from your Ruby test suite to Code Climate's hosted, automated code review service.
|
7
6
|
|
8
7
|
Code Climate - [https://codeclimate.com](https://codeclimate.com)
|
9
8
|
|
10
|
-
# Important FYIs
|
11
|
-
|
12
|
-
Across the many different testing frameworks, setups, and environments, there are lots of variables at play. Before setting up test coverage, it's important to understand what we do and do not currently support:
|
13
|
-
|
14
|
-
* **Default branch only:** We only support test coverage for your [default branch](http://docs.codeclimate.com/article/151-glossary-default-branch). Be sure to check out this branch before running your tests.
|
15
|
-
* **Single payload:** We currently only support a single test coverage payload per commit. If you run your tests in multiple steps, or via parallel tests, Code Climate will only process the first payload that we receive. If you are using a CI, be sure to check if you are running your tests in a parallel mode.
|
16
|
-
|
17
|
-
**Note:** There is one exception to this rule. We've specifically built an integration with [Solano Labs](https://www.solanolabs.com/) to support parallel tests.
|
18
|
-
|
19
|
-
**Note:** If you've configured Code Climate to analyze multiple languages in the same repository (e.g., Ruby and JavaScript), we can nonetheless only process test coverage information for one of these languages. We'll process the first payload that we receive.
|
20
|
-
* **Invalid File Paths:** By default, our test reporters expect your application to exist at the root of your repository. If this is not the case, the file paths in your test coverage payload will not match the file paths that Code Climate expects. For our Ruby test reporter, [we have a work-around to this issue](http://docs.codeclimate.com/article/220-help-im-having-trouble-with-test-coverage#ruby_sub_folder).
|
21
|
-
|
22
9
|
## Installation
|
23
10
|
|
24
11
|
This gem requires a user, but not necessarily a paid account, on Code Climate, so if you don't have one the
|
@@ -28,116 +15,17 @@ first step is to signup at: [https://codeclimate.com](https://codeclimate.com).
|
|
28
15
|
|
29
16
|
gem "codeclimate-test-reporter", group: :test
|
30
17
|
|
31
|
-
1. Start
|
32
|
-
`spec_helper.rb` file:
|
18
|
+
1. Start SimpleCov as you normally would (more information here: https://github.com/colszowka/simplecov)
|
33
19
|
|
34
|
-
|
35
|
-
CodeClimate::TestReporter.start
|
20
|
+
1. Set the `CODECLIMATE_REPO_TOKEN` environment variable (provided after you add your repo to your Code Climate account by clicking on "Setup Test Coverage" on the right hand side of your feed)
|
36
21
|
|
37
|
-
|
38
|
-
on your CI server, and the results will show up in your Code Climate account.
|
39
|
-
|
40
|
-
The `CODECLIMATE_REPO_TOKEN` value is provided after you add your repo to your
|
41
|
-
Code Climate account by clicking on "Setup Test Coverage" on the right hand side of your feed.
|
22
|
+
1. Run the `codeclimate-test-reporter` executable at the end of your test suite
|
42
23
|
|
43
24
|
Please contact hello@codeclimate.com if you need any assistance setting this up.
|
44
25
|
|
45
|
-
##
|
46
|
-
|
47
|
-
Certain behaviors of the test reporter can be configured. See the `Configuration`
|
48
|
-
class for more details. For example, you can change the logging level to not
|
49
|
-
print info messages:
|
50
|
-
|
51
|
-
*Note that the configuration block must come before TestReporter.start.*
|
52
|
-
|
53
|
-
```ruby
|
54
|
-
CodeClimate::TestReporter.configure do |config|
|
55
|
-
config.logger.level = Logger::WARN
|
56
|
-
end
|
57
|
-
|
58
|
-
CodeClimate::TestReporter.start
|
59
|
-
```
|
60
|
-
|
61
|
-
Another example for when your Rails application root is not at the root of the git repository root
|
62
|
-
|
63
|
-
```ruby
|
64
|
-
CodeClimate::TestReporter.configure do |config|
|
65
|
-
config.path_prefix = "app_root" #the root of your Rails application relative to the repository root
|
66
|
-
config.git_dir = "../" #the relative or absolute location of your git root compared to where your tests are run
|
67
|
-
end
|
68
|
-
|
69
|
-
CodeClimate::TestReporter.start
|
70
|
-
```
|
71
|
-
|
72
|
-
## Troubleshooting
|
73
|
-
|
74
|
-
If you're having trouble setting up or working with our test coverage feature, [see our detailed help doc](http://docs.codeclimate.com/article/220-help-im-having-trouble-with-test-coverage), which covers the most common issues encountered.
|
75
|
-
|
76
|
-
## Extending Simplecov with other formatters
|
77
|
-
|
78
|
-
Since ruby-test-reporter 0.4.0 you can use `CodeClimate::TestReporter::Formatter` as a Simplecov formatter directly. Just add the formatter to your Simplecov formatter in addition to the rest of your configuration:
|
79
|
-
|
80
|
-
```ruby
|
81
|
-
require 'codeclimate-test-reporter'
|
82
|
-
SimpleCov.start do
|
83
|
-
formatter SimpleCov::Formatter::MultiFormatter.new([
|
84
|
-
SimpleCov::Formatter::HTMLFormatter,
|
85
|
-
CodeClimate::TestReporter::Formatter
|
86
|
-
])
|
87
|
-
...
|
88
|
-
end
|
89
|
-
```
|
90
|
-
|
91
|
-
## Using with [parallel_tests](https://github.com/grosser/parallel_tests)
|
92
|
-
|
93
|
-
Note: This may work with other parallel test runners as long as they run on the same machine.
|
94
|
-
|
95
|
-
Be sure you're using `simplecov` `>= 0.9.0`.
|
96
|
-
|
97
|
-
Add the following to your `test_helper.rb`/`spec_helper.rb` instead of what is normally required.
|
98
|
-
|
99
|
-
```ruby
|
100
|
-
require 'simplecov'
|
101
|
-
require 'codeclimate-test-reporter'
|
102
|
-
SimpleCov.add_filter 'vendor'
|
103
|
-
SimpleCov.formatters = []
|
104
|
-
SimpleCov.start CodeClimate::TestReporter.configuration.profile
|
105
|
-
```
|
106
|
-
|
107
|
-
Then after all your tests run, in a rake task or as a build step do:
|
108
|
-
|
109
|
-
```
|
110
|
-
require 'simplecov'
|
111
|
-
require 'codeclimate-test-reporter'
|
112
|
-
CodeClimate::TestReporter::Formatter.new.format(SimpleCov.result)
|
113
|
-
```
|
114
|
-
|
115
|
-
## Using with multiple machines
|
116
|
-
|
117
|
-
For the time-being, we don't officially support coverage data from parallel test runs. That said, [codeclimate batch](https://github.com/grosser/codeclimate_batch) is a handy work-around that was created by one of our customers.
|
118
|
-
|
119
|
-
Note that this solution requires standing up a separate server (like a Heroku instance) that sits between your testing environment and Code Climate. Though this option is not formally supported, if you have an immediate need for parallel testing support, [codeclimate batch](https://github.com/grosser/codeclimate_batch) is a helpful interim solution until we can release our official support for this.
|
120
|
-
|
121
|
-
## Help! Your gem is raising a ...
|
122
|
-
|
123
|
-
### VCR::Errors::UnhandledHTTPRequestError
|
124
|
-
|
125
|
-
Add the following to your spec or test helper:
|
126
|
-
|
127
|
-
VCR.configure do |config|
|
128
|
-
# your existing configuration
|
129
|
-
config.ignore_hosts 'codeclimate.com'
|
130
|
-
end
|
131
|
-
|
132
|
-
### WebMock::NetConnectNotAllowedError
|
133
|
-
|
134
|
-
Add the following to your spec or test helper:
|
135
|
-
|
136
|
-
WebMock.disable_net_connect!(:allow => "codeclimate.com")
|
137
|
-
|
138
|
-
### Other communication failures
|
26
|
+
## Troubleshooting / FYIs
|
139
27
|
|
140
|
-
|
28
|
+
Across the many different testing frameworks, setups, and environments, there are lots of variables at play. If you're having any trouble with your test coverage reporting or the results are confusing, please see our full documentation here: https://docs.codeclimate.com/docs/setting-up-test-coverage
|
141
29
|
|
142
30
|
## Contributions
|
143
31
|
|
data/bin/cc-tddium-post-worker
CHANGED
@@ -7,7 +7,7 @@ if ENV["CODECLIMATE_REPO_TOKEN"]
|
|
7
7
|
tmpdir = Dir.tmpdir
|
8
8
|
puts "Searching #{tmpdir} for files to POST."
|
9
9
|
coverage_report_files = Dir.glob("#{tmpdir}/codeclimate-test-coverage-*")
|
10
|
-
if coverage_report_files.
|
10
|
+
if coverage_report_files.any?
|
11
11
|
puts "Found: "
|
12
12
|
puts coverage_report_files.join("\n")
|
13
13
|
client = CodeClimate::TestReporter::Client.new
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "codeclimate-test-reporter"
|
4
|
+
|
5
|
+
COVERAGE_FILE = "coverage/.resultset.json".freeze
|
6
|
+
|
7
|
+
if ENV["CODECLIMATE_REPO_TOKEN"]
|
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
|
15
|
+
|
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)
|
24
|
+
end
|
@@ -1,14 +1,23 @@
|
|
1
1
|
module CodeClimate
|
2
2
|
module TestReporter
|
3
|
+
WARNING_MESSAGE = <<-EOS.freeze
|
4
|
+
This usage of the Code Climate Test Reporter is now deprecated. Since version
|
5
|
+
1.0, we now require you to run `SimpleCov` in your test/spec helper, and then
|
6
|
+
run the provided `codeclimate-ruby` binary separately to report your results
|
7
|
+
to Code Climate.
|
8
|
+
|
9
|
+
More information here: https://github.com/codeclimate/ruby-test-reporter/blob/master/README.md
|
10
|
+
EOS
|
11
|
+
|
3
12
|
def self.start
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
13
|
+
logger.warn(WARNING_MESSAGE)
|
14
|
+
exit(1)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.run(results)
|
18
|
+
return unless CodeClimate::TestReporter.run?
|
19
|
+
formatted_results = CodeClimate::TestReporter::Formatter.new.format(results)
|
20
|
+
CodeClimate::TestReporter::PostResults.new(formatted_results).post
|
12
21
|
end
|
13
22
|
|
14
23
|
def self.run?
|
@@ -50,5 +59,13 @@ module CodeClimate
|
|
50
59
|
def self.logger
|
51
60
|
CodeClimate::TestReporter.configuration.logger
|
52
61
|
end
|
62
|
+
|
63
|
+
def self.tddium?
|
64
|
+
ci_service_data && ci_service_data[:name] == "tddium"
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.ci_service_data
|
68
|
+
Ci.service_data
|
69
|
+
end
|
53
70
|
end
|
54
71
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module CodeClimate
|
2
2
|
module TestReporter
|
3
3
|
class CalculateBlob
|
4
|
-
|
5
4
|
def initialize(file_path)
|
6
5
|
@file_path = file_path
|
7
6
|
end
|
@@ -10,7 +9,7 @@ module CodeClimate
|
|
10
9
|
calculate_with_file or calculate_with_git
|
11
10
|
end
|
12
11
|
|
13
|
-
|
12
|
+
private
|
14
13
|
|
15
14
|
def calculate_with_file
|
16
15
|
File.open(@file_path, "rb") do |file|
|
@@ -31,7 +30,6 @@ module CodeClimate
|
|
31
30
|
|
32
31
|
output
|
33
32
|
end
|
34
|
-
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
@@ -5,9 +5,8 @@ require "net/https"
|
|
5
5
|
module CodeClimate
|
6
6
|
module TestReporter
|
7
7
|
class Client
|
8
|
-
|
9
8
|
DEFAULT_TIMEOUT = 5 # in seconds
|
10
|
-
USER_AGENT = "Code Climate (Ruby Test Reporter v#{VERSION})"
|
9
|
+
USER_AGENT = "Code Climate (Ruby Test Reporter v#{CodeClimate::TestReporter::VERSION})".freeze
|
11
10
|
|
12
11
|
def host
|
13
12
|
ENV["CODECLIMATE_API_HOST"] ||
|
@@ -72,7 +71,7 @@ module CodeClimate
|
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
75
|
-
|
74
|
+
private
|
76
75
|
|
77
76
|
def http_client(uri)
|
78
77
|
Net::HTTP.new(uri.host, uri.port).tap do |http|
|
@@ -6,9 +6,9 @@ module CodeClimate
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def instructions
|
9
|
-
|
9
|
+
<<-STR
|
10
10
|
WebMock.disable_net_connect!(:allow => "codeclimate.com")
|
11
|
-
STR
|
11
|
+
STR
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -18,21 +18,20 @@ STR
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def instructions
|
21
|
-
|
21
|
+
<<-STR
|
22
22
|
VCR.configure do |config|
|
23
23
|
# your existing configuration
|
24
24
|
config.ignore_hosts 'codeclimate.com'
|
25
25
|
end
|
26
|
-
STR
|
26
|
+
STR
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
class ExceptionMessage
|
31
|
-
|
32
31
|
HTTP_STUBBING_MESSAGES = {
|
33
|
-
"VCR::Errors::UnhandledHTTPRequestError" => VCRMessage,
|
34
|
-
"WebMock::NetConnectNotAllowedError"
|
35
|
-
}
|
32
|
+
"VCR::Errors::UnhandledHTTPRequestError".freeze => VCRMessage,
|
33
|
+
"WebMock::NetConnectNotAllowedError".freeze => WebMockMessage,
|
34
|
+
}.freeze
|
36
35
|
|
37
36
|
def initialize(exception)
|
38
37
|
@exception = exception
|
@@ -59,7 +58,7 @@ Add the following to your spec or test helper to ensure codeclimate-test-reporte
|
|
59
58
|
parts.join("\n")
|
60
59
|
end
|
61
60
|
|
62
|
-
|
61
|
+
private
|
63
62
|
|
64
63
|
def exception_class
|
65
64
|
@exception.class.to_s
|
@@ -12,41 +12,27 @@ require "code_climate/test_reporter/payload_validator"
|
|
12
12
|
module CodeClimate
|
13
13
|
module TestReporter
|
14
14
|
class Formatter
|
15
|
-
|
16
|
-
return true unless CodeClimate::TestReporter.run?
|
15
|
+
class InvalidSimpleCovResultError < StandardError; end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
file_path = File.join(Dir.tmpdir, "codeclimate-test-coverage-#{SecureRandom.uuid}.json")
|
24
|
-
print "Coverage results saved to #{file_path}... "
|
25
|
-
File.open(file_path, "w") { |file| file.write(payload.to_json) }
|
26
|
-
else
|
27
|
-
client = Client.new
|
28
|
-
print "Sending report to #{client.host} for branch #{Git.branch_from_git_or_ci}... "
|
29
|
-
client.post_results(payload)
|
17
|
+
def format(results)
|
18
|
+
begin
|
19
|
+
validated_results = results.values.fetch(0).fetch("coverage")
|
20
|
+
rescue NoMethodError, KeyError => ex
|
21
|
+
raise InvalidSimpleCovResultError, ex.message
|
30
22
|
end
|
31
23
|
|
32
|
-
|
33
|
-
true
|
34
|
-
rescue => ex
|
35
|
-
puts ExceptionMessage.new(ex).message
|
36
|
-
false
|
37
|
-
end
|
24
|
+
simplecov_results = SimpleCov::Result.new(validated_results)
|
38
25
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
apply_prefix filename
|
26
|
+
payload = to_payload(simplecov_results)
|
27
|
+
PayloadValidator.validate(payload)
|
28
|
+
|
29
|
+
payload
|
44
30
|
end
|
45
31
|
|
46
|
-
|
32
|
+
private
|
47
33
|
|
48
34
|
def partial?
|
49
|
-
tddium?
|
35
|
+
CodeClimate::TestReporter.tddium?
|
50
36
|
end
|
51
37
|
|
52
38
|
def to_payload(result)
|
@@ -62,7 +48,7 @@ module CodeClimate
|
|
62
48
|
end
|
63
49
|
|
64
50
|
{
|
65
|
-
name:
|
51
|
+
name: ShortenFilename.new(file.filename).short_filename,
|
66
52
|
blob_id: CalculateBlob.new(file.filename).blob_id,
|
67
53
|
coverage: file.coverage.to_json,
|
68
54
|
covered_percent: round(file.covered_percent, 2),
|
@@ -70,8 +56,8 @@ module CodeClimate
|
|
70
56
|
line_counts: {
|
71
57
|
total: file.lines.count,
|
72
58
|
covered: file.covered_lines.count,
|
73
|
-
missed: file.missed_lines.count
|
74
|
-
}
|
59
|
+
missed: file.missed_lines.count,
|
60
|
+
},
|
75
61
|
}
|
76
62
|
end
|
77
63
|
|
@@ -89,36 +75,17 @@ module CodeClimate
|
|
89
75
|
pwd: Dir.pwd,
|
90
76
|
rails_root: (Rails.root.to_s rescue nil),
|
91
77
|
simplecov_root: ::SimpleCov.root,
|
92
|
-
gem_version: VERSION
|
78
|
+
gem_version: VERSION,
|
93
79
|
},
|
94
|
-
ci_service: ci_service_data
|
80
|
+
ci_service: CodeClimate::TestReporter.ci_service_data,
|
95
81
|
}
|
96
82
|
end
|
97
83
|
|
98
|
-
def tddium?
|
99
|
-
ci_service_data && ci_service_data[:name] == "tddium"
|
100
|
-
end
|
101
|
-
|
102
84
|
# Convert to Float before rounding.
|
103
85
|
# Fixes [#7] possible segmentation fault when calling #round on a Rational
|
104
86
|
def round(numeric, precision)
|
105
87
|
Float(numeric).round(precision)
|
106
88
|
end
|
107
|
-
|
108
|
-
def write_to_file?
|
109
|
-
warn "TO_FILE is deprecated, use CODECLIMATE_TO_FILE" if ENV["TO_FILE"]
|
110
|
-
tddium? || ENV["CODECLIMATE_TO_FILE"] || ENV["TO_FILE"]
|
111
|
-
end
|
112
|
-
|
113
|
-
def apply_prefix filename
|
114
|
-
prefix = CodeClimate::TestReporter.configuration.path_prefix
|
115
|
-
return filename if prefix.nil?
|
116
|
-
"#{prefix}/#{filename}"
|
117
|
-
end
|
118
|
-
|
119
|
-
def ci_service_data
|
120
|
-
@ci_service_data ||= Ci.service_data
|
121
|
-
end
|
122
89
|
end
|
123
90
|
end
|
124
91
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module CodeClimate
|
2
2
|
module TestReporter
|
3
3
|
class Git
|
4
|
-
|
5
4
|
class << self
|
6
5
|
def info
|
7
6
|
{
|
@@ -17,16 +16,16 @@ module CodeClimate
|
|
17
16
|
|
18
17
|
def clean_service_branch
|
19
18
|
ci_branch = String(Ci.service_data[:branch])
|
20
|
-
clean = ci_branch.strip.sub(
|
19
|
+
clean = ci_branch.strip.sub(%r{^origin/}, "")
|
21
20
|
|
22
|
-
clean.
|
21
|
+
!clean.empty? ? clean : nil
|
23
22
|
end
|
24
23
|
|
25
24
|
def clean_git_branch
|
26
25
|
git_branch = String(branch_from_git)
|
27
|
-
clean = git_branch.sub(
|
26
|
+
clean = git_branch.sub(%r{^origin/}, "") unless git_branch.start_with?("(")
|
28
27
|
|
29
|
-
clean.
|
28
|
+
!clean.empty? ? clean : nil
|
30
29
|
end
|
31
30
|
|
32
31
|
private
|
@@ -65,4 +64,3 @@ module CodeClimate
|
|
65
64
|
end
|
66
65
|
end
|
67
66
|
end
|
68
|
-
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module CodeClimate
|
2
|
+
module TestReporter
|
3
|
+
class PostResults
|
4
|
+
def initialize(results)
|
5
|
+
@results = results
|
6
|
+
end
|
7
|
+
|
8
|
+
def post
|
9
|
+
if write_to_file?
|
10
|
+
file_path = File.join(Dir.tmpdir, "codeclimate-test-coverage-#{SecureRandom.uuid}.json")
|
11
|
+
print "Coverage results saved to #{file_path}... "
|
12
|
+
File.open(file_path, "w") { |file| file.write(@results.to_json) }
|
13
|
+
else
|
14
|
+
client = Client.new
|
15
|
+
print "Sending report to #{client.host} for branch #{Git.branch_from_git_or_ci}... "
|
16
|
+
client.post_results(@results)
|
17
|
+
end
|
18
|
+
|
19
|
+
puts "done."
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def write_to_file?
|
25
|
+
warn "TO_FILE is deprecated, use CODECLIMATE_TO_FILE" if ENV["TO_FILE"]
|
26
|
+
CodeClimate::TestReporter.tddium? || ENV["CODECLIMATE_TO_FILE"] || ENV["TO_FILE"]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CodeClimate
|
2
|
+
module TestReporter
|
3
|
+
class ShortenFilename
|
4
|
+
def initialize(filename)
|
5
|
+
@filename = filename
|
6
|
+
end
|
7
|
+
|
8
|
+
def short_filename
|
9
|
+
return @filename unless ::SimpleCov.root
|
10
|
+
apply_prefix @filename.gsub(/^#{::SimpleCov.root}/, ".").gsub(%r{^\./}, "")
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def apply_prefix(filename)
|
16
|
+
if (prefix = CodeClimate::TestReporter.configuration.path_prefix)
|
17
|
+
File.join(prefix, filename)
|
18
|
+
else
|
19
|
+
filename
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -2,6 +2,8 @@ require "code_climate/test_reporter"
|
|
2
2
|
require "code_climate/test_reporter/calculate_blob"
|
3
3
|
require "code_climate/test_reporter/version"
|
4
4
|
require "code_climate/test_reporter/client"
|
5
|
+
require "code_climate/test_reporter/post_results"
|
6
|
+
require "code_climate/test_reporter/shorten_filename"
|
5
7
|
require "code_climate/test_reporter/formatter"
|
6
8
|
require "code_climate/test_reporter/configuration"
|
7
9
|
require "code_climate/test_reporter/git"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate-test-reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.pre.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Helmkamp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.0.0
|
23
|
-
type: :runtime
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.0.0
|
26
|
+
version: '0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: bundler
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,12 +100,14 @@ email:
|
|
106
100
|
- bryan@brynary.com
|
107
101
|
executables:
|
108
102
|
- cc-tddium-post-worker
|
103
|
+
- codeclimate-test-reporter
|
109
104
|
extensions: []
|
110
105
|
extra_rdoc_files: []
|
111
106
|
files:
|
112
107
|
- LICENSE.txt
|
113
108
|
- README.md
|
114
109
|
- bin/cc-tddium-post-worker
|
110
|
+
- bin/codeclimate-test-reporter
|
115
111
|
- config/cacert.pem
|
116
112
|
- lib/code_climate/test_reporter.rb
|
117
113
|
- lib/code_climate/test_reporter/calculate_blob.rb
|
@@ -122,6 +118,8 @@ files:
|
|
122
118
|
- lib/code_climate/test_reporter/formatter.rb
|
123
119
|
- lib/code_climate/test_reporter/git.rb
|
124
120
|
- lib/code_climate/test_reporter/payload_validator.rb
|
121
|
+
- lib/code_climate/test_reporter/post_results.rb
|
122
|
+
- lib/code_climate/test_reporter/shorten_filename.rb
|
125
123
|
- lib/code_climate/test_reporter/version.rb
|
126
124
|
- lib/codeclimate-test-reporter.rb
|
127
125
|
homepage: https://github.com/codeclimate/ruby-test-reporter
|
@@ -139,9 +137,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
137
|
version: '1.9'
|
140
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
139
|
requirements:
|
142
|
-
- - "
|
140
|
+
- - ">"
|
143
141
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
142
|
+
version: 1.3.1
|
145
143
|
requirements: []
|
146
144
|
rubyforge_project:
|
147
145
|
rubygems_version: 2.4.5
|
@@ -149,3 +147,4 @@ signing_key:
|
|
149
147
|
specification_version: 4
|
150
148
|
summary: Uploads Ruby test coverage data to Code Climate.
|
151
149
|
test_files: []
|
150
|
+
has_rdoc:
|