-
-
Notifications
You must be signed in to change notification settings - Fork 281
Add simplecov to measure test coverage of our code #1534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -17,3 +17,6 @@ pkg | |||
|
|||
.ruby-gemset | |||
.ruby-version | |||
|
|||
# simplecov generated | |||
coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo] Avoid git management of generated files.
spec/spec_helper.rb
Outdated
require 'simplecov' | ||
|
||
SimpleCov.start do | ||
enable_coverage :branch | ||
add_filter '/spec/' | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo] Currently, rspec always measures coverage when it is run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Gemfile
Outdated
@@ -10,6 +10,7 @@ gem 'rake' | |||
gem 'rspec', '~> 3.11' | |||
gem 'rubocop-performance', '~> 1.7' | |||
gem 'rubocop-rake', '~> 0.6' | |||
gem 'simplecov' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're at it, have you tried https://github.com/grosser/single_cov ?
I have no experience with it, and have no idea if it provides such a pretty report as Simplecov.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# spec/spec_helper.rb
SingleCov.setup :rspec
The following was going to need to be added to all specs.
require 'spec_helper'
SingleCov.covered!
If there are areas not covered by the test as shown below, the following output is likely to be present.
lib/rubocop/cop/rspec/align_left_let_brace.rb new uncovered lines introduced (1 current vs 0 configured)
Lines missing coverage:
lib/rubocop/cop/rspec/align_left_let_brace.rb:25
Personally, I think simplecov looks good, what do you think?
@ydah can you add minimal coverage? |
This comment was marked as resolved.
This comment was marked as resolved.
What I meant is to add |
This comment was marked as resolved.
This comment was marked as resolved.
e8a3b50
to
a5f3c41
Compare
|
||
SimpleCov.start do | ||
enable_coverage :branch | ||
minimum_coverage line: 99.86, branch: 95.33 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo] Current coverage is specified.
@@ -3,6 +3,8 @@ | |||
require 'rubocop' | |||
require 'rubocop/rspec/support' | |||
|
|||
require 'simplecov' unless ENV['NO_COVERAGE'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo] Turned on/off by environment variable, but usually enabled coverage
with: | ||
ruby-version: "${{ matrix.ruby }}" | ||
bundler-cache: true | ||
- run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo] Since there is no need to measure coverage for each version, it is disabled here.
bundler-cache: true | ||
- run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }} | ||
|
||
coverage: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo] New coverage job is being created only check coverage.
1dbb3f9
to
4d6e015
Compare
@nijikon I added minimal coverage to match the current coverage. What do you think? |
@ydah looks good on my end, let's merge and see how this will work |
@pirj RSpec will fail if the coverage is below the minimum. So I don't seem to need to do anything on the GitHub Actions side, what do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This PR is add [simplecov](https://github.com/simplecov-ruby/simplecov) to measure test coverage of our code Branch coverage is enabled, but [minimum coverage by file](https://github.com/simplecov-ruby/simplecov#minimum-coverage-by-file) is also enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 👍
I'll leave the final decision to @bquorning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
This PR is add simplecov to measure test coverage of our code.
Branch coverage is enabled, but minimum coverage by file is enabled.
Below the lowest of the current coverage, RSpec will fail as shown below.
This keeps the test coverage of our code high.
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).