File tree Expand file tree Collapse file tree 3 files changed +37
-15
lines changed Expand file tree Collapse file tree 3 files changed +37
-15
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
13
17
matrix :
14
18
ruby_version :
15
19
- ' 2.7'
16
20
- ' 3.2'
21
+ name : " spec (ruby ${{ matrix.ruby_version }})"
17
22
uses : " puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
18
23
secrets : " inherit"
19
24
with :
25
+ rake_task : " spec:coverage"
20
26
ruby_version : ${{ matrix.ruby_version }}
21
27
22
28
acceptance :
Original file line number Diff line number Diff line change @@ -7,6 +7,14 @@ RSpec::Core::RakeTask.new(:spec) do |t|
7
7
t . exclude_pattern = "spec/acceptance/**/*.rb"
8
8
end
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
RSpec ::Core ::RakeTask . new ( :acceptance ) do |t |
11
19
t . pattern = "spec/acceptance/**/*.rb"
12
20
end
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
if ENV [ 'COVERAGE' ] == 'yes'
4
- require 'simplecov'
5
- require 'simplecov-console '
6
- require 'codecov '
4
+ begin
5
+ require 'simplecov'
6
+ require 'simplecov-console '
7
7
8
- SimpleCov . formatters = [
9
- SimpleCov ::Formatter ::HTMLFormatter ,
10
- SimpleCov ::Formatter ::Console ,
11
- SimpleCov ::Formatter ::Codecov
12
- ]
13
- SimpleCov . start do
14
- track_files 'lib/**/*.rb'
8
+ SimpleCov . formatters = [
9
+ SimpleCov ::Formatter ::HTMLFormatter ,
10
+ SimpleCov ::Formatter ::Console
11
+ ]
15
12
16
- add_filter 'lib/puppetlabs_spec_helper/version.rb'
13
+ if ENV [ 'CI' ] == 'true'
14
+ require 'codecov'
15
+ SimpleCov . formatters << SimpleCov ::Formatter ::Codecov
16
+ end
17
17
18
- add_filter '/spec'
18
+ SimpleCov . start do
19
+ track_files 'lib/**/*.rb'
19
20
20
- # do not track vendored files
21
- add_filter '/vendor'
22
- add_filter '/.vendor'
21
+ add_filter 'lib/puppetlabs_spec_helper/version.rb'
22
+
23
+ add_filter '/spec'
24
+
25
+ # do not track vendored files
26
+ add_filter '/vendor'
27
+ add_filter '/.vendor'
28
+ end
29
+ rescue LoadError
30
+ raise 'Add the simplecov, simplecov-console, codecov gems to Gemfile to enable this task'
23
31
end
24
32
end
25
33
You can’t perform that action at this time.
0 commit comments