coverband 4.2.0 → 4.2.2
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 +4 -4
- data/.rubocop.yml +29 -9
- data/.travis.yml +10 -8
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +3 -1
- data/Gemfile.rails4 +1 -0
- data/README.md +72 -43
- data/Rakefile +14 -3
- data/changes.md +66 -11
- data/coverband.gemspec +2 -5
- data/lib/coverband/adapters/base.rb +64 -45
- data/lib/coverband/adapters/file_store.rb +15 -9
- data/lib/coverband/adapters/hash_redis_store.rb +182 -0
- data/lib/coverband/adapters/redis_store.rb +33 -11
- data/lib/coverband/at_exit.rb +2 -11
- data/lib/coverband/collectors/coverage.rb +34 -40
- data/lib/coverband/collectors/delta.rb +34 -28
- data/lib/coverband/collectors/view_tracker.rb +124 -0
- data/lib/coverband/configuration.rb +96 -32
- data/lib/coverband/integrations/background.rb +9 -4
- data/lib/coverband/integrations/{middleware.rb → background_middleware.rb} +2 -6
- data/lib/coverband/integrations/bundler.rb +8 -0
- data/lib/coverband/integrations/report_middleware.rb +15 -0
- data/lib/coverband/integrations/resque.rb +3 -5
- data/lib/coverband/reporters/base.rb +40 -16
- data/lib/coverband/reporters/console_report.rb +1 -0
- data/lib/coverband/reporters/html_report.rb +21 -27
- data/lib/coverband/reporters/web.rb +19 -21
- data/lib/coverband/utils/absolute_file_converter.rb +47 -0
- data/lib/coverband/utils/file_hasher.rb +16 -0
- data/lib/coverband/utils/file_list.rb +16 -5
- data/lib/coverband/utils/html_formatter.rb +37 -8
- data/lib/coverband/utils/lines_classifier.rb +5 -0
- data/lib/coverband/utils/railtie.rb +20 -9
- data/lib/coverband/utils/relative_file_converter.rb +41 -0
- data/lib/coverband/utils/result.rb +1 -37
- data/lib/coverband/utils/results.rb +51 -0
- data/lib/coverband/utils/s3_report.rb +2 -2
- data/lib/coverband/utils/source_file.rb +31 -8
- data/lib/coverband/utils/tasks.rb +10 -10
- data/lib/coverband/version.rb +5 -1
- data/lib/coverband.rb +39 -22
- data/public/application.css +6 -6
- data/public/application.js +27 -0
- data/test/benchmarks/benchmark.rake +167 -73
- data/test/benchmarks/init_rails.rake +10 -0
- data/test/coverband/adapters/base_test.rb +73 -42
- data/test/coverband/adapters/file_store_test.rb +48 -37
- data/test/coverband/adapters/hash_redis_store_test.rb +190 -0
- data/test/coverband/adapters/redis_store_test.rb +92 -59
- data/test/coverband/at_exit_test.rb +0 -2
- data/test/coverband/collectors/coverage_test.rb +62 -10
- data/test/coverband/collectors/delta_test.rb +36 -6
- data/test/coverband/collectors/view_tracker_test.rb +77 -0
- data/test/coverband/configuration_test.rb +47 -7
- data/test/coverband/coverband_test.rb +14 -2
- data/test/coverband/integrations/background_middleware_test.rb +44 -0
- data/test/coverband/integrations/background_test.rb +1 -3
- data/test/coverband/integrations/report_middleware_test.rb +44 -0
- data/test/coverband/integrations/resque_worker_test.rb +6 -6
- data/test/coverband/integrations/test_resque_job.rb +3 -1
- data/test/coverband/reporters/base_test.rb +2 -79
- data/test/coverband/reporters/console_test.rb +2 -6
- data/test/coverband/reporters/html_test.rb +58 -19
- data/test/coverband/reporters/web_test.rb +0 -10
- data/test/coverband/utils/absolute_file_converter_test.rb +56 -0
- data/test/coverband/utils/file_groups_test.rb +11 -5
- data/test/coverband/utils/file_hasher_test.rb +29 -0
- data/test/coverband/utils/file_list_test.rb +5 -5
- data/test/coverband/utils/html_formatter_test.rb +43 -0
- data/test/coverband/utils/relative_file_converter_test.rb +39 -0
- data/test/coverband/utils/result_test.rb +6 -47
- data/test/coverband/utils/results_test.rb +54 -0
- data/test/coverband/utils/s3_report_test.rb +2 -0
- data/test/coverband/utils/source_file_test.rb +50 -0
- data/test/dog.rb.erb +12 -0
- data/test/forked/rails_full_stack_test.rb +106 -0
- data/test/forked/rails_rake_full_stack_test.rb +48 -0
- data/test/integration/full_stack_test.rb +17 -16
- data/test/rails4_dummy/Rakefile +6 -0
- data/test/rails4_dummy/config/application.rb +8 -9
- data/test/rails4_dummy/config/coverband.rb +5 -3
- data/test/rails5_dummy/Rakefile +6 -0
- data/test/rails5_dummy/config/application.rb +6 -10
- data/test/rails5_dummy/config/coverband.rb +4 -2
- data/test/rails_test_helper.rb +22 -5
- data/test/test_helper.rb +45 -8
- data/test/unique_files.rb +17 -9
- data/views/file_list.erb +2 -2
- data/views/gem_list.erb +10 -1
- data/views/layout.erb +6 -18
- data/views/nav.erb +35 -0
- data/views/source_file.erb +13 -4
- data/views/source_file_loader.erb +1 -1
- data/views/view_tracker.erb +37 -0
- metadata +59 -25
- data/lib/coverband/utils/file_path_helper.rb +0 -57
- data/test/coverband/integrations/middleware_test.rb +0 -96
- data/test/integration/rails_full_stack_test.rb +0 -95
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 33ec68822b5c228e86048d62ded36cfeba06adf77022d07b39cdcb897c215f6f
|
|
4
|
+
data.tar.gz: 7494e163926def8f8406da850efe02f5cd79f6ba6377abaf14ccb09aedc6ca85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fda6dd49e21244819834f20e857ba2f4c8fddec4b1096a2b7ecfad7acdf6352cb2d4a8783f1cb5efc1ea2dc1ef5d03e7712f709fb928e29461dd41fc2dff76d8
|
|
7
|
+
data.tar.gz: b318161bc9c3709d41a35bb8a4e108a5ab38bea2feb095b1fc8d900f6e8a9bcfcc37dbf90392408d2efa3d510a58ceff5c69d19a422e4923049c08ee69d20c9c
|
data/.rubocop.yml
CHANGED
|
@@ -2,14 +2,21 @@ AllCops:
|
|
|
2
2
|
TargetRubyVersion: 2.4
|
|
3
3
|
Exclude:
|
|
4
4
|
- docs/**/*
|
|
5
|
+
- test/rails4_dummy/**/*
|
|
6
|
+
- test/rails5_dummy/**/*
|
|
7
|
+
- test/fixtures/**/*
|
|
8
|
+
# Get the code passing first then we will enable for tests
|
|
9
|
+
- test/**/*
|
|
5
10
|
Documentation:
|
|
6
11
|
Enabled: false
|
|
7
12
|
Metrics/MethodLength:
|
|
8
13
|
Enabled: false
|
|
9
14
|
Metrics/LineLength:
|
|
10
|
-
Max:
|
|
15
|
+
Max: 160
|
|
11
16
|
Metrics/BlockNesting:
|
|
12
17
|
Max: 5
|
|
18
|
+
Metrics/BlockLength:
|
|
19
|
+
Max: 30
|
|
13
20
|
Metrics/CyclomaticComplexity:
|
|
14
21
|
Enabled: false
|
|
15
22
|
Metrics/PerceivedComplexity:
|
|
@@ -22,38 +29,51 @@ Metrics/ModuleLength:
|
|
|
22
29
|
Enabled: false
|
|
23
30
|
Metrics/ParameterLists:
|
|
24
31
|
Max: 10
|
|
25
|
-
|
|
26
|
-
Enabled: false
|
|
27
|
-
Style/PredicateName:
|
|
32
|
+
Naming/AccessorMethodName:
|
|
28
33
|
Enabled: false
|
|
34
|
+
Naming/PredicateName:
|
|
35
|
+
Enabled: true
|
|
29
36
|
Style/TernaryParentheses:
|
|
30
37
|
Enabled: false
|
|
31
38
|
Style/MutableConstant:
|
|
32
39
|
Enabled: false
|
|
40
|
+
Style/IdenticalConditionalBranches:
|
|
41
|
+
Enabled: false
|
|
42
|
+
Style/ClassVars:
|
|
43
|
+
Enabled: false
|
|
44
|
+
Style/MultilineBlockChain:
|
|
45
|
+
Enabled: false
|
|
33
46
|
Style/FrozenStringLiteralComment:
|
|
34
47
|
Enabled: true
|
|
35
48
|
Style/GuardClause:
|
|
36
49
|
Enabled: true
|
|
37
50
|
Style/NumericPredicate:
|
|
38
|
-
Enabled:
|
|
51
|
+
Enabled: true
|
|
39
52
|
Style/NumericLiterals:
|
|
40
53
|
Enabled: false
|
|
41
54
|
Style/NumericLiteralPrefix:
|
|
42
55
|
Enabled: false
|
|
43
56
|
Style/ClassAndModuleChildren:
|
|
44
57
|
Enabled: false
|
|
58
|
+
Style/SymbolProc:
|
|
59
|
+
Enabled: false
|
|
60
|
+
Style/RegexpLiteral:
|
|
61
|
+
Enabled: false
|
|
45
62
|
Performance/Casecmp:
|
|
46
63
|
Enabled: false
|
|
47
|
-
|
|
64
|
+
Performance/RegexpMatch:
|
|
65
|
+
Enabled: false
|
|
66
|
+
Layout/MultilineMethodCallIndentation:
|
|
48
67
|
Enabled: true
|
|
49
|
-
|
|
68
|
+
Layout/MultilineOperationIndentation:
|
|
50
69
|
Enabled: true
|
|
51
70
|
Lint/RescueException:
|
|
52
71
|
Enabled: true
|
|
72
|
+
Lint/UselessAccessModifier:
|
|
73
|
+
Enabled: true
|
|
53
74
|
Lint/ShadowingOuterLocalVariable:
|
|
54
75
|
Enabled: true
|
|
55
76
|
Style/FormatString:
|
|
56
77
|
Enabled: true
|
|
57
|
-
|
|
78
|
+
Security/Eval:
|
|
58
79
|
Enabled: true
|
|
59
|
-
|
data/.travis.yml
CHANGED
|
@@ -9,11 +9,13 @@ gemfile:
|
|
|
9
9
|
- Gemfile.rails4
|
|
10
10
|
services:
|
|
11
11
|
- redis-server
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
script:
|
|
13
|
+
- bundle exec rake rubocop
|
|
14
|
+
- COVERBAND_HASH_REDIS_STORE=t bundle exec rake
|
|
15
|
+
- COVERBAND_HASH_REDIS_STORE=t bundle exec rake forked_tests
|
|
16
|
+
- bundle exec rake
|
|
17
|
+
- bundle exec rake forked_tests
|
|
18
|
+
# remove this for now as it is flaky
|
|
19
|
+
# passes locally on 2.3.5 on travis passes sometimes on 2.4 and always on 2.6.1
|
|
20
|
+
#- bundle exec rake benchmarks:memory
|
|
21
|
+
- bundle exec rake benchmarks
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at danmayer@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
72
|
+
|
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
|
74
|
+
|
|
75
|
+
For answers to common questions about this code of conduct, see
|
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/Gemfile
CHANGED
|
@@ -5,5 +5,7 @@ source 'https://rubygems.org'
|
|
|
5
5
|
# Specify your gem's dependencies in coverband.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
gem 'rails', '~>5'
|
|
8
|
-
#
|
|
8
|
+
# these gems are used for testing gem tracking
|
|
9
|
+
gem 'irb', require: false
|
|
10
|
+
gem 'pundit'
|
|
9
11
|
gem 'rainbow', require: false
|
data/Gemfile.rails4
CHANGED
data/README.md
CHANGED
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://travis-ci.org/danmayer/coverband)
|
|
6
6
|
[](https://coveralls.io/github/danmayer/coverband?branch=master)
|
|
7
|
+
[](https://codeclimate.com/github/danmayer/coverband/maintainability)
|
|
8
|
+
[](https://discord.gg/KAH38EV)
|
|
9
|
+
|
|
7
10
|
|
|
8
11
|
<p align="center">
|
|
9
12
|
<a href="#key-features">Key Features</a> •
|
|
10
13
|
<a href="#installation">Installation</a> •
|
|
11
14
|
<a href="#coverage-report">Coverage Report</a> •
|
|
12
|
-
<a href="#verify-correct-installation">Verify Correct Installation</a> •
|
|
13
15
|
<a href="#advanced-config">Advanced Config</a> •
|
|
14
16
|
<a href="#license">License</a> •
|
|
15
|
-
<a href="/changes.md">Change Log / Roadmap</a>
|
|
17
|
+
<a href="/changes.md">Change Log / Roadmap</a> •
|
|
18
|
+
<a href="/CODE_OF_CONDUCT.md">Code of Conduct</a>
|
|
16
19
|
</p>
|
|
17
20
|
|
|
18
21
|
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.
|
|
@@ -24,9 +27,11 @@ A gem to measure production code usage, showing a counter for the number of time
|
|
|
24
27
|
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.
|
|
25
28
|
|
|
26
29
|
- Low performance overhead
|
|
27
|
-
-
|
|
30
|
+
- Simple setup and configuration
|
|
28
31
|
- Out of the box support for all standard code execution paths (web, cron, background jobs, rake tasks, etc)
|
|
32
|
+
- Splits load time (Rails eager load) and Run time metrics
|
|
29
33
|
- Easy to understand actionable insights from the report
|
|
34
|
+
- Tracks Gem usage (still in experimental stages and not recommended for production)
|
|
30
35
|
- Development mode, offers deep insight of code usage details (number of LOC execution during single request, etc) during development.
|
|
31
36
|
- Mountable web interface to easily share reports
|
|
32
37
|
|
|
@@ -52,9 +57,17 @@ gem 'coverband'
|
|
|
52
57
|
|
|
53
58
|
If [tracking gem usage](#collecting-gem--library-usage), be sure to include coverband before other gems you would like to track.
|
|
54
59
|
|
|
60
|
+
## Upgrading to Latest
|
|
61
|
+
|
|
62
|
+
### No custom code or middleware required
|
|
63
|
+
|
|
64
|
+
With older versions of coverband, projects would report to redis using rack or sidekiq middleware. After coverband 4.0, this should no longer be required and could cause performance issues. Reporting to redis is now automatically done within a background thread with no custom code needed.
|
|
65
|
+
|
|
66
|
+
See [changelog](https://github.com/danmayer/coverband/blob/master/changes.md).
|
|
67
|
+
|
|
55
68
|
## Rails
|
|
56
69
|
|
|
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.
|
|
70
|
+
The Railtie integration means you shouldn't need to do anything anything else other than ensure coverband is required after rails within your Gemfile. The only exception to this is gem tracking of `Bundle.require` which depends on requiring coverband within the application.rb. See [Collecting Gem / Library Usage](https://github.com/danmayer/coverband#collecting-gem--library-usage).
|
|
58
71
|
|
|
59
72
|
## Sinatra
|
|
60
73
|
|
|
@@ -64,7 +77,7 @@ For the best coverage you want this loaded as early as possible. I have been put
|
|
|
64
77
|
require 'coverband'
|
|
65
78
|
require File.dirname(__FILE__) + '/config/environment'
|
|
66
79
|
|
|
67
|
-
use Coverband::
|
|
80
|
+
use Coverband::BackgroundMiddleware
|
|
68
81
|
run ActionController::Dispatcher.new
|
|
69
82
|
```
|
|
70
83
|
|
|
@@ -88,17 +101,20 @@ Rails.application.routes.draw do
|
|
|
88
101
|
end
|
|
89
102
|
```
|
|
90
103
|
|
|
104
|
+
or you can enable basic auth by setting `ENV['COVERBAND_PASSWORD']` or via your configuration `config.password = 'my_pass'`
|
|
105
|
+
|
|
91
106
|
### Coverband Web Endpoint
|
|
92
107
|
|
|
93
108
|
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.
|
|
94
109
|
|
|
95
|
-

|
|
96
111
|
|
|
97
112
|
> The web index as available on the Coverband Demo site
|
|
98
113
|
|
|
99
114
|
- **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
115
|
- **clear coverage report:** This will clear the coverage data. This wipes out all collected data (**dangerous**)
|
|
116
|
+
- View individual file details
|
|
117
|
+
- **clear individual file coverage:** This will clear the details of the file you are looking at. This is helpful if you don't want to loose all Coverage data but made a change that you expect would impact a particular file.
|
|
102
118
|
|
|
103
119
|
### Rake Tasks
|
|
104
120
|
|
|
@@ -118,14 +134,6 @@ Index Page
|
|
|
118
134
|
Details on an example Sinatra app
|
|
119
135
|

|
|
120
136
|
|
|
121
|
-
# Verify Correct Installation
|
|
122
|
-
|
|
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.
|
|
128
|
-
|
|
129
137
|
# Coverband Demo
|
|
130
138
|
|
|
131
139
|
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.
|
|
@@ -156,10 +164,10 @@ Coverband.configure do |config|
|
|
|
156
164
|
config.s3_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
|
157
165
|
config.s3_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
|
158
166
|
|
|
159
|
-
# config options false, true
|
|
167
|
+
# config options false, true. (defaults to false)
|
|
160
168
|
# true and debug can give helpful and interesting code usage information
|
|
161
|
-
#
|
|
162
|
-
#
|
|
169
|
+
# and is safe to use if one is investigating issues in production, but it will slightly
|
|
170
|
+
# hit perf.
|
|
163
171
|
config.verbose = false
|
|
164
172
|
end
|
|
165
173
|
```
|
|
@@ -173,10 +181,19 @@ config.ignore += ['config/application.rb',
|
|
|
173
181
|
'config/boot.rb',
|
|
174
182
|
'config/puma.rb',
|
|
175
183
|
'config/schedule.rb',
|
|
176
|
-
'bin/*'
|
|
184
|
+
'bin/*',
|
|
177
185
|
'config/environments/*',
|
|
178
186
|
'lib/tasks/*']
|
|
179
187
|
```
|
|
188
|
+
### View Tracking
|
|
189
|
+
|
|
190
|
+
Coverband allows an optional feature to track all view files that are used by an application.
|
|
191
|
+
|
|
192
|
+
To opt-in to this feature... enable the feature in your Coverband config.
|
|
193
|
+
|
|
194
|
+
`config.track_views = true`
|
|
195
|
+
|
|
196
|
+

|
|
180
197
|
|
|
181
198
|
### Writing Coverband Results to S3
|
|
182
199
|
|
|
@@ -199,13 +216,13 @@ ENV['AWS_ACCESS_KEY_ID']
|
|
|
199
216
|
ENV['AWS_SECRET_ACCESS_KEY']
|
|
200
217
|
```
|
|
201
218
|
|
|
202
|
-
###
|
|
203
|
-
|
|
204
|
-
Between the release of 4.0 and 4.1 our data format changed. This resets all your coverage data. If you want to restore your previous coverage data, feel free to migrate.
|
|
219
|
+
### Redis Hash Store
|
|
205
220
|
|
|
206
|
-
|
|
221
|
+
Coverband on very high volume sites with many server processes reporting can have a race condition. To resolve the race condition and reduce Ruby memory overhead we have introduced a new Redis storage option. This moves the some of the work from the Ruby processes to Redis. It is worth noting because of this, it has a larger demands on the Redis server. So adjust your Redis instance accordingly. To help reduce the extra redis load you can also change the background reporting time period.
|
|
207
222
|
|
|
208
|
-
|
|
223
|
+
* set the new Redis store: `config.store = Coverband::Adapters::HashRedisStore.new(Redis.new(url: redis_url))`
|
|
224
|
+
* adjust from default 30s reporting `config.background_reporting_sleep_seconds = 120`
|
|
225
|
+
* reminder it is recommended to have a unique Redis per workload (background jobs, caching, Coverband), for this store, it may be more important to have a dedicated Redis.
|
|
209
226
|
|
|
210
227
|
### Clear Coverage
|
|
211
228
|
|
|
@@ -213,6 +230,14 @@ Now that Coverband uses MD5 hashes there should be no reason to manually clear c
|
|
|
213
230
|
|
|
214
231
|
`rake coverband:clear`
|
|
215
232
|
|
|
233
|
+
### Coverage Data Migration
|
|
234
|
+
|
|
235
|
+
Between the release of 4.0 and 4.1 our data format changed. This resets all your coverage data. If you want to restore your previous coverage data, feel free to migrate.
|
|
236
|
+
|
|
237
|
+
`rake coverband:migrate`
|
|
238
|
+
|
|
239
|
+
- We will be working to support migrations going forward, when possible
|
|
240
|
+
|
|
216
241
|
### Adding Rake Tasks outside of Rails
|
|
217
242
|
|
|
218
243
|
Rails apps should automaticallly include the tasks via the Railtie.
|
|
@@ -251,6 +276,8 @@ By adding any files above you will get reporting on those files as part of your
|
|
|
251
276
|
|
|
252
277
|
### Collecting Gem / Library Usage
|
|
253
278
|
|
|
279
|
+
__WARNING:__ Gem Tracking is still in experimental stages and not recommended for production. We have some performance issues when view reports on large applications. Gem tracing also during background thread data collection has HIGH memory requirements, during report merging (seemingly around 128mb of extra memory, which is crazy). We recommend deploying WITHOUT `track_gems` first and only enabling it after confirming that Coverband is working and performing well.
|
|
280
|
+
|
|
254
281
|
Gem usage can be tracked by enabling the `track_gems` config.
|
|
255
282
|
|
|
256
283
|
```
|
|
@@ -261,7 +288,20 @@ end
|
|
|
261
288
|
|
|
262
289
|
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
290
|
|
|
264
|
-
When tracking gems, it is important that `Coverband#start` is called before the gems to be tracked are required.
|
|
291
|
+
When tracking gems, it is important that `Coverband#start` is called before the gems to be tracked are required. The best way to do this is to require coverband before Bundle.require is called. Within rails, require coverband within the application.rb like so:
|
|
292
|
+
|
|
293
|
+
```ruby
|
|
294
|
+
require 'coverband'
|
|
295
|
+
Bundler.require(*Rails.groups)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
If you are using the resque integration, resque needs to be required before coverband since the integration will not run unless resque is loaded. Within the application.rb just require resque before coverband.
|
|
299
|
+
|
|
300
|
+
```ruby
|
|
301
|
+
require 'resque'
|
|
302
|
+
require 'coverband'
|
|
303
|
+
Bundler.require(*Rails.groups)
|
|
304
|
+
```
|
|
265
305
|
|
|
266
306
|
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
307
|
|
|
@@ -287,27 +327,11 @@ Coverband.start
|
|
|
287
327
|
|
|
288
328
|
### Verbose Debug / Development Mode
|
|
289
329
|
|
|
290
|
-
Note: To debug issues getting Coverband working. I recommend running in development mode, by turning verbose logging on `config.verbose = true` and passing in the Rails.logger `config.logger = Rails.logger` to the Coverband config. This makes it easy to follow in development mode. Be careful to not leave these on in production as they will affect performance.
|
|
330
|
+
Note: To debug issues getting Coverband working. I recommend running in development mode, by turning verbose logging on `config.verbose = true` and passing in the Rails.logger `config.logger = Rails.logger` to the Coverband config. We respect the log level, and I would recommend log level info generally, but if you are investigating a prolbem Coverband logs additional data at the `debug` level. This makes it easy to follow in development mode. Be careful to not leave these on in production as they will affect performance.
|
|
291
331
|
|
|
292
332
|
---
|
|
293
333
|
|
|
294
|
-
If you are trying to debug locally wondering what code is being run during a request. The verbose modes `config.verbose = true`
|
|
295
|
-
|
|
296
|
-
config.verbose = 'debug'
|
|
297
|
-
|
|
298
|
-
coverband file usage:
|
|
299
|
-
[["/Users/danmayer/projects/app_name/lib/facebook.rb", 6],
|
|
300
|
-
["/Users/danmayer/projects/app_name/app/models/some_modules.rb", 9],
|
|
301
|
-
...
|
|
302
|
-
["/Users/danmayer/projects/app_name/app/models/user.rb", 2606],
|
|
303
|
-
["/Users/danmayer/projects/app_name/app/helpers/application_helper.rb",
|
|
304
|
-
43150]]
|
|
305
|
-
|
|
306
|
-
file:
|
|
307
|
-
/Users/danmayer/projects/app_name/app/helpers/application_helper.rb =>
|
|
308
|
-
[[448, 1], [202, 1],
|
|
309
|
-
...
|
|
310
|
-
[517, 1617], [516, 38577]]
|
|
334
|
+
If you are trying to debug locally wondering what code is being run during a request. The verbose modes `config.verbose = true` && `Rails.logger.level = :debug`. With true set it will output the number of lines executed per file, to the passed in log.
|
|
311
335
|
|
|
312
336
|
# Prerequisites
|
|
313
337
|
|
|
@@ -335,6 +359,7 @@ If you submit a change please make sure the tests and benchmarks are passing.
|
|
|
335
359
|
- view test coverage: `open coverage/index.html`
|
|
336
360
|
- run the benchmarks before and after your change to see impact
|
|
337
361
|
- `rake benchmarks`
|
|
362
|
+
- run a single test by line number like rspec: `bundle exec m test/coverband/reporters/html_test.rb:29`
|
|
338
363
|
|
|
339
364
|
### Known Issues
|
|
340
365
|
|
|
@@ -352,6 +377,10 @@ What is the coverage data in Redis?
|
|
|
352
377
|
|
|
353
378
|
`Coverband.configuration.store.coverage`
|
|
354
379
|
|
|
380
|
+
## Logo
|
|
381
|
+
|
|
382
|
+
The Coverband logo was created by [Dave Woodall](http://davewoodall.com). Thanks Dave!
|
|
383
|
+
|
|
355
384
|
# License
|
|
356
385
|
|
|
357
386
|
This is a MIT License project...
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'bundler/gem_tasks'
|
|
4
|
-
|
|
5
4
|
import 'test/benchmarks/benchmark.rake'
|
|
5
|
+
require 'rubocop/rake_task'
|
|
6
|
+
|
|
7
|
+
RuboCop::RakeTask.new
|
|
6
8
|
|
|
7
|
-
task default: [
|
|
9
|
+
task default: %i[test]
|
|
10
|
+
|
|
11
|
+
task 'test:all': %i[rubocop test forked_tests benchmarks:memory benchmarks]
|
|
8
12
|
|
|
9
13
|
task :test
|
|
10
14
|
require 'rake/testtask'
|
|
@@ -17,9 +21,16 @@ Rake::TestTask.new(:test) do |test|
|
|
|
17
21
|
test.verbose = true
|
|
18
22
|
end
|
|
19
23
|
|
|
24
|
+
Rake::TestTask.new(:forked_tests) do |test|
|
|
25
|
+
test.libs << 'lib' << 'test'
|
|
26
|
+
test.test_files = FileList['test/forked/**/*_test.rb']
|
|
27
|
+
test.verbose = true
|
|
28
|
+
end
|
|
29
|
+
|
|
20
30
|
desc 'load irb with this gem'
|
|
21
31
|
task :console do
|
|
22
|
-
|
|
32
|
+
puts 'running console'
|
|
33
|
+
exec 'bundle exec console'
|
|
23
34
|
end
|
|
24
35
|
|
|
25
36
|
# This is really just for testing and development because without configuration
|
data/changes.md
CHANGED
|
@@ -16,6 +16,8 @@ Will be the fully modern release that drops maintenance legacy support in favor
|
|
|
16
16
|
- add built-in support for easy loading via Railties
|
|
17
17
|
- built in support for activejob, sidekiq, and other common frameworks
|
|
18
18
|
- reduced configuration options
|
|
19
|
+
- support oneshot
|
|
20
|
+
- drop middleware figure out a way to kick off background without middelware
|
|
19
21
|
- options on reporting
|
|
20
22
|
- background reporting
|
|
21
23
|
- or middleware reporting
|
|
@@ -47,6 +49,7 @@ Will be the fully modern release that drops maintenance legacy support in favor
|
|
|
47
49
|
- move all code to work with relative paths leaving only stdlib Coverage working on full paths
|
|
48
50
|
- add gem_safe_lists to track only some gems
|
|
49
51
|
- add gem_details_safe list to report on details on some gems
|
|
52
|
+
- - display gems that are in loaded with 0 coverage, thanks @kbaum
|
|
50
53
|
|
|
51
54
|
### Coverband_jam_session
|
|
52
55
|
|
|
@@ -54,32 +57,84 @@ This is a possible gem to host experimental or more complex features, which woul
|
|
|
54
57
|
|
|
55
58
|
Feature Ideas:
|
|
56
59
|
|
|
60
|
+
- per request coverage implemented via Ruby 2.6.0 coverage.clear https://bugs.ruby-lang.org/issues/15022
|
|
57
61
|
- statsd adapters (it would allow passing in date ranges on usage)
|
|
58
|
-
- move to SimpleCov console out, or make similar console tabular output
|
|
59
62
|
- Possibly add ability to record code run for a given route
|
|
60
63
|
- integrate recording with deploy tag or deploy timestamp
|
|
61
64
|
- diff code usage across deployed versions
|
|
62
65
|
- what methods increased usage or decreased
|
|
63
|
-
- Improve client code api, around manual usage of sampling (like event usage)
|
|
64
66
|
- ability to change the Coverband config at runtime by changing the config pushed to the Redis hash. In memory cache around the changes to only make that call periodically.
|
|
65
67
|
- Opposed to just showing code usage on a route allow 'tagging' events which would record line coverage for that tag (this would allow tagging all code that modified an ActiveRecord model for example
|
|
66
68
|
- additional adapters (tracepoint, ruby-profiler, etc)
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
69
|
+
- tagged coverage reports
|
|
70
|
+
- code route tracing (entry point to all code executed for example /some_path -> code coverage of that path)
|
|
71
|
+
- deploy git hash tagging of reported Coverage
|
|
72
|
+
- allow only to collect coverage based on route (limiting or scoped coverage)
|
|
73
|
+
- coverage over some other variable like a set of alpha users
|
|
71
74
|
- document how to use this on staging / selenium test suite runs
|
|
72
75
|
- possible add API to pull report at end of run
|
|
73
76
|
|
|
74
|
-
# Alpha
|
|
77
|
+
# Alpha / Beta / Release Candidates
|
|
75
78
|
|
|
76
|
-
### Coverband 4.
|
|
79
|
+
### Coverband 4.2.2
|
|
77
80
|
|
|
78
|
-
-
|
|
79
|
-
|
|
81
|
+
- new experimental hash redis store for high volume collection
|
|
82
|
+
(hundreds of clients), thanks @kbaum
|
|
83
|
+
- view_tracker supports tracking view layer files like `.html.erb`
|
|
84
|
+
- documentation improvements, thanks @brossetti1, @jjb, @kbaum
|
|
85
|
+
- we now have discordapp for discussions, thanks @kbaum,
|
|
86
|
+
https://discordapp.com/channels/609509533999562753/609509533999562756
|
|
87
|
+
- perf fix on Rails initialization, thanks @skangg
|
|
88
|
+
- simplified logging
|
|
80
89
|
|
|
81
90
|
# Released
|
|
82
91
|
|
|
92
|
+
### Coverband 4.2.2
|
|
93
|
+
|
|
94
|
+
- new experimental hash redis store for high volume collection
|
|
95
|
+
(hundreds of clients), thanks @kbaum
|
|
96
|
+
- view_tracker supports tracking view layer files like `.html.erb`
|
|
97
|
+
- documentation improvements, thanks @brossetti1, @jjb, @kbaum
|
|
98
|
+
- we now have discordapp for discussions, thanks @kbaum,
|
|
99
|
+
https://discordapp.com/channels/609509533999562753/609509533999562756
|
|
100
|
+
- perf fix on Rails initialization, thanks @skangg
|
|
101
|
+
- simplified logging
|
|
102
|
+
|
|
103
|
+
### Coverband 4.2.1
|
|
104
|
+
|
|
105
|
+
- larger changes
|
|
106
|
+
- reduce memory usage
|
|
107
|
+
- fix issue where reports didn't include files with 0 activity
|
|
108
|
+
- updated runtime relavent lines and runtime percentages
|
|
109
|
+
- add Oneshot coverage support for Ruby 2.6.0 thanks @zwalker
|
|
110
|
+
- I would consider this our test oneshot release, please report any issues
|
|
111
|
+
- improved control over memory vs functionality
|
|
112
|
+
- oneshot support is the best memory and speed if you are on Ruby 2.6.\*
|
|
113
|
+
- simulated_oneshot works for Ruby prior to 2.6.\*, keeps lower runtime memory, at a trade of only being able to detect eager_load or runtime hits not both
|
|
114
|
+
- full hit tracking (The previous and current default), this uses more memory than other options, but provides full robust data
|
|
115
|
+
|
|
116
|
+
* small changes fixes
|
|
117
|
+
- further improvements on eager_loading detection, thanks @kbaum
|
|
118
|
+
- fix on ignore configuration options
|
|
119
|
+
- fix broken static server
|
|
120
|
+
- fix issue where clear and coverage trigger coverage reports
|
|
121
|
+
- improved logging
|
|
122
|
+
- fix on gem runtime code coverage support, thanks @kbaum
|
|
123
|
+
- fix sorting of runtime coverage
|
|
124
|
+
- add runtime coverage to gem summary pages
|
|
125
|
+
- documented redis TTL, thanks @jjb
|
|
126
|
+
- resolve regression on coverband rake tasks recording coverage
|
|
127
|
+
- improved runtime / eager loading tracking
|
|
128
|
+
- fix on small memory leaks
|
|
129
|
+
- added warnings that gem tracking isn't production ready
|
|
130
|
+
- built in support for basic auth on the web rack app, thanks @jjb
|
|
131
|
+
- don't clobber rake environment method definition, thanks @shioyama
|
|
132
|
+
- readme improvements, thanks @yuriyalekseyev
|
|
133
|
+
- fix duplicate requires thanks @yuriyalekseyev
|
|
134
|
+
- various cleanups and improvements, thanks @kbaum
|
|
135
|
+
- additional benchmarks to ensure proper memory handling, thanks @kbaum
|
|
136
|
+
- default redis TTL, thanks @jjb
|
|
137
|
+
|
|
83
138
|
### Coverband 4.2.0
|
|
84
139
|
|
|
85
140
|
**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.
|
|
@@ -96,7 +151,7 @@ Feature Ideas:
|
|
|
96
151
|
- move from thread based reporter instance to process based instance
|
|
97
152
|
- thanks Karl Baum for much of the above mentioned work
|
|
98
153
|
- clear coverage on individual files
|
|
99
|
-
- we have a logo, thanks Dave Woodall
|
|
154
|
+
- we have a logo, thanks Dave Woodall, http://davewoodall.com
|
|
100
155
|
|
|
101
156
|
### Coverband 4.1.1
|
|
102
157
|
|
data/coverband.gemspec
CHANGED
|
@@ -28,17 +28,14 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.add_development_dependency 'm'
|
|
29
29
|
spec.add_development_dependency 'memory_profiler'
|
|
30
30
|
spec.add_development_dependency 'minitest'
|
|
31
|
+
spec.add_development_dependency 'minitest-fork_executor'
|
|
31
32
|
spec.add_development_dependency 'mocha', '~> 1.7.0'
|
|
32
33
|
spec.add_development_dependency 'rack'
|
|
33
34
|
spec.add_development_dependency 'rack-test'
|
|
34
35
|
spec.add_development_dependency 'rake'
|
|
35
36
|
spec.add_development_dependency 'resque'
|
|
36
|
-
|
|
37
|
-
spec.add_development_dependency 'minitest-reporters'
|
|
37
|
+
spec.add_development_dependency 'rubocop'
|
|
38
38
|
|
|
39
|
-
# TODO: used for benchmarking and tests I think we have other better benchmarking
|
|
40
|
-
# perhaps time to drop this and refactor.
|
|
41
|
-
spec.add_development_dependency 'classifier-reborn'
|
|
42
39
|
spec.add_development_dependency 'coveralls'
|
|
43
40
|
# add when debugging
|
|
44
41
|
# require 'byebug'; byebug
|