codeclimate_circle_ci_coverage 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OTA0MzhhYmJkZmM2NjIxMGJmYTYxZTY2MDBmMDRkNmQ4ZGZjYzI1Mw==
5
- data.tar.gz: !binary |-
6
- OWY5NDMwYzA0MjljNDdjNjIxOGQyY2IyN2Y1MDY3NGU0MGE0Yjg2OQ==
2
+ SHA1:
3
+ metadata.gz: 77c9a114b6d1c02f0ac91c9ad154f7e64f0e0511
4
+ data.tar.gz: 31b1711f5cbfe8eaebc4a9203931a1e8dca3f8c6
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- Zjk0MTQzYjQ4ODE0ZTQ3MDZmYTI2NWQ3Mzk5MDBjN2M5ZmIwODVhNGQzZGQ0
10
- MjQ3ZGU1ZjcwZTVmZGU4NTNkMWU1YzU0N2RkZTVmNGYxOTllNjM4OGFiZmQ3
11
- ZmU2OWMwOGU3MjQ5YTAyZGZiN2Q2MzlkZmIzYWUzY2M5ZGIyOTY=
12
- data.tar.gz: !binary |-
13
- YmY3MjhjMjkxOGQ5NmQ1Mzg0MTUzYmYzZGU0MTM0ZTg1ZTM0NmE1NTgyOTBm
14
- NTZiOTFhZTdkODBhZWNhY2QzMTE1NTM5NTc3YmY4Yjc0NDFhZTNkMzA4YmNj
15
- OGExOTcyNDBmNWNkMTBjNDBiYzk2Zjc3YWQ5NGU3MmZhNTRiMzc=
6
+ metadata.gz: 6c4a73570d3ae41ce42241b2c7155226ce61fdd7dcefa61580a83ac8c3be71a7c5467029849ebfff81636e81d3719f330db27c6a01abb5cc6194cedc663eb183
7
+ data.tar.gz: dc1447ec095c3e0fe3519408d11cf6761a4721a3a104963293bbabf41fabe73445a4987cf779b7ab5574cd61116d23de72a8ba160d9091bd67b64a8f31cb4672
data/bin/report_coverage CHANGED
@@ -14,4 +14,8 @@ OptionParser.new do |opts|
14
14
  end.parse!
15
15
 
16
16
  reporter = CoverageReporter.new(options[:branch])
17
- reporter.run
17
+ if reporter.run
18
+ exit(0)
19
+ else
20
+ abort "Error running report_coverage"
21
+ end
@@ -27,11 +27,18 @@ class CoverageReporter
27
27
  ENV['CIRCLE_NODE_INDEX'].to_i
28
28
  end
29
29
 
30
+ # Returns false if unsuccessful
31
+ # Returns true if successful
30
32
  def run
31
33
  # Only submit coverage to codeclimate on target branch
32
- return if current_branch != target_branch
34
+ if current_branch != target_branch
35
+ puts "Current branch #{current_branch} is not the target branch #{target_branch}"
36
+ puts "No Coverage will be reported"
37
+ return false
38
+ end
39
+
33
40
  # Only run on node0
34
- return unless current_node.zero?
41
+ return false unless current_node.zero?
35
42
 
36
43
  all_coverage_dir = File.join("all_coverage")
37
44
  download_files(all_coverage_dir)
@@ -41,6 +48,7 @@ class CoverageReporter
41
48
  output_result_html(merged_result)
42
49
  upload_result_file(merged_result)
43
50
  store_code_climate_payload(merged_result)
51
+ true
44
52
  end
45
53
 
46
54
  # Public: Download the .resultset.json files from each of the nodes
@@ -79,14 +87,7 @@ class CoverageReporter
79
87
  resultset = JSON.load(File.read(file))
80
88
  resultset.each do |_command_name, data|
81
89
  result = SimpleCov::Result.from_hash(['command', i].join => data)
82
-
83
- puts "Resetting result #{i} created_at from #{result.created_at} to #{Time.now}"
84
- # It appears that sometimes the nodes provided by CircleCI have
85
- # clocks which are not accurate/synchronized
86
- # So we always set the created_at to Time.now so that the ResultMerger
87
- # doesn't discard any results
88
- result.created_at = Time.now
89
-
90
+ check_and_fix_result_time(result)
90
91
  SimpleCov::ResultMerger.store_result(result)
