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 66 - " main"
77 workflow_dispatch :
88
9+ env :
10+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
11+
912jobs :
13+
1014 spec :
1115 strategy :
1216 fail-fast : false
1317 matrix :
1418 ruby_version :
1519 - ' 2.7'
1620 - ' 3.2'
21+ name : " spec (ruby ${{ matrix.ruby_version }})"
1722 uses : " puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
1823 secrets : " inherit"
1924 with :
25+ rake_task : " spec:coverage"
2026 ruby_version : ${{ matrix.ruby_version }}
2127
2228 acceptance :
Original file line number Diff line number Diff line change @@ -7,6 +7,14 @@ RSpec::Core::RakeTask.new(:spec) do |t|
77 t . exclude_pattern = "spec/acceptance/**/*.rb"
88end
99
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+
1018RSpec ::Core ::RakeTask . new ( :acceptance ) do |t |
1119 t . pattern = "spec/acceptance/**/*.rb"
1220end
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33if ENV [ 'COVERAGE' ] == 'yes'
4- require 'simplecov'
5- require 'simplecov-console '
6- require 'codecov '
4+ begin
5+ require 'simplecov'
6+ require 'simplecov-console '
77
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+ ]
1512
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
1717
18- add_filter '/spec'
18+ SimpleCov . start do
19+ track_files 'lib/**/*.rb'
1920
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'
2331 end
2432end
2533
You can’t perform that action at this time.
0 commit comments