File tree 4 files changed +32
-21
lines changed
4 files changed +32
-21
lines changed Original file line number Diff line number Diff line change 6
6
- " main"
7
7
workflow_dispatch :
8
8
9
+ env :
10
+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
11
+
9
12
jobs :
13
+
10
14
spec :
11
15
strategy :
12
16
fail-fast : false
18
22
uses : " puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
19
23
secrets : " inherit"
20
24
with :
25
+ rake_task : " spec:coverage"
21
26
ruby_version : ${{ matrix.ruby_version }}
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ group :test do
14
14
15
15
gem 'codecov'
16
16
gem 'simplecov'
17
+ gem 'simplecov-console'
17
18
end
18
19
19
20
group :development do
Original file line number Diff line number Diff line change @@ -7,5 +7,13 @@ require 'yard'
7
7
RSpec ::Core ::RakeTask . new ( :spec )
8
8
task :default => :spec
9
9
10
+ namespace :spec do
11
+ desc 'Run RSpec code examples with coverage collection'
12
+ task :coverage do
13
+ ENV [ 'COVERAGE' ] = 'yes'
14
+ Rake ::Task [ 'spec' ] . execute
15
+ end
16
+ end
17
+
10
18
YARD ::Rake ::YardocTask . new do |t |
11
19
end
Original file line number Diff line number Diff line change 5
5
require 'ostruct'
6
6
7
7
if ENV [ 'COVERAGE' ] == 'yes'
8
- require 'simplecov'
9
-
10
- if ENV [ 'CI' ] == 'true'
11
- require 'codecov'
12
- SimpleCov . formatter = SimpleCov ::Formatter ::Codecov
13
- else
8
+ begin
9
+ require 'simplecov'
10
+ require 'simplecov-console'
14
11
SimpleCov . formatters = [
15
- SimpleCov ::Formatter ::HTMLFormatter
12
+ SimpleCov ::Formatter ::HTMLFormatter ,
13
+ SimpleCov ::Formatter ::Console
16
14
]
17
- end
18
- SimpleCov . start do
19
- track_files 'lib/**/*.rb'
20
-
21
- add_filter '/spec'
15
+ if ENV [ 'CI' ] == 'true'
16
+ require 'codecov'
17
+ SimpleCov . formatters << SimpleCov ::Formatter ::Codecov
18
+ end
22
19
23
- # do not track vendored files
24
- add_filter '/vendor'
25
- add_filter '/.vendor'
20
+ SimpleCov . start do
21
+ track_files 'lib/**/*.rb'
26
22
27
- # do not track gitignored files
28
- # this adds about 4 seconds to the coverage check
29
- # this could definitely be optimized
30
- add_filter do |f |
31
- # system returns true if exit status is 0, which with git-check-ignore means file is ignored
32
- system ( "git check-ignore --quiet #{ f . filename } " )
23
+ add_filter '/spec'
24
+ add_filter 'lib/puppet_litmus/version.rb'
25
+ # do not track vendored files
26
+ add_filter '/vendor'
27
+ add_filter '/.vendor'
33
28
end
29
+ rescue LoadError
30
+ raise 'Add the simplecov, simplecov-console, and codecov gems to Gemfile to enable this task'
34
31
end
35
32
end
36
33
You can’t perform that action at this time.
0 commit comments