91
92
  end
92
93
  end
@@ -96,6 +97,18 @@ class CoverageReporter
96
97
  merged_result
97
98
  end
98
99
 
100
+ def check_and_fix_result_time(result)
101
+ if Time.now - result.created_at >= SimpleCov.merge_timeout
102
+ puts "result #{i} has a created_at from #{result.created_at} (current time #{Time.now})"
103
+ puts "This will prevent coverage from being combined. Please check your tests for Stub-Time-related issues"
104
+ put "Setting result created_at to current time to avoid this issue"
105
+ # If the result is timestamped old, it is ignored by SimpleCov
106
+ # So we always set the created_at to Time.now so that the ResultMerger
107
+ # doesn't discard any results
108
+ result.created_at = Time.now
109
+ end
110
+ end
111
+
99
112
  def output_result_html(merged_result)
100
113
  # Format merged result with html
101
114
  html_formatter = SimpleCov::Formatter::HTMLFormatter.new
@@ -108,8 +121,8 @@ class CoverageReporter
108
121
  codeclimate_formatter.format(merged_result)
109
122
  end
110
123
 
111
- # Internal: Debug function, in use to try to determine why codeclimate
112
- # is marking some lines of comments as "relevant" lines.
124
+ # Internal: Debug function, in use to log the exact file which is sent to codeclimate
125
+ # for use when troubleshooting.
113
126
  def store_code_climate_payload(merged_result)
114
127
  ENV["CODECLIMATE_TO_FILE"] = "true"
115
128
  codeclimate_formatter = CodeClimate::TestReporter::Formatter.new
@@ -1,2 +1,3 @@
1
+ require "codeclimate_circle_ci_coverage/version"
1
2
  require "codeclimate_circle_ci_coverage/patch_simplecov"
2
3
  require "codeclimate_circle_ci_coverage/coverage_reporter"
@@ -1,9 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CoverageReporter do
4
- describe "#initial_test" do
5
- it "passes" do
6
- expect(1).to eq(1)
4
+ let(:reporter) { described_class.new("master") }
5
+
6
+ describe "#run" do
7
+ it "returns false on mismatch branch names" do
8
+ allow(reporter).to receive(:current_branch).and_return("develop")
9
+ expect(reporter.run).to be_falsey
10
+ end
11
+
12
+ it "returns false on incorrect node number" do
13
+ allow(reporter).to receive(:current_branch).and_return("master")
14
+ allow(reporter).to receive(:current_node).and_return(1)
15
+ expect(reporter.run).to be_falsey
16
+ end
17
+
18
+ it "returns true when branch and node are correct" do
19
+ allow(reporter).to receive(:current_branch).and_return("master")
20
+ allow(reporter).to receive(:current_node).and_return(0)
21
+ expect(reporter.run).to be_truthy
7
22
  end
8
23
  end
9
24
  end
data/spec/spec_helper.rb CHANGED
@@ -1,98 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
2
  require 'codeclimate_circle_ci_coverage'
