Skip to content

Commit 3bd3193

Browse files
committed
Add simplecov to measure test coverage of our code
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.
1 parent c557186 commit 3bd3193

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

.github/workflows/main.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,18 @@ jobs:
4040
with:
4141
ruby-version: "${{ matrix.ruby }}"
4242
bundler-cache: true
43-
- run: bundle exec rake ${{ matrix.task }}
43+
- run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }}
44+
45+
coverage:
46+
runs-on: ubuntu-latest
47+
name: "Test coverage"
48+
steps:
49+
- uses: actions/checkout@v3
50+
- uses: ruby/setup-ruby@v1
51+
with:
52+
ruby-version: "3.2"
53+
bundler-cache: true
54+
- run: bundle exec rake spec
4455

4556
edge-rubocop:
4657
runs-on: ubuntu-latest

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ pkg
1717

1818
.ruby-gemset
1919
.ruby-version
20+
21+
# simplecov generated
22+
coverage

.simplecov

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
SimpleCov.start do
4+
enable_coverage :branch
5+
minimum_coverage line: 99.86, branch: 95.33
6+
add_filter '/spec/'
7+
add_filter '/vendor/bundle/'
8+
end

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ gem 'rake'
1010
gem 'rspec', '~> 3.11'
1111
gem 'rubocop-performance', '~> 1.7'
1212
gem 'rubocop-rake', '~> 0.6'
13+
gem 'simplecov', '>= 0.19'
1314
gem 'yard'
1415

1516
local_gemfile = 'Gemfile.local'

spec/spec_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
require 'rubocop'
44
require 'rubocop/rspec/support'
55

6+
require 'simplecov' unless ENV['NO_COVERAGE']
7+
68
module SpecHelper
79
ROOT = Pathname.new(__dir__).parent.freeze
810
end

0 commit comments

Comments
 (0)