coverband 4.1.0 → 4.2.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.
Files changed (77) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +6 -1
  3. data/.travis.yml +4 -2
  4. data/README.md +74 -51
  5. data/Rakefile +1 -1
  6. data/changes.md +45 -25
  7. data/coverband.gemspec +4 -0
  8. data/lib/coverband/adapters/base.rb +24 -1
  9. data/lib/coverband/adapters/redis_store.rb +29 -8
  10. data/lib/coverband/at_exit.rb +19 -2
  11. data/lib/coverband/collectors/coverage.rb +35 -73
  12. data/lib/coverband/collectors/delta.rb +67 -0
  13. data/lib/coverband/integrations/background.rb +4 -3
  14. data/lib/coverband/integrations/rack_server_check.rb +4 -1
  15. data/lib/coverband/integrations/resque.rb +4 -1
  16. data/lib/coverband/reporters/base.rb +21 -14
  17. data/lib/coverband/reporters/html_report.rb +40 -15
  18. data/lib/coverband/reporters/web.rb +29 -6
  19. data/lib/coverband/utils/html_formatter.rb +20 -4
  20. data/lib/coverband/utils/railtie.rb +8 -0
  21. data/lib/coverband/utils/result.rb +3 -2
  22. data/lib/coverband/utils/results.rb +63 -0
  23. data/lib/coverband/utils/source_file.rb +5 -0
  24. data/lib/coverband/version.rb +1 -1
  25. data/lib/coverband.rb +23 -3
  26. data/public/application.css +5 -0
  27. data/public/application.js +108 -1644
  28. data/public/dependencies.js +1581 -0
  29. data/public/favicon.png +0 -0
  30. data/test/benchmarks/benchmark.rake +31 -0
  31. data/test/benchmarks/coverage_fork.sh +37 -0
  32. data/test/{unit/adapters_base_test.rb → coverband/adapters/base_test.rb} +1 -1
  33. data/test/{unit/adapters_file_store_test.rb → coverband/adapters/file_store_test.rb} +1 -1
  34. data/test/{unit/adapters_redis_store_test.rb → coverband/adapters/redis_store_test.rb} +27 -10
  35. data/test/coverband/collectors/coverage_test.rb +73 -0
  36. data/test/coverband/collectors/delta_test.rb +52 -0
  37. data/test/{unit → coverband}/coverband_test.rb +7 -0
  38. data/test/coverband/integrations/background_test.rb +31 -0
  39. data/test/{unit → coverband/integrations}/middleware_test.rb +2 -1
  40. data/test/{unit/rack_server_checkout_test.rb → coverband/integrations/rack_server_check_test.rb} +1 -1
  41. data/test/{unit → coverband/integrations}/resque_worker_test.rb +9 -3
  42. data/test/{unit/reports_base_test.rb → coverband/reporters/base_test.rb} +5 -5
  43. data/test/{unit/reports_console_test.rb → coverband/reporters/console_test.rb} +2 -2
  44. data/test/{unit/reports_html_test.rb → coverband/reporters/html_test.rb} +7 -8
  45. data/test/{unit/reports_web_test.rb → coverband/reporters/web_test.rb} +2 -2
  46. data/test/{unit → integration}/full_stack_test.rb +10 -8
  47. data/test/{unit → integration}/rails_full_stack_test.rb +23 -4
  48. data/test/rails4_dummy/config/application.rb +1 -1
  49. data/test/rails4_dummy/config/coverband.rb +4 -1
  50. data/test/rails4_dummy/tmp/.keep +0 -0
  51. data/test/rails5_dummy/config/application.rb +1 -1
  52. data/test/rails5_dummy/config/coverband.rb +3 -1
  53. data/test/rails5_dummy/tmp/.keep +0 -0
  54. data/test/rails_test_helper.rb +13 -8
  55. data/test/test_helper.rb +9 -13
  56. data/test/unique_files.rb +23 -0
  57. data/views/file_list.erb +9 -0
  58. data/views/gem_list.erb +1 -1
  59. data/views/layout.erb +4 -3
  60. data/views/source_file.erb +16 -4
  61. data/views/source_file_loader.erb +7 -0
  62. metadata +100 -59
  63. data/test/unit/background_test.rb +0 -28
  64. data/test/unit/collectors_coverage_test.rb +0 -53
  65. data/test/unit/rails_gems_full_stack_test.rb +0 -36
  66. /data/test/{unit → coverband}/at_exit_test.rb +0 -0
  67. /data/test/{unit → coverband}/configuration_test.rb +0 -0
  68. /data/test/{unit → coverband/integrations}/test_resque_job.rb +0 -0
  69. /data/test/{unit → coverband}/utils/file_groups_test.rb +0 -0
  70. /data/test/{unit → coverband}/utils/file_list_test.rb +0 -0
  71. /data/test/{unit → coverband}/utils/gem_list_test.rb +0 -0
  72. /data/test/{unit → coverband}/utils/lines_classifier_test.rb +0 -0
  73. /data/test/{unit → coverband}/utils/result_test.rb +0 -0
  74. /data/test/{unit → coverband}/utils/s3_report_test.rb +0 -0
  75. /data/test/{unit → coverband}/utils/source_file_line_test.rb +0 -0
  76. /data/test/{unit → coverband}/utils/source_file_test.rb +0 -0
  77. /data/test/{unit/dog.rb → dog.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b7070c0b3648d9f4fe856175711373dbddc19df4
4
- data.tar.gz: d31f4e2ae34e9ad28cbf93fa6e7bcebeb99a9c52
2
+ SHA256:
3
+ metadata.gz: 1e214b1bd6119046657daa64ed6d69f77f821c6c670b72e98d307ede5f08e61f
4
+ data.tar.gz: 469d9470799f90b5b52d53d3a630fae75b3b6bff0390375987902331878f530e
5
5
  SHA512:
6
- metadata.gz: 630244e791fe41a7f5d53b89a6d2782764252fd6f8f7eecb37eab9259928bf422e1a2a6282dc046e0c6fdbc7d2b3581c8a1eeb9584670848fc1b678b5ab0629e
7
- data.tar.gz: b03947618d4e2b51a27a84438de3c5cc5d1da4f9a5024e4d9d6cf00d39f652874ecc0f0c0ae2a6d475b90a8bfa792c133a01696084f337f4c7146d567a8044f9
6
+ metadata.gz: f1b0f503941ab9dbc2dee6a184fe6d6d937a5f505a5c9112ae7343197372586d6cb42df758f24effde0ee30fb359c0e2e651c64a1f5ee4c9a588a4499683dc73
7
+ data.tar.gz: ee700abfe4c730011dcc5c1c8521f55a2cc7ec5149e44b08187c8d09419023160a0f7c8aaba4b2aa0bb405eb13f4aeee1d8ce9cabce4860738d4ea94cac63c04
data/.gitignore CHANGED
@@ -5,6 +5,8 @@
5
5
  .yardoc
6
6
  .idea/
7
7
  .ruby-version
8
+ assets/.DS_Store
9
+ .DS_Store
8
10
  Gemfile*lock
9
11
  InstalledFiles
10
12
  _yardoc
@@ -16,7 +18,10 @@ rdoc
16
18
  spec/reports
17
19
  test/tmp
18
20
  test/version_tmp
19
- tmp
21
+ /tmp/
22
+ temp_results
20
23
  .byebug_history
21
24
  .env
22
25
  log/
26
+ test/unique_files
27
+ test/rails5_dummy/tmp
data/.travis.yml CHANGED
@@ -3,7 +3,7 @@ rvm:
3
3
  - "2.3"
4
4
  - "2.4"
5
5
  - "2.5"
6
- - "2.6"
6
+ - "2.6.1"
7
7
  gemfile:
8
8
  - Gemfile
9
9
  - Gemfile.rails4
@@ -11,7 +11,9 @@ services:
11
11
  - redis-server
12
12
  before_install:
13
13
  - echo 'this is a hack to clear default bundler and force bundler 1.17.3'
14
+ - ls /home/travis/.rvm/gems/
14
15
  - rm /home/travis/.rvm/gems/ruby-2.3.7@global/specifications/bundler-2.0.1.gemspec || true
16
+ - rm /home/travis/.rvm/gems/ruby-2.5.4@global/specifications/bundler-2.0.1.gemspec || true
15
17
  - gem uninstall bundler || true
16
18
  - gem install bundler -v '1.17.3'
17
- - bundler --version
19
+ - bundler --version
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ <img src="https://raw.github.com/danmayer/coverband/master/docs/assets/logo/heads.svg?sanitize=true" width='300'>
2
+
1
3
  # Coverband
2
4
 
3
5
  [![Build Status](https://travis-ci.org/danmayer/coverband.svg?branch=master)](https://travis-ci.org/danmayer/coverband)
@@ -15,29 +17,31 @@
15
17
 
16
18
  A gem to measure production code usage, showing a counter for the number of times each line of code that is executed. Coverband allows easy configuration to collect and report on production code usage. It reports in the background via a thread or can be used as Rack middleware, or manually configured to meet any need.
17
19
 
18
- __Note:__ Coverband is not intended for test code coverage, for that we recommended using [SimpleCov](https://github.com/colszowka/simplecov).
20
+ **Note:** Coverband is not intended for test code coverage, for that we recommended using [SimpleCov](https://github.com/colszowka/simplecov).
19
21
 
20
22
  ## Key Features
21
23
 
22
24
  The primary goal of Coverband is giving deep insight into your production runtime usage of your application code, while having the least impact on performance possible.
23
25
 
24
- * Low performance overhead
25
- * Very simple setup and configuration
26
- * Out of the box support for all standard code execution paths (web, cron, background jobs, rake tasks, etc)
27
- * Easy to understand actionable insights from the report
28
- * Development mode, offers deep insight of code usage details (number of LOC execution during single request, etc) during development.
29
- * Mountable web interface to easily share reports
26
+ - Low performance overhead
27
+ - Very simple setup and configuration
28
+ - Out of the box support for all standard code execution paths (web, cron, background jobs, rake tasks, etc)
29
+ - Easy to understand actionable insights from the report
30
+ - Development mode, offers deep insight of code usage details (number of LOC execution during single request, etc) during development.
31
+ - Mountable web interface to easily share reports
30
32
 
31
33
  # Installation
32
34
 
33
35
  ## Redis
34
36
 
35
- Coverband stores coverage data in Redis. The Redis endpoint is looked for in this order:
37
+ Coverband stores coverage data in Redis. The Redis endpoint is looked for in this order:
36
38
 
37
39
  1. `ENV['COVERBAND_REDIS_URL']`
38
40
  2. `ENV['REDIS_URL']`
39
41
  3. `localhost`
40
42
 
43
+ The redis store can also be explicitly defined within the coverband.rb. See [advanced config](#advanced-config).
44
+
41
45
  ## Gem Installation
42
46
 
43
47
  Add this line to your application's `Gemfile`, remember to `bundle install` after updating:
@@ -46,10 +50,11 @@ Add this line to your application's `Gemfile`, remember to `bundle install` afte
46
50
  gem 'coverband'
47
51
  ```
48
52
 
49
- ## Rails
53
+ If [tracking gem usage](#collecting-gem--library-usage), be sure to include coverband before other gems you would like to track.
50
54
 
51
- The Railtie integration means you shouldn't need to do anything anything else. If you have an issue with that, please [file an issue](https://github.com/danmayer/coverband/issues).
55
+ ## Rails
52
56
 
57
+ The Railtie integration means you shouldn't need to do anything anything else other than ensure coverband is required after rails within your Gemfile.
53
58
 
54
59
  ## Sinatra
55
60
 
@@ -73,7 +78,7 @@ Rails.application.routes.draw do
73
78
  end
74
79
  ```
75
80
 
76
- But don't forget to *protect your source code with proper authentication*. Something like this when using devise:
81
+ But don't forget to _protect your source code with proper authentication_. Something like this when using devise:
77
82
 
78
83
  ```ruby
79
84
  Rails.application.routes.draw do
@@ -88,11 +93,12 @@ end
88
93
  The web endpoint is a barebones endpoint that you can either expose direct (after authentication) or you can just link to the actions you wish to expose. The index is intended as a example to showcase all the features.
89
94
 
90
95
  ![image](https://raw.github.com/danmayer/coverband/master/docs/coverband_web_update.png)
96
+
91
97
  > The web index as available on the Coverband Demo site
92
98
 
93
- * __force coverage collection:__ This triggers coverage collection on the current webserver process
94
- * __reload Coverband files:__ This has Coverband reload files as configured (force reload of some files that might not capture Coverage on boot). This can be used to reload files on demand.
95
- * __clear coverage report:__ This will clear the coverage data. This wipes out all collected data (__dangerous__)
99
+ - **force coverage collection:** This triggers coverage collection on the current webserver process
100
+ - **reload Coverband files:** This has Coverband reload files as configured (force reload of some files that might not capture Coverage on boot). This can be used to reload files on demand.
101
+ - **clear coverage report:** This will clear the coverage data. This wipes out all collected data (**dangerous**)
96
102
 
97
103
  ### Rake Tasks
98
104
 
@@ -114,17 +120,16 @@ Details on an example Sinatra app
114
120
 
115
121
  # Verify Correct Installation
116
122
 
117
- * boot up your application
118
- * run app and hit a controller (via a web request, at least one request must complete)
119
- * run `rake coverband:coverage` this will show app initialization coverage
120
- * make another request, or enough that your reporting frequency will trigger
121
- * run `rake coverband:coverage` and you should see coverage increasing for the endpoints you hit.
123
+ - boot up your application
124
+ - run app and hit a controller (via a web request, at least one request must complete)
125
+ - run `rake coverband:coverage` this will show app initialization coverage
126
+ - make another request, or enough that your reporting frequency will trigger
127
+ - run `rake coverband:coverage` and you should see coverage increasing for the endpoints you hit.
122
128
 
123
129
  # Coverband Demo
124
130
 
125
131
  Take Coverband for a spin on the live Heroku deployed [Coverband Demo](https://coverband-demo.herokuapp.com/). The [full source code for the demo](https://github.com/danmayer/coverband_demo) is available to help with installation, configuration, and understanding of basic usage.
126
132
 
127
-
128
133
  ### Example apps
129
134
 
130
135
  - [Rails 5.2.x App](https://github.com/danmayer/coverband_demo)
@@ -133,14 +138,12 @@ Take Coverband for a spin on the live Heroku deployed [Coverband Demo](https://c
133
138
 
134
139
  # Advanced Config
135
140
 
136
-
137
141
  If you need to configure coverband, this can be done by creating a `config/coverband.rb` file relative to your project root.
138
142
 
139
- * See [lib/coverband/configuration.rb](https://github.com/danmayer/coverband/blob/master/lib/coverband/configuration.rb) for all options
140
- * By default Coverband will try to stored data to Redis
141
- * Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
143
+ - See [lib/coverband/configuration.rb](https://github.com/danmayer/coverband/blob/master/lib/coverband/configuration.rb) for all options
144
+ - By default Coverband will try to stored data to Redis \* Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
142
145
 
143
- Below is an example config file for a Rails 5 app:
146
+ Below is an example config file for a Rails 5 app:
144
147
 
145
148
  ```ruby
146
149
  #config/coverband.rb
@@ -166,14 +169,12 @@ end
166
169
  Sometimes you have files that are known to be valuable perhaps in other environments or something that is just run very infrequently. Opposed to having to mentally filter them out of the report, you can just have them ignored in the Coverband reporting by using `config.ignore` as shown below. Ignore takes a string but can also match with regex rules see how below ignores all rake tasks as an example.
167
170
 
168
171
  ```
169
- config.ignore = ['config/application.rb',
172
+ config.ignore += ['config/application.rb',
170
173
  'config/boot.rb',
171
174
  'config/puma.rb',
172
175
  'config/schedule.rb',
173
- 'config/environments/test.rb',
174
- 'config/environments/development.rb',
175
- 'config/environments/staging.rb',
176
- 'config/environments/production.rb',
176
+ 'bin/*'
177
+ 'config/environments/*',
177
178
  'lib/tasks/*']
178
179
  ```
179
180
 
@@ -204,8 +205,7 @@ Between the release of 4.0 and 4.1 our data format changed. This resets all your
204
205
 
205
206
  `rake coverband:migrate`
206
207
 
207
- * We will be working to support migrations going forward, when possible
208
-
208
+ - We will be working to support migrations going forward, when possible
209
209
 
210
210
  ### Clear Coverage
211
211
 
@@ -246,21 +246,44 @@ Coverband.configure do |config|
246
246
  config.safe_reload_files = ['config/coverband.rb']
247
247
  end
248
248
  ```
249
- By adding any files above you will get reporting on those files as part of your coverage runtime report. The files are reloaded when Coverband first starts, you can also trigger a reload via the web interface.
250
249
 
250
+ By adding any files above you will get reporting on those files as part of your coverage runtime report. The files are reloaded when Coverband first starts, you can also trigger a reload via the web interface.
251
251
 
252
252
  ### Collecting Gem / Library Usage
253
253
 
254
- By default Coverband has assumed you are trying to track your application code usage and not all the supporting framework and library (Gems) code usage. There are reasons to track library usage though such as finding out which Gems aren't actually being used within production. See some of the discussion on [issue 21](https://github.com/danmayer/coverband/issues/21).
254
+ Gem usage can be tracked by enabling the `track_gems` config.
255
+
256
+ ```
257
+ Coverband.configure do |config|
258
+ config.track_gems = true
259
+ end
260
+ ```
261
+
262
+ The `track_gems` feature exposes a Gems tab in the report which prints out the percentage usage of each Gem. See demo [here](https://coverband-demo.herokuapp.com/coverage?#_Gems).
263
+
264
+ When tracking gems, it is important that `Coverband#start` is called before the gems to be tracked are required. Since `Coverband#start` is automatically called by default when coverband is required, list coverband before the other gems to be tracked within your Gemfile. The exception to this are gems like rails and resque. Since coverband has some specific intergrations for these frameworks, these two gems should be required first.
265
+
266
+ The track_gems config only exposes the overall usage of a gem. In order to see the detail of each file, enable the `gem_details` flag.
267
+
268
+ ```
269
+ Coverband.configure do |config|
270
+ config.track_gems = true
271
+ config.gem_details = true
272
+ end
273
+ ```
274
+
275
+ This flag exposes line by line usage of gem files. Unfortunately due to the way the coverband report is currently rendered, enabling `gem_details` slows down viewing of the coverage report in the browser and is not yet recommended.
276
+
277
+ ### Manually Starting Coverband
255
278
 
256
- How to collect gem usage with Coverband:
279
+ Coverband starts on require of the the library which is usually done within the Gemfile. This can be disabled by setting the `COVERBAND_DISABLE_AUTO_START` environment variable. This environment variable can be useful to toggle coverband on and off in certain environments.
257
280
 
258
- * use the `safe_reload_files` feature to add the path of all gem files you wish to track
259
- * --- or ---
260
- * ensure you call `require 'coverband'` which triggers `Coverband.start` before loading all your gems
261
- * while possible this is currently hard as Rails and most environments load your whole Gemfile
262
- * we are looking for an improve and easier way to support this.
281
+ In order to start coverband manually yourself when this flag is enabled, call `Coverband.configure` followed by `Coverband.start`.
263
282
 
283
+ ```ruby
284
+ Coverband.configure
285
+ Coverband.start
286
+ ```
264
287
 
265
288
  ### Verbose Debug / Development Mode
266
289
 
@@ -288,8 +311,8 @@ If you are trying to debug locally wondering what code is being run during a req
288
311
 
289
312
  # Prerequisites
290
313
 
291
- * Coverband 3.0.X+ requires Ruby 2.3+
292
- * Coverband currently requires Redis for production usage
314
+ - Coverband 3.0.X+ requires Ruby 2.3+
315
+ - Coverband currently requires Redis for production usage
293
316
 
294
317
  # Contributing To Coverband
295
318
 
@@ -306,18 +329,18 @@ If you are working on adding features, PRs, or bugfixes to Coverband this sectio
306
329
 
307
330
  If you submit a change please make sure the tests and benchmarks are passing.
308
331
 
309
- * run tests:
310
- * `bundle exec rake`
311
- * `BUNDLE_GEMFILE=Gemfile.rails4 bundle exec rake` (Same tests using rails 4 instead of 5)
312
- * view test coverage: `open coverage/index.html`
313
- * run the benchmarks before and after your change to see impact
314
- * `rake benchmarks`
332
+ - run tests:
333
+ - `bundle exec rake`
334
+ - `BUNDLE_GEMFILE=Gemfile.rails4 bundle exec rake` (Same tests using rails 4 instead of 5)
335
+ - view test coverage: `open coverage/index.html`
336
+ - run the benchmarks before and after your change to see impact
337
+ - `rake benchmarks`
315
338
 
316
339
  ### Known Issues
317
340
 
318
- * __total fail__ on front end code, because of the precompiled template step basically coverage doesn't work well for `erb`, `slim`, and the like.
319
- * related it will try to report something, but the line numbers reported for `ERB` files are often off and aren't considered useful. I recommend filtering out .erb using the `config.ignore` option. The default configuration excludes these files
320
- * coverage doesn't show for Rails `config/application.rb` or `config/boot.rb` as they get loaded when loading the Rake environment prior to starting the `Coverage` library. See [reload files section](#forcing-coverband-to-track-coverage-on-files-loaded-during-boot-safe_reload_files).
341
+ - **total fail** on front end code, because of the precompiled template step basically coverage doesn't work well for `erb`, `slim`, and the like.
342
+ - related it will try to report something, but the line numbers reported for `ERB` files are often off and aren't considered useful. I recommend filtering out .erb using the `config.ignore` option. The default configuration excludes these files
343
+ - coverage doesn't show for Rails `config/application.rb` or `config/boot.rb` as they get loaded when loading the Rake environment prior to starting the `Coverage` library. See [reload files section](#forcing-coverband-to-track-coverage-on-files-loaded-during-boot-safe_reload_files).
321
344
 
322
345
  ### Debugging Redis Store
323
346
 
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ Rake::TestTask.new(:test) do |test|
13
13
  # exclude benchmark from the tests as the way it functions resets code coverage during executions
14
14
  # test.pattern = 'test/unit/*_test.rb'
15
15
  # using test files opposed to pattern as it outputs which files are run
16
- test.test_files = FileList['test/unit/**/*_test.rb']
16
+ test.test_files = FileList['test/integration/**/*_test.rb', 'test/coverband/**/*_test.rb']
17
17
  test.verbose = true
18
18
  end
19
19
 
data/changes.md CHANGED
@@ -36,7 +36,17 @@ Will be the fully modern release that drops maintenance legacy support in favor
36
36
  - Make good video on setup, install, usage
37
37
  - See if we can add support for views / templates
38
38
  - using this technique https://github.com/ioquatix/covered
39
- - Better default grouping (could use groups features for gems for rails controllers, models, lib, etc)
39
+ - Better default grouping (could use groups features for gems for rails controllers, models, lib, etc)
40
+ - Improved logging for easier debugging and development
41
+ - drop the verbose mode and better support standard logger levels
42
+ - Possibly setup a build assets system
43
+ - my JS rules expanded the compressed JS at the top of application.js, basically we want to stitch together JS
44
+ - I guess we could also load multiple JS files as most of the JS is just default compressed JS and a tiny amount of actual app JS.
45
+ - lazy load for Coverband results
46
+ - view layer file coverage
47
+ - move all code to work with relative paths leaving only stdlib Coverage working on full paths
48
+ - add gem_safe_lists to track only some gems
49
+ - add gem_details_safe list to report on details on some gems
40
50
 
41
51
  ### Coverband_jam_session
42
52
 
@@ -63,41 +73,51 @@ Feature Ideas:
63
73
 
64
74
  # Alpha
65
75
 
66
- ### Coverband 4.2.0.alpha
76
+ ### Coverband 4.3.0?
67
77
 
68
- ???
69
-
70
- ### Coverband 4.1.0.beta
71
-
72
- - default disabled web clear, add config option to allow it
73
- - out of the box support for resque
74
- - readme improvements
75
- - fix on regression of merging directory changing deployments
76
- - fixes for duplicate root paths
77
- - pilot release of Gems tracking (disabled by default)
78
- - todos
79
- - support multiple gem paths (various version managers setup multiple gem paths)
80
- - speed up page load by allowing multiple pages
81
- - added web settings and debug views
82
- - added support for seeing coverage data size consumed in redis
83
- - support coverage data migrations from 4.0.x to 4.1.0
84
- - fixes for heroku /tmp asset building
78
+ - further improvements on eager_loading detection
79
+ - ?
85
80
 
86
81
  # Released
87
82
 
83
+ ### Coverband 4.2.0
84
+
85
+ **NOTE:** This release introduces load time and runtime Coverage. To get the full benifit of this feature you need to reset you coverage data (`rake coverband:clear` or clear via the web UI). Until you clear the combined result is still correct, but your runtime data will be mixed with previous data. This is due to an additive change in how we store coverage. We didn't reset by default as the coverage history for some folks may be more important than runtime breakdown.
86
+
87
+ - loadtime vs runtime coverage
88
+ - This fixes the coverage last seen date to exclude just load time data
89
+ - now you can see boot time coverage vs code hit during production execution
90
+ - list view shows runtime percentage and runtime hits
91
+ - file view shows line hits load, runtime, and combined
92
+ - perf speedup on gem details views
93
+ - ajax load code views for more responsive pages on large projects
94
+ - fix for issues with COVERBAND_DISABLE_AUTO_START
95
+ - silence warnings
96
+ - move from thread based reporter instance to process based instance
97
+ - thanks Karl Baum for much of the above mentioned work
98
+ - clear coverage on individual files
99
+ - we have a logo, thanks Dave Woodall
100
+
101
+ ### Coverband 4.1.1
102
+
103
+ - fix bug on info page when using namespaces
104
+ - fix bug related to forking Ruby processes (Resque for example)
105
+ - bug caused negative line hits
106
+ - bug seemed to cause memory leaks (not entirely sure how)
107
+ - various test improvements
108
+ - fix bad requests on coverband web admin to `/coverage/favicon.png`
109
+ - improved documentation
110
+
88
111
  ### Coverband 4.1.0
89
112
 
90
113
  - default disabled web clear, add config option to allow it
91
114
  - out of the box support for resque
92
115
  - readme improvements
93
116
  - fix on regression of merging directory changing deployments
94
- - fixes for duplicate root paths
95
- - pilot release of Gems tracking (disabled by default)
96
- - todos
97
- - support multiple gem paths (various version managers setup multiple gem paths)
98
- - speed up page load by allowing multiple pages
117
+ - fixes for duplicate root paths
118
+ - pilot release of Gems tracking (disabled by default) - todos - support multiple gem paths (various version managers setup multiple gem paths) - speed up page load by allowing multiple pages
99
119
  - added web settings and debug views
100
- - added support for seeing coverage data size consumed in redis
120
+ - added support for seeing coverage data size consumed in redis
101
121
  - support coverage data migrations from 4.0.x to 4.1.0
102
122
  - fixes for heroku /tmp asset building
103
123
 
data/coverband.gemspec CHANGED
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'rack-test'
34
34
  spec.add_development_dependency 'rake'
35
35
  spec.add_development_dependency 'resque'
36
+ # temporarily needed to fun tests for classifier-reborn as part of benchmarks
37
+ spec.add_development_dependency 'minitest-reporters'
36
38
 
37
39
  # TODO: used for benchmarking and tests I think we have other better benchmarking
38
40
  # perhaps time to drop this and refactor.
@@ -42,6 +44,8 @@ Gem::Specification.new do |spec|
42
44
  # require 'byebug'; byebug
43
45
  spec.add_development_dependency 'pry-byebug'
44
46
 
47
+ spec.add_development_dependency 'minitest-profile'
48
+
45
49
  # TODO: Remove when other production adapters exist
46
50
  # because the default configuration of redis store, we really do require
47
51
  # redis now. I was reluctant to add this, but until we offer another production
@@ -4,6 +4,7 @@ module Coverband
4
4
  module Adapters
5
5
  class Base
6
6
  include Coverband::Utils::FilePathHelper
7
+ attr_accessor :type
7
8
 
8
9
  def initialize
9
10
  @file_hash_cache = {}
@@ -13,6 +14,10 @@ module Coverband
13
14
  raise 'abstract'
14
15
  end
15
16
 
17
+ def clear_file!(_file)
18
+ raise 'abstract'
19
+ end
20
+
16
21
  def migrate!
17
22
  raise 'abstract'
18
23
  end
@@ -39,6 +44,11 @@ module Coverband
39
44
  get_report
40
45
  end
41
46
 
47
+ def get_coverage_report
48
+ data = Coverband.configuration.store.split_coverage(Coverband::TYPES)
49
+ data.merge(Coverband::MERGED_TYPE => Coverband.configuration.store.merged_coverage(Coverband::TYPES))
50
+ end
51
+
42
52
  def covered_files
43
53
  coverage.keys || []
44
54
  end
@@ -50,6 +60,18 @@ module Coverband
50
60
 
51
61
  protected
52
62
 
63
+ def split_coverage(types)
64
+ types.reduce({}) do |data, type|
65
+ data.update(type => get_report(type))
66
+ end
67
+ end
68
+
69
+ def merged_coverage(types)
70
+ types.reduce({}) do |data, type|
71
+ merge_reports(data, get_report(type), skip_expansion: true)
72
+ end
73
+ end
74
+
53
75
  def save_coverage
54
76
  raise 'abstract'
55
77
  end
@@ -65,10 +87,11 @@ module Coverband
65
87
  def expand_report(report)
66
88
  expanded = {}
67
89
  report_time = Time.now.to_i
90
+ updated_time = self.type == Coverband::EAGER_TYPE ? nil : report_time
68
91
  report.each_pair do |key, line_data|
69
92
  extended_data = {
70
93
  'first_updated_at' => report_time,
71
- 'last_updated_at' => report_time,
94
+ 'last_updated_at' => updated_time,
72
95
  'file_hash' => file_hash(key),
73
96
  'data' => line_data
74
97
  }
@@ -22,11 +22,21 @@ module Coverband
22
22
  end
23
23
 
24
24
  def clear!
25
- @redis.del(base_key)
25
+ Coverband::TYPES.each do |type|
26
+ @redis.del(type_base_key(type))
27
+ end
28
+ end
29
+
30
+ def clear_file!(filename)
31
+ Coverband::TYPES.each do |type|
32
+ data = get_report(type)
33
+ data.delete(filename)
34
+ save_coverage(data, type)
35
+ end
26
36
  end
27
37
 
28
38
  def size
29
- @redis.get(REDIS_STORAGE_FORMAT_VERSION).bytesize
39
+ @redis.get(base_key).bytesize
30
40
  end
31
41
 
32
42
  ###
@@ -51,6 +61,11 @@ module Coverband
51
61
  save_coverage(merge_reports(get_report, relative_path_report, skip_expansion: true))
52
62
  end
53
63
 
64
+ def type=(type)
65
+ super
66
+ reset_base_key
67
+ end
68
+
54
69
  private
55
70
 
56
71
  attr_reader :redis
@@ -60,16 +75,22 @@ module Coverband
60
75
  end
61
76
 
62
77
  def base_key
63
- @base_key ||= [@format_version, @redis_namespace].compact.join('.')
78
+ @base_key ||= [@format_version, @redis_namespace, type].compact.join('.')
79
+ end
80
+
81
+ def type_base_key(local_type)
82
+ [@format_version, @redis_namespace, local_type].compact.join('.')
64
83
  end
65
84
 
66
- def save_coverage(data)
67
- redis.set base_key, data.to_json
68
- redis.expire(base_key, @ttl) if @ttl
85
+ def save_coverage(data, local_type = nil)
86
+ local_type ||= type
87
+ redis.set type_base_key(local_type), data.to_json
88
+ redis.expire(type_base_key(local_type), @ttl) if @ttl
69
89
  end
70
90
 
71
- def get_report
72
- data = redis.get base_key
91
+ def get_report(local_type = nil)
92
+ local_type ||= type
93
+ data = redis.get type_base_key(local_type)
73
94
  data ? JSON.parse(data) : {}
74
95
  end
75
96
  end
@@ -4,15 +4,32 @@ module Coverband
4
4
  class AtExit
5
5
  @semaphore = Mutex.new
6
6
 
7
+ @at_exit_registered = nil
7
8
  def self.register
9
+ return if ENV['COVERBAND_DISABLE_AT_EXIT']
8
10
  return if @at_exit_registered
11
+
9
12
  @semaphore.synchronize do
10
13
  return if @at_exit_registered
14
+
11
15
  @at_exit_registered = true
12
16
  at_exit do
13
17
  ::Coverband::Background.stop
14
- Coverband.report_coverage(true)
15
- Coverband.configuration.logger&.debug('Coverband: Reported coverage before exit')
18
+
19
+ #####
20
+ # TODO: This is is brittle and not a great solution to avoid deploy time
21
+ # actions polluting the 'runtime' metrics
22
+ #
23
+ # * should we skip /bin/rails webpacker:compile ?
24
+ # * Perhaps detect heroku deployment ENV var opposed to tasks?
25
+ #####
26
+ default_heroku_tasks = ['assets:clean', 'assets:precompile']
27
+ if defined?(Rake) && Rake.respond_to?(:application) && (Rake&.application&.top_level_tasks || []).any? { |task| default_heroku_tasks.include?(task) }
28
+ # skip reporting
29
+ else
30
+ Coverband.report_coverage(true)
31
+ #Coverband.configuration.logger&.debug('Coverband: Reported coverage before exit')
32
+ end
16
33
  end
17
34
  end
18
35
  end