File tree Expand file tree Collapse file tree 4 files changed +35
-8
lines changed Expand file tree Collapse file tree 4 files changed +35
-8
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 :
10
13
11
14
spec :
19
22
uses : " puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
20
23
secrets : " inherit"
21
24
with :
25
+ rake_task : " spec:coverage"
22
26
ruby_version : ${{ matrix.ruby_version }}
23
27
24
28
acceptance :
Original file line number Diff line number Diff line change @@ -10,8 +10,9 @@ group :test do
10
10
gem 'json'
11
11
12
12
gem 'rspec-json_expectations' , '~> 1.4'
13
-
14
- gem 'simplecov' , :require => false if ENV [ 'COVERAGE' ] == 'yes'
13
+ gem 'simplecov' , :require => false
14
+ gem 'simplecov-console' , :require => false
15
+ gem 'codecov' , :require => false
15
16
end
16
17
17
18
group :acceptance do
Original file line number Diff line number Diff line change @@ -27,6 +27,14 @@ rescue LoadError
27
27
# Gem not present
28
28
end
29
29
30
+ namespace :spec do
31
+ desc 'Run RSpec code examples with coverage collection'
32
+ task :coverage do
33
+ ENV [ 'COVERAGE' ] = 'yes'
34
+ Rake ::Task [ 'spec' ] . execute
35
+ end
36
+ end
37
+
30
38
RSpec ::Core ::RakeTask . new ( :spec ) do |t |
31
39
t . exclude_pattern = 'spec/acceptance/**/*_spec.rb'
32
40
end
Original file line number Diff line number Diff line change 1
1
# Disable GitHub Actions reporting since it breaks the test suite
2
2
ENV . delete ( 'GITHUB_ACTION' )
3
3
4
- if ENV [ 'COVERAGE' ] == 'yes' && RUBY_VERSION . start_with? ( '2.7.' )
5
- require 'simplecov'
6
- SimpleCov . start do
7
- add_filter ( '/spec/' )
8
- add_filter ( '/vendor/' )
9
- add_group ( 'Checks' , 'lib/puppet-lint/plugins' )
4
+ if ENV [ 'COVERAGE' ] == 'yes'
5
+ begin
6
+ require 'simplecov'
7
+ require 'simplecov-console'
8
+ SimpleCov . formatters = [
9
+ SimpleCov ::Formatter ::HTMLFormatter ,
10
+ SimpleCov ::Formatter ::Console ,
11
+ ]
12
+ if ENV [ 'CI' ] == 'true'
13
+ require 'codecov'
14
+ SimpleCov . formatters << SimpleCov ::Formatter ::Codecov
15
+ end
16
+
17
+ SimpleCov . start do
18
+ add_filter ( '/spec/' )
19
+ add_filter ( '/vendor/' )
20
+ add_group ( 'Checks' , 'lib/puppet-lint/plugins' )
21
+ end
22
+ rescue LoadError
23
+ raise 'Add the simplecov, simplecov-console, codecov gems to Gemfile to enable this task'
10
24
end
11
25
end
12
26
You can’t perform that action at this time.
0 commit comments