2
-
3
- # This file was generated by the `rspec --init` command. Conventionally, all
4
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
- # The generated `.rspec` file contains `--require spec_helper` which will cause
6
- # this file to always be loaded, without a need to explicitly require it in any
7
- # files.
8
- #
9
- # Given that it is always loaded, you are encouraged to keep this file as
10
- # light-weight as possible. Requiring heavyweight dependencies from this file
11
- # will add to the boot time of your test suite on EVERY test run, even for an
12
- # individual file that may not need all of that loaded. Instead, consider making
13
- # a separate helper file that requires the additional dependencies and performs
14
- # the additional setup, and require it from the spec files that actually need
15
- # it.
16
- #
17
- # The `.rspec` file also contains a few flags that are not defaults but that
18
- # users commonly want.
19
- #
20
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
- RSpec.configure do |config|
22
- # rspec-expectations config goes here. You can use an alternate
23
- # assertion/expectation library such as wrong or the stdlib/minitest
24
- # assertions if you prefer.
25
- config.expect_with :rspec do |expectations|
26
- # This option will default to `true` in RSpec 4. It makes the `description`
27
- # and `failure_message` of custom matchers include text for helper methods
28
- # defined using `chain`, e.g.:
29
- # be_bigger_than(2).and_smaller_than(4).description
30
- # # => "be bigger than 2 and smaller than 4"
31
- # ...rather than:
32
- # # => "be bigger than 2"
33
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
- end
35
-
36
- # rspec-mocks config goes here. You can use an alternate test double
37
- # library (such as bogus or mocha) by changing the `mock_with` option here.
38
- config.mock_with :rspec do |mocks|
39
- # Prevents you from mocking or stubbing a method that does not exist on
40
- # a real object. This is generally recommended, and will default to
41
- # `true` in RSpec 4.
42
- mocks.verify_partial_doubles = true
43
- end
44
-
45
- # The settings below are suggested to provide a good initial experience
46
- # with RSpec, but feel free to customize to your heart's content.
47
- =begin
48
- # These two settings work together to allow you to limit a spec run
49
- # to individual examples or groups you care about by tagging them with
50
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
- # get run.
52
- config.filter_run :focus
53
- config.run_all_when_everything_filtered = true
54
-
55
- # Allows RSpec to persist some state between runs in order to support
56
- # the `--only-failures` and `--next-failure` CLI options. We recommend
57
- # you configure your source control system to ignore this file.
58
- config.example_status_persistence_file_path = "spec/examples.txt"
59
-
60
- # Limits the available syntax to the non-monkey patched syntax that is
61
- # recommended. For more details, see:
62
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
63
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
65
- config.disable_monkey_patching!
66
-
67
- # This setting enables warnings. It's recommended, but in some cases may
68
- # be too noisy due to issues in dependencies.
69
- config.warnings = true
70
-
71
- # Many RSpec users commonly either run the entire suite or an individual
72
- # file, and it's useful to allow more verbose output when running an
73
- # individual spec file.
74
- if config.files_to_run.one?
75
- # Use the documentation formatter for detailed output,
76
- # unless a formatter has already been configured
77
- # (e.g. via a command-line flag).
78
- config.default_formatter = 'doc'
79
- end
80
-
81
- # Print the 10 slowest examples and example groups at the
82
- # end of the spec run, to help surface which specs are running
83
- # particularly slow.
84
- config.profile_examples = 10
85
-
86
- # Run specs in random order to surface order dependencies. If you find an
87
- # order dependency and want to debug it, you can fix the order by providing
88
- # the seed, which is printed after each run.
89
- # --seed 1234
90
- config.order = :random
91
-
92
- # Seed global randomization in this process using the `--seed` CLI option.
93
- # Setting this allows you to use `--seed` to deterministically reproduce
94
- # test failures related to randomization by passing the same `--seed` value
95
- # as the one that triggered the failure.
96
- Kernel.srand config.seed
97
- =end
98
- end
metadata CHANGED
@@ -1,71 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate_circle_ci_coverage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Dunlop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: simplecov
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '0.11'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '0.11'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rubocop
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ~>
59
+ - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '0'
61
+ version: '10.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ~>
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '0'
68
+ version: '10.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ~>
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
60
88
  - !ruby/object:Gem::Version
61
- version: '3.2'
89
+ version: '0.38'
62
90
  type: :development
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
- - - ~>
94
+ - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: '3.2'
96
+ version: '0.38'
69
97
  description: A set of tools to support reporting SimpleCov Coverage to CodeClimate
70
98
  with Parallel tests on CircleCI
71
99
  email: robin@dunlopweb.com
@@ -90,17 +118,17 @@ require_paths:
90
118
  - lib
91
119
  required_ruby_version: !ruby/object:Gem::Requirement
92
120
  requirements:
93
- - - ! '>='
121
+ - - ">="
94
122
  - !ruby/object:Gem::Version
95
123
  version: '0'
96
124
  required_rubygems_version: !ruby/object:Gem::Requirement
97
125
  requirements:
98
- - - ! '>='
126
+ - - ">="
99
127
  - !ruby/object:Gem::Version
100
128
  version: '0'
101
129
  requirements: []
102
130
  rubyforge_project:
103
- rubygems_version: 2.4.6
131
+ rubygems_version: 2.4.8
104
132
  signing_key:
105
133
  specification_version: 4
106
134
  summary: CodeClimate Code Coverage reporting script for CircleCI