minitest_rollbar 0.2.4 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9b2051548b4953111f13e58d930a87dfdf8eea18
4
- data.tar.gz: d08d68ff4a90fc65d991789af15ad63a6e07a5f0
2
+ SHA256:
3
+ metadata.gz: c9610c9e587b99d002297b5a35cd47ff746b26918fe284ace66c5ea3ac711f76
4
+ data.tar.gz: 78cc79d7cbd79c6a03d87e73ea5070d3c8a675e4d45805b9c75957fa6cce8a92
5
5
  SHA512:
6
- metadata.gz: db12c5079c8250081b4f968bf900196535653ec9598dfc6ec90db0d502d784221940ad80ebe3d8e3440a8355ee413098aea9eb9a97707bea2b860f232baa6d5a
7
- data.tar.gz: 16cceac41e0442b16a840a7588ce97f798efaea8dcf16b55fc1daf0a9ae1d521c64542d7b1cd255fb3352d428dc81c47b6dd147868c0197fe351b806a1f6386b
6
+ metadata.gz: f59643be2d588a7466b40cd5a8afc68cda0701ebc05477af027c0387610542e17919c2c6f6f9d8d056f386d7db19791fca7fffe138987706dbea83fe8257d264
7
+ data.tar.gz: 35a5a643b94a4809ae4dd71bc9f779d2f855e22c8d5110632d954ec46b44f97bb773623f5b0ff7163b032b2eca5f2fe46c9f68249534f524d9dc0c07835b20cc
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org' do
4
+ gem 'appraisal', '>= 2.3', '< 3'
5
+ gem 'bundler', '>= 1.17.3', '< 3'
6
+ gem 'minitest', '>= 5.8', '< 6'
7
+ gem 'mocha', '>= 1.11', '< 2'
8
+ gem 'rake', '>= 13', '< 14'
9
+ gem 'rubocop', '>= 0.91', '< 1'
10
+ gem 'rubocop-minitest', '>= 0.10', '< 1'
11
+ gem 'simplecov', '>= 0.18', '< 1', group: :test, require: false
12
+ end
13
+
14
+ gemspec
@@ -1,22 +1,20 @@
1
- Copyright (c) 2016, AppFolio, Inc.
2
- All rights reserved.
1
+ Copyright (c) 2016-2020 AppFolio inc
3
2
 
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
6
10
 
7
- 1. Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
- 2. Redistributions in binary form must reproduce the above copyright notice,
10
- this list of conditions and the following disclaimer in the documentation
11
- and/or other materials provided with the distribution.
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
12
13
 
13
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,42 +1,52 @@
1
- # Minitest-rollbar
1
+ # MinitestRollbar
2
2
 
3
- Minitest-rollbar is a gem to log test exceptions to rollbar. This is useful in
4
- a CI environment to gather statistics on common exceptions that could indicate
5
- infrastructer related issues.
3
+ minitest_rollbar is a gem to log test exceptions to rollbar. This is useful in a CI environment to gather statistics on
4
+ common exceptions that could indicate infrastructer related issues.
6
5
 
7
6
  ## Installation
8
7
 
9
8
  Add this line to your application's Gemfile:
10
9
 
11
10
  ```ruby
12
- gem 'minitest_rollbar'
11
+ gem 'minitest_rollbar'
13
12
  ```
14
13
 
15
14
  And then execute:
16
15
 
17
- $ bundle
16
+ ```bash
17
+ $ bundle install
18
+ ```
18
19
 
19
20
  Or install it yourself as:
20
21
 
21
- $ gem install minitest_rollbar
22
+ ```bash
23
+ $ gem install minitest_rollbar
24
+ ```
22
25
 
23
26
  ## Usage
24
27
 
25
- Require necessary files on test_helper:
26
-
27
- require 'minitest_rollbar'
28
+ Require necessary files in the test_helper:
28
29
 
29
- Set up authentication token by:
30
+ ```ruby
31
+ require 'minitest_rollbar'
32
+ ```
30
33
 
31
- MinitestRollbar.access_token = {YOUR_TOKEN}
34
+ Get a reporter with access_token and ssl policy using:
32
35
 
33
- By default we try to group occurrence by string returned by exception.inspect (Concatenate exception class name and message). We generate a fingerprint for that. To use rollbar's [default](https://rollbar.com/docs/grouping-algorithm/) default grouping algorithm, do
36
+ ```ruby
37
+ MinitestRollbar::RollbarReporter.new(rollbar_config: { verify_ssl_peer: false, access_token: 'whatever' })
38
+ ```
34
39
 
35
- MinitestRollbar.use_default_grouping = true
40
+ By default, occurrences are grouped by string and returned by exception.inspect (Concatenate exception class name and
41
+ message). We generate a fingerprint for that. To use rollbar's [default](https://rollbar.com/docs/grouping-algorithm/)
42
+ grouping algorithm use:
36
43
 
