Skip to content

Commit

Permalink
Add simplecov to measure test coverage of our code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ydah committed Dec 29, 2022
1 parent c557186 commit 3bd3193
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,18 @@ jobs:
with:
ruby-version: "${{ matrix.ruby }}"
bundler-cache: true
- run: bundle exec rake ${{ matrix.task }}
- run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }}

coverage:
runs-on: ubuntu-latest
name: "Test coverage"
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- run: bundle exec rake spec

edge-rubocop:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ pkg

.ruby-gemset
.ruby-version

# simplecov generated
coverage
8 changes: 8 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

SimpleCov.start do
enable_coverage :branch
minimum_coverage line: 99.86, branch: 95.33
add_filter '/spec/'
add_filter '/vendor/bundle/'
end
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gem 'rake'
gem 'rspec', '~> 3.11'
gem 'rubocop-performance', '~> 1.7'
gem 'rubocop-rake', '~> 0.6'
gem 'simplecov', '>= 0.19'
gem 'yard'

local_gemfile = 'Gemfile.local'
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'rubocop'
require 'rubocop/rspec/support'

require 'simplecov' unless ENV['NO_COVERAGE']

module SpecHelper
ROOT = Pathname.new(__dir__).parent.freeze
end
Expand Down

0 comments on commit 3bd3193

Please sign in to comment.