coverband 5.0.0.rc.4 → 5.0.0.rc.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +1 -0
- data/changes.md +5 -1
- data/coverband.gemspec +1 -0
- data/lib/coverband/adapters/web_service_store.rb +2 -4
- data/lib/coverband/configuration.rb +54 -50
- data/lib/coverband/reporters/base.rb +1 -2
- data/lib/coverband/version.rb +1 -1
- data/test/coverband/configuration_test.rb +40 -1
- data/test/coverband/integrations/background_test.rb +13 -2
- data/test/jruby_check.rb +1 -1
- data/test/test_helper.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b829c0b4e513f6f04dbc4e4459a2bfbbbfdf5ecb563f7d8e584c6c628082d875
|
4
|
+
data.tar.gz: d3931c93df0c2add11d5cebf98fe26d6df14b4ae987b58edb80d2891f38782f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbae35d24375200cc62e3f191ca3dd001f3be9ef24383ec5508c14dec0e5830dd23107031a8fe093f52615c06b292a91a38ef9fb68d5d54a7834d1b9097dd0ae
|
7
|
+
data.tar.gz: 2e085a9d3a5cd3e23c87508d0e36b4119a6027fe10a164714b4de8b934142a981691214f493e169c6167288cd666e7d7c024a605423597fec1fb6d8e72bc1e89
|
data/.standard.yml
CHANGED
@@ -13,6 +13,7 @@ ignore: # default: []
|
|
13
13
|
- Style/RedundantRegexpEscape # fix later, enforcement changed
|
14
14
|
- Layout/ArrayAlignment # WTF all of master broken from a few changes in rubo
|
15
15
|
- Performance/RegexpMatch # Rubocop / standardrb have this WRONG for Ruby 2.3/2.4 not compatiable
|
16
|
+
- Style/GlobalStdStream # Rubocop / standardrb have this WRONG for Ruby 2.3/2.4 not compatiable
|
16
17
|
- "vendor/**/*"
|
17
18
|
- "pkg/**/*"
|
18
19
|
- "test/**/*":
|
data/changes.md
CHANGED
@@ -61,7 +61,11 @@ Will be the fully modern release that drops maintenance legacy support in favor
|
|
61
61
|
- drops static report support
|
62
62
|
- drops gem support
|
63
63
|
- only loaded web reporter files when required
|
64
|
-
-
|
64
|
+
- configuration improvements
|
65
|
+
- improved load order allowing more time for ENV vars (better dotenv, figaro, rails secrets support)
|
66
|
+
- all config options can be set via coverband config, not requiring ENV var support
|
67
|
+
- deprecation notices on soon to be removed config options
|
68
|
+
- config exceptions on invalid configuration combinations
|
65
69
|
- improved resque patching pattern
|
66
70
|
- improved default ignores
|
67
71
|
- additional adapters
|
data/coverband.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "rack-test"
|
31
31
|
spec.add_development_dependency "rake"
|
32
32
|
spec.add_development_dependency "resque"
|
33
|
+
spec.add_development_dependency "standard", "= 0.2.5"
|
33
34
|
spec.add_development_dependency "standardrb"
|
34
35
|
|
35
36
|
spec.add_development_dependency "coveralls"
|
@@ -3,8 +3,7 @@
|
|
3
3
|
module Coverband
|
4
4
|
module Adapters
|
5
5
|
###
|
6
|
-
# WebServiceStore store a
|
7
|
-
# TODO: add webmock tests
|
6
|
+
# WebServiceStore: store a checkpoint of coverage to a remote service
|
8
7
|
###
|
9
8
|
class WebServiceStore < Base
|
10
9
|
attr_reader :coverband_url, :process_type, :runtime_env, :hostname, :pid
|
@@ -56,8 +55,7 @@ module Coverband
|
|
56
55
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
|
57
56
|
http.request(req)
|
58
57
|
end
|
59
|
-
|
60
|
-
coverage_data
|
58
|
+
JSON.parse(res.body)
|
61
59
|
rescue => e
|
62
60
|
logger&.error "Coverband: Error while retrieving coverage #{e}" if Coverband.configuration.verbose || Coverband.configuration.service_dev_mode
|
63
61
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Coverband
|
4
4
|
class Configuration
|
5
5
|
attr_accessor :root_paths, :root,
|
6
|
-
:
|
6
|
+
:verbose,
|
7
7
|
:reporter, :redis_namespace, :redis_ttl,
|
8
8
|
:background_reporting_enabled,
|
9
9
|
:test_env, :web_enable_clear, :gem_details, :web_debug, :report_on_exit,
|
@@ -11,7 +11,7 @@ module Coverband
|
|
11
11
|
:view_tracker
|
12
12
|
attr_writer :logger, :s3_region, :s3_bucket, :s3_access_key_id,
|
13
13
|
:s3_secret_access_key, :password, :api_key, :service_url, :coverband_timeout, :service_dev_mode,
|
14
|
-
:service_test_mode, :
|
14
|
+
:service_test_mode, :process_type, :track_views, :redis_url,
|
15
15
|
:background_reporting_sleep_seconds, :reporting_wiggle
|
16
16
|
|
17
17
|
attr_reader :track_gems, :ignore, :use_oneshot_lines_coverage
|
@@ -20,7 +20,6 @@ module Coverband
|
|
20
20
|
# TODO: This is is brittle and not a great solution to avoid deploy time
|
21
21
|
# actions polluting the 'runtime' metrics
|
22
22
|
#
|
23
|
-
# * should we skip /bin/rails webpacker:compile ?
|
24
23
|
# * Perhaps detect heroku deployment ENV var opposed to tasks?
|
25
24
|
#####
|
26
25
|
IGNORE_TASKS = ["coverband:clear",
|
@@ -28,6 +27,7 @@ module Coverband
|
|
28
27
|
"coverband:coverage_server",
|
29
28
|
"coverband:migrate",
|
30
29
|
"assets:precompile",
|
30
|
+
"webpacker:compile",
|
31
31
|
"db:version",
|
32
32
|
"db:create",
|
33
33
|
"db:drop",
|
@@ -56,7 +56,6 @@ module Coverband
|
|
56
56
|
@root_paths = []
|
57
57
|
@ignore = IGNORE_DEFAULTS.dup
|
58
58
|
@search_paths = TRACKED_DEFAULT_PATHS.dup
|
59
|
-
@additional_files = []
|
60
59
|
@verbose = false
|
61
60
|
@reporter = "scov"
|
62
61
|
@logger = nil
|
@@ -65,8 +64,6 @@ module Coverband
|
|
65
64
|
@background_reporting_sleep_seconds = nil
|
66
65
|
@test_env = nil
|
67
66
|
@web_enable_clear = false
|
68
|
-
@track_gems = false
|
69
|
-
@gem_details = false
|
70
67
|
@track_views = true
|
71
68
|
@view_tracker = nil
|
72
69
|
@web_debug = false
|
@@ -85,17 +82,19 @@ module Coverband
|
|
85
82
|
@service_dev_mode = nil
|
86
83
|
@service_test_mode = nil
|
87
84
|
@proces_type = nil
|
88
|
-
|
85
|
+
|
86
|
+
@redis_url = nil
|
87
|
+
@redis_namespace = nil
|
88
|
+
@redis_ttl = 2_592_000 # in seconds. Default is 30 days.
|
89
|
+
@reporting_wiggle = nil
|
89
90
|
|
90
91
|
# TODO: these are deprecated
|
91
92
|
@s3_region = nil
|
92
93
|
@s3_bucket = nil
|
93
94
|
@s3_access_key_id = nil
|
94
95
|
@s3_secret_access_key = nil
|
95
|
-
|
96
|
-
@
|
97
|
-
@redis_ttl = 2_592_000 # in seconds. Default is 30 days.
|
98
|
-
@reporting_wiggle = nil
|
96
|
+
@track_gems = false
|
97
|
+
@gem_details = false
|
99
98
|
end
|
100
99
|
|
101
100
|
def logger
|
@@ -110,25 +109,16 @@ module Coverband
|
|
110
109
|
@password || ENV["COVERBAND_PASSWORD"]
|
111
110
|
end
|
112
111
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
def s3_region
|
118
|
-
puts "deprecated, s3 is no longer support"
|
119
|
-
end
|
120
|
-
|
121
|
-
def s3_access_key_id
|
122
|
-
puts "deprecated, s3 is no longer support"
|
123
|
-
end
|
124
|
-
|
125
|
-
def s3_secret_access_key
|
126
|
-
puts "deprecated, s3 is no longer support"
|
127
|
-
end
|
128
|
-
|
112
|
+
# The adjustments here either protect the redis or service from being overloaded
|
113
|
+
# the tradeoff being the delay in when reporting data is available
|
114
|
+
# if running your own redis increasing this number reduces load on the redis CPU
|
129
115
|
def background_reporting_sleep_seconds
|
130
|
-
@background_reporting_sleep_seconds ||= if
|
131
|
-
|
116
|
+
@background_reporting_sleep_seconds ||= if service?
|
117
|
+
# default to 10m for service
|
118
|
+
Coverband.configuration.coverband_env == "production" ? 600 : 60
|
119
|
+
elsif store.is_a?(Coverband::Adapters::HashRedisStore)
|
120
|
+
# Default to 5 minutes if using the hash redis store
|
121
|
+
300
|
132
122
|
else
|
133
123
|
60
|
134
124
|
end
|
@@ -139,7 +129,8 @@ module Coverband
|
|
139
129
|
end
|
140
130
|
|
141
131
|
def store
|
142
|
-
@store ||= if
|
132
|
+
@store ||= if service?
|
133
|
+
raise "invalid configuration: unclear default store coverband expects either api_key or redis_url" if redis_url
|
143
134
|
require "coverband/adapters/web_service_store"
|
144
135
|
Coverband::Adapters::WebServiceStore.new(service_url)
|
145
136
|
else
|
@@ -147,21 +138,18 @@ module Coverband
|
|
147
138
|
end
|
148
139
|
end
|
149
140
|
|
150
|
-
def track_views
|
151
|
-
@track_views ||= service_disabled_dev_test_env? ? false : true
|
152
|
-
end
|
153
|
-
|
154
141
|
def store=(store)
|
155
142
|
raise "Pass in an instance of Coverband::Adapters" unless store.is_a?(Coverband::Adapters::Base)
|
156
|
-
|
157
|
-
|
158
|
-
# This is a safer default for the high server volumes that need the hash store
|
159
|
-
# it should avoid overloading the redis with lots of load
|
160
|
-
@background_reporting_sleep_seconds = 300 if store.is_a?(Coverband::Adapters::HashRedisStore)
|
143
|
+
raise "invalid configuration: only coverband service expects an API Key" if api_key && !store.is_a?(Coverband::Adapters::WebServiceStore)
|
144
|
+
raise "invalid configuration: coverband service shouldn't have redis url set" if redis_url && store.is_a?(Coverband::Adapters::WebServiceStore)
|
161
145
|
|
162
146
|
@store = store
|
163
147
|
end
|
164
148
|
|
149
|
+
def track_views
|
150
|
+
@track_views ||= service_disabled_dev_test_env? ? false : true
|
151
|
+
end
|
152
|
+
|
165
153
|
###
|
166
154
|
# Search Paths
|
167
155
|
###
|
@@ -183,10 +171,6 @@ module Coverband
|
|
183
171
|
@ignore = (@ignore + ignored_array).uniq
|
184
172
|
end
|
185
173
|
|
186
|
-
def track_gems=(_value)
|
187
|
-
puts "gem tracking is deprecated, setting this will be ignored"
|
188
|
-
end
|
189
|
-
|
190
174
|
def current_root
|
191
175
|
@current_root ||= File.expand_path(Coverband.configuration.root).freeze
|
192
176
|
end
|
@@ -203,7 +187,7 @@ module Coverband
|
|
203
187
|
@all_root_patterns ||= all_root_paths.map { |path| /^#{path}/ }.freeze
|
204
188
|
end
|
205
189
|
|
206
|
-
SKIPPED_SETTINGS = %w[@s3_secret_access_key @store]
|
190
|
+
SKIPPED_SETTINGS = %w[@s3_secret_access_key @store @api_key @password]
|
207
191
|
def to_h
|
208
192
|
instance_variables
|
209
193
|
.each_with_object({}) do |var, hash|
|
@@ -221,6 +205,10 @@ module Coverband
|
|
221
205
|
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
|
222
206
|
end
|
223
207
|
|
208
|
+
def redis_url
|
209
|
+
@redis_url ||= ENV["COVERBAND_REDIS_URL"] || ENV["REDIS_URL"]
|
210
|
+
end
|
211
|
+
|
224
212
|
def api_key
|
225
213
|
@api_key ||= ENV["COVERBAND_API_KEY"]
|
226
214
|
end
|
@@ -245,12 +233,12 @@ module Coverband
|
|
245
233
|
@service_dev_mode ||= ENV["COVERBAND_ENABLE_TEST_MODE"] || false
|
246
234
|
end
|
247
235
|
|
248
|
-
def
|
236
|
+
def process_type
|
249
237
|
@process_type ||= ENV["PROCESS_TYPE"] || "unknown"
|
250
238
|
end
|
251
239
|
|
252
|
-
def
|
253
|
-
|
240
|
+
def service?
|
241
|
+
Coverband.coverband_service? || !api_key.nil?
|
254
242
|
end
|
255
243
|
|
256
244
|
def service_disabled_dev_test_env?
|
@@ -258,12 +246,28 @@ module Coverband
|
|
258
246
|
(coverband_env == "development" && !Coverband.configuration.service_dev_mode)
|
259
247
|
end
|
260
248
|
|
261
|
-
|
249
|
+
def s3_bucket
|
250
|
+
puts "deprecated, s3 is no longer support"
|
251
|
+
end
|
262
252
|
|
263
|
-
def
|
264
|
-
|
253
|
+
def s3_region
|
254
|
+
puts "deprecated, s3 is no longer support"
|
255
|
+
end
|
256
|
+
|
257
|
+
def s3_access_key_id
|
258
|
+
puts "deprecated, s3 is no longer support"
|
259
|
+
end
|
260
|
+
|
261
|
+
def s3_secret_access_key
|
262
|
+
puts "deprecated, s3 is no longer support"
|
263
|
+
end
|
264
|
+
|
265
|
+
def track_gems=(_value)
|
266
|
+
puts "gem tracking is deprecated, setting this will be ignored"
|
265
267
|
end
|
266
268
|
|
269
|
+
private
|
270
|
+
|
267
271
|
def redis_store_options
|
268
272
|
{ttl: Coverband.configuration.redis_ttl,
|
269
273
|
redis_namespace: Coverband.configuration.redis_namespace}
|
data/lib/coverband/version.rb
CHANGED
@@ -4,6 +4,7 @@ require File.expand_path("../test_helper", File.dirname(__FILE__))
|
|
4
4
|
|
5
5
|
class BaseTest < Minitest::Test
|
6
6
|
def setup
|
7
|
+
Coverband.configuration.reset
|
7
8
|
super
|
8
9
|
Coverband.configuration.reset
|
9
10
|
Coverband.configure do |config|
|
@@ -52,7 +53,7 @@ class BaseTest < Minitest::Test
|
|
52
53
|
assert_equal current_paths, Coverband.configuration.root_paths
|
53
54
|
end
|
54
55
|
|
55
|
-
test "store raises
|
56
|
+
test "store raises when not set to supported adapter" do
|
56
57
|
Coverband::Collectors::Coverage.instance.reset_instance
|
57
58
|
assert_raises RuntimeError do
|
58
59
|
Coverband.configure do |config|
|
@@ -61,6 +62,44 @@ class BaseTest < Minitest::Test
|
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
65
|
+
test "store defaults to redis store" do
|
66
|
+
Coverband::Collectors::Coverage.instance.reset_instance
|
67
|
+
assert_equal Coverband.configuration.store.class, Coverband::Adapters::RedisStore
|
68
|
+
end
|
69
|
+
|
70
|
+
test "store is a service store when api_key is set" do
|
71
|
+
Coverband::Collectors::Coverage.instance.reset_instance
|
72
|
+
Coverband.configuration.reset
|
73
|
+
Coverband.configure do |config|
|
74
|
+
config.redis_url = nil
|
75
|
+
config.api_key = "test-key"
|
76
|
+
end
|
77
|
+
assert_equal Coverband.configuration.store.class.to_s, "Coverband::Adapters::WebServiceStore"
|
78
|
+
end
|
79
|
+
|
80
|
+
test "store raises when api key set but not set to service" do
|
81
|
+
Coverband::Collectors::Coverage.instance.reset_instance
|
82
|
+
Coverband.configuration.reset
|
83
|
+
assert_raises RuntimeError do
|
84
|
+
Coverband.configure do |config|
|
85
|
+
config.api_key = "test-key"
|
86
|
+
config.redis_url = "redis://localhost:3333"
|
87
|
+
config.store = Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace: "coverband_test")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
test "store raises when api key and redis_url" do
|
93
|
+
Coverband::Collectors::Coverage.instance.reset_instance
|
94
|
+
Coverband.configuration.reset
|
95
|
+
assert_raises RuntimeError do
|
96
|
+
Coverband.configure do |config|
|
97
|
+
config.api_key = "test-key"
|
98
|
+
config.redis_url = "redis://localhost:3333"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
64
103
|
test "use_oneshot_lines_coverage" do
|
65
104
|
refute Coverband.configuration.use_oneshot_lines_coverage
|
66
105
|
|
@@ -12,18 +12,29 @@ class BackgroundTest < Minitest::Test
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
def setup
|
16
|
+
Coverband.configuration.reset
|
17
|
+
super
|
18
|
+
Coverband.configure do |config|
|
19
|
+
config.background_reporting_sleep_seconds = 60
|
20
|
+
Coverband.configuration.reporting_wiggle = 0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
15
24
|
def test_start
|
25
|
+
sleep_seconds = Coverband.configuration.background_reporting_sleep_seconds.to_i
|
16
26
|
Thread.expects(:new).yields.returns(ThreadDouble.new(true))
|
17
27
|
Coverband::Background.expects(:loop).yields
|
18
|
-
Coverband::Background.expects(:sleep).with(
|
28
|
+
Coverband::Background.expects(:sleep).with(sleep_seconds)
|
19
29
|
Coverband::Collectors::Coverage.instance.expects(:report_coverage).once
|
20
30
|
2.times { Coverband::Background.start }
|
21
31
|
end
|
22
32
|
|
23
33
|
def test_start_with_wiggle
|
34
|
+
sleep_seconds = Coverband.configuration.background_reporting_sleep_seconds.to_i
|
24
35
|
Thread.expects(:new).yields.returns(ThreadDouble.new(true))
|
25
36
|
Coverband::Background.expects(:loop).yields
|
26
|
-
Coverband::Background.expects(:sleep).with(
|
37
|
+
Coverband::Background.expects(:sleep).with(sleep_seconds + 5)
|
27
38
|
Coverband::Background.expects(:rand).with(10).returns(5)
|
28
39
|
Coverband.configuration.reporting_wiggle = 10
|
29
40
|
Coverband::Collectors::Coverage.instance.expects(:report_coverage).once
|
data/test/jruby_check.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -45,6 +45,7 @@ module Coverband
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.reset
|
48
|
+
Coverband.configuration.reset
|
48
49
|
Coverband.configuration.redis_namespace = "coverband_test"
|
49
50
|
Coverband.configuration.store.instance_variable_set(:@redis_namespace, "coverband_test")
|
50
51
|
Coverband.configuration.store.class.class_variable_set(:@@path_cache, {})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coverband
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0.rc.
|
4
|
+
version: 5.0.0.rc.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-08-
|
12
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: benchmark-ips
|
@@ -165,6 +165,20 @@ dependencies:
|
|
165
165
|
- - ">="
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: standard
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - '='
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: 0.2.5
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - '='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: 0.2.5
|
168
182
|
- !ruby/object:Gem::Dependency
|
169
183
|
name: standardrb
|
170
184
|
requirement: !ruby/object:Gem::Requirement
|