44
+ ```ruby
45
+ MinitestRollbar.use_default_grouping = true
46
+ ```
37
47
 
38
48
  ## License
39
49
 
40
- This gem is available under the Simplified BSD License.
50
+ This gem is available under the MIT License.
41
51
 
42
- * Copyright (c), 2016, AppFolio, Inc.
52
+ * Copyright (c), 2016-2020, AppFolio, Inc.
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ warn e.message
9
+ warn 'Run `bundle install` to install missing gems'
10
+ exit e.status_code
11
+ end
12
+
13
+ require 'rake/testtask'
14
+
15
+ Rake::TestTask.new(:test) do |test|
16
+ test.libs << 'test'
17
+ test.pattern = 'test/**/*_test.rb'
18
+ test.verbose = true
19
+ end
20
+
21
+ task default: :test
@@ -1,2 +1,8 @@
1
- require 'minitest_rollbar/reporters'
2
- require 'minitest_rollbar/version'
1
+ # frozen_string_literal: true
2
+
3
+ require 'rollbar'
4
+ require 'minitest/reporters'
5
+
6
+ module MinitestRollbar
7
+ autoload :RollbarReporter, 'minitest_rollbar/rollbar_reporter'
8
+ end
@@ -1,46 +1,41 @@
1
- require 'rollbar'
2
- require 'minitest/reporters'
1
+ # frozen_string_literal: true
3
2
 
4
3
  module MinitestRollbar
5
- class << self
6
- attr_accessor :access_token
4
+ class RollbarReporter < Minitest::Reporters::BaseReporter
7
5
  attr_accessor :use_default_grouping
8
- end
9
6
 
10
- class RollbarReporter < Minitest::Reporters::BaseReporter
11
7
  def initialize(options = {})
12
- super
8
+ @rollbar_config = options.delete(:rollbar_config) || {}
9
+
10
+ raise StandardError.new('Must set rollbar access token') if @rollbar_config[:access_token].nil?
11
+
12
+ super(options)
13
+
13
14
  @sequential_exception_count = 0
14
- # Inspect will return ExceptionType + Message.
15
- # E.g #<Selenium::WebDriver::Error::NoSuchWindowError: Window not found. The browser window may have been closed.>
16
- # Use this as a criteria for log batch grouping
15
+ @use_default_grouping = false
17
16
  @previous_exception_inspect_result = nil
18
17
  @previous_exception = nil
19
18
 
20
- raise 'Must set rollbar access token' if MinitestRollbar.access_token.nil?
21
- Rollbar.configure do |config|
22
- config.access_token = MinitestRollbar.access_token
23
- config.verify_ssl_peer = false
24
- end
19
+ # Rollbar global setting, notifier instance won't report if this is not set
20
+ Rollbar.configuration.enabled = true
25
21
  end
26
22
 
27
23
  def record(result)
28
24
  super
29
25
  if result.error?
30
26
  current_exception = result.failure.exception
31
- current_exception_inspect_result = current_exception.inspect
32
27
 
33
28
  if @previous_exception_inspect_result.nil?
34
29
  record_new_error(current_exception)
35
- elsif current_exception_inspect_result == @previous_exception_inspect_result
30
+ elsif current_exception.inspect == @previous_exception_inspect_result
36
31
  increment_error_counting
37
32
  else # New exception
38
- report_error_to_rollbar notifier
33
+ report_error_to_rollbar(notifier)
39
34
  record_new_error current_exception
40
35
  end
41
36
  else
42
37
  unless @previous_exception.nil?
43
- report_error_to_rollbar notifier
38
+ report_error_to_rollbar(notifier)
44
39
  reset_error_counting
45
40
  end
46
41
  end
@@ -48,18 +43,39 @@ module MinitestRollbar
48
43
 
49
44
  def report
50
45
  super
51
- if @sequential_exception_count > 0
52
- report_error_to_rollbar notifier
46
+ if @sequential_exception_count.positive?
47
+ report_error_to_rollbar(notifier)
53
48
  reset_error_counting
54
49
  end
55
50
  end
56
51
 
57
52
  private
58
53
 
54
+ def git_commit_hash
55
+ ENV['CIRCLE_SHA1']
56
+ end
57
+
58
+ def build_config_name
59
+ ENV['CIRCLE_JOB']
60
+ end
61
+
59
62
  def notifier
60
- MinitestRollbar.use_default_grouping.nil? ?
61
- Rollbar.scope({count: @sequential_exception_count, fingerprint: @previous_exception_inspect_result}):
62
- Rollbar.scope({count: @sequential_exception_count})
63
+ scope.merge!(fingerprint: @previous_exception_inspect_result) unless @use_default_grouping
64
+
65
+ rollbar_notifier = Rollbar.scope(scope)
66
+
67
+ @rollbar_config.each { |key, value| rollbar_notifier.configuration.send("#{key}=", value) }
68
+
69
+ rollbar_notifier
70
+ end
71
+
72
+ def scope
73
+ @scope ||= {
74
+ environment: 'PossibleInfraFlaky',
75
+ count: @sequential_exception_count,
76
+ commit_hash: git_commit_hash,
77
+ build_config: build_config_name
78
+ }
63
79
  end
64
80
 
65
81
  def report_error_to_rollbar(notifier)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MinitestRollbar
2
- VERSION = '0.2.4'.freeze
4
+ VERSION = '1.0.0'
3
5
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/minitest_rollbar/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'minitest_rollbar'
7
+ spec.version = MinitestRollbar::VERSION
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.authors = ['AppFolio']
10
+ spec.email = ['dev@appfolio.com']
11
+ spec.summary = 'A minitest reporter that logs test exceptions to Rollbar.'
12
+ spec.description = spec.summary
13
+ spec.homepage = 'https://github.com/appfolio/minitest_rollbar'
14
+ spec.licenses = ['MIT']
15
+ spec.files = Dir['**/*'].select { |f| f[%r{^(lib/|Gemfile$|Rakefile|LICENSE.*|README.*|.*gemspec)}] }
16
+ spec.test_files = spec.files.grep(%r{^(test)/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+
21
+ spec.add_dependency('minitest-reporters', ['>= 1', '< 2'])
22
+ spec.add_dependency('rollbar', ['>= 2', '< 4'])
23
+ end
metadata CHANGED
@@ -1,88 +1,76 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest_rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Yuesong Wang
8
- autorequire:
7
+ - AppFolio
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-18 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: minitest-reporters
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.12'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
17
+ - - ">="
25
18
  - !ruby/object:Gem::Version
26
- version: '1.12'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
19
+ version: '1'
20
+ - - "<"
32
21
  - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
22
+ version: '2'
23
+ type: :runtime
35
24
  prerelease: false
36
25
  version_requirements: !ruby/object:Gem::Requirement
37
26
  requirements:
38
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1'
30
+ - - "<"
39
31
  - !ruby/object:Gem::Version
40
- version: '10.0'
32
+ version: '2'
41
33
  - !ruby/object:Gem::Dependency
42
34
  name: rollbar
43
35
  requirement: !ruby/object:Gem::Requirement
44
36
  requirements:
45
- - - "~>"
37
+ - - ">="
46
38
  - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: minitest-reporters
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
39
+ version: '2'
40
+ - - "<"
60
41
  - !ruby/object:Gem::Version
61
- version: '1.0'
42
+ version: '4'
62
43
  type: :runtime
63
44
  prerelease: false
64
45
  version_requirements: !ruby/object:Gem::Requirement
65
46
  requirements:
66
- - - "~>"
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '2'
50
+ - - "<"
67
51
  - !ruby/object:Gem::Version
68
- version: '1.0'
69
- description:
52
+ version: '4'
53
+ description: A minitest reporter that logs test exceptions to Rollbar.
70
54
  email:
71
- - wangyuesong0@qq.com
55
+ - dev@appfolio.com
72
56
  executables: []
73
57
  extensions: []
74
58
  extra_rdoc_files: []
75
59
  files:
60
+ - Gemfile
76
61
  - LICENSE.txt
77
62
  - README.md
63
+ - Rakefile
78
64
  - lib/minitest_rollbar.rb
79
- - lib/minitest_rollbar/reporters.rb
65
+ - lib/minitest_rollbar/rollbar_reporter.rb
80
66
  - lib/minitest_rollbar/version.rb
81
- homepage: https://github.com/appfolio/minitest-rollbar
67
+ - minitest_rollbar.gemspec
68
+ homepage: https://github.com/appfolio/minitest_rollbar
82
69
  licenses:
83
- - BSD-2-Clause
84
- metadata: {}
85
- post_install_message:
70
+ - MIT
71
+ metadata:
72
+ allowed_push_host: https://rubygems.org
73
+ post_install_message:
86
74
  rdoc_options: []
87
75
  require_paths:
88
76
  - lib
@@ -97,9 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
85
  - !ruby/object:Gem::Version
98
86
  version: '0'
99
87
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 2.6.6
102
- signing_key:
88
+ rubygems_version: 3.1.2
89
+ signing_key:
103
90
  specification_version: 4
104
- summary: A minitest reporter that logs testexceptions to Rollbar.
91
+ summary: A minitest reporter that logs test exceptions to Rollbar.
105
92
  test_files: []