Skip to content

Commit d623d27

Browse files
authored
Merge pull request #380 from puppetlabs/pdksync_"cat-1618-add_code_cov"
pdksync - "(CAT-1618) - Add code coverage to ci"
2 parents 1707d5b + 7a4e596 commit d623d27

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

.github/workflows/ci.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- "main"
77
workflow_dispatch:
88

9+
env:
10+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
11+
912
jobs:
1013
spec:
1114
strategy:
@@ -18,14 +21,15 @@ jobs:
1821
- ruby-version: '2.7'
1922
puppet_gem_version: '~> 7.0'
2023
- ruby_version: '3.2'
21-
puppet_gem_version: 'https://github.com/puppetlabs/puppet' # puppet8'
24+
puppet_gem_version: '~> 8.0'
2225
runs_on:
2326
- "ubuntu-latest"
2427
- "windows-latest"
2528
name: "spec (${{ matrix.runs_on }} ruby ${{ matrix.ruby_version }} | puppet ${{matrix.puppet_gem_version}})"
2629
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
2730
secrets: "inherit"
2831
with:
32+
rake_task: "spec:coverage"
2933
ruby_version: ${{ matrix.ruby_version }}
3034
puppet_gem_version: ${{ matrix.puppet_gem_version }}
3135
runs_on: ${{ matrix.runs_on }}

.github/workflows/nightly.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- ruby-version: '2.7'
1818
puppet_gem_version: '~> 7.0'
1919
- ruby_version: '3.2'
20-
puppet_gem_version: 'https://github.com/puppetlabs/puppet' # puppet8'
20+
puppet_gem_version: '~> 8.0'
2121
runs_on:
2222
- "ubuntu-latest"
2323
- "windows-latest"

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ group :development do
4343
gem 'serverspec'
4444
gem 'simplecov', require: false
4545
gem 'simplecov-console', require: false
46+
gem 'codecov', require: false
4647

4748
gem 'redcarpet'
4849
end

Rakefile

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ RSpec::Core::RakeTask.new(:spec) do |t|
1515
t.exclude_pattern = "spec/acceptance/**/*.rb"
1616
end
1717

18+
namespace :spec do
19+
desc 'Run RSpec code examples with coverage collection'
20+
task :coverage do
21+
ENV['COVERAGE'] = 'yes'
22+
Rake::Task['spec'].execute
23+
end
24+
end
25+
26+
1827
RSpec::Core::RakeTask.new(:acceptance) do |t|
1928
t.pattern = "spec/unit/**/*.rb"
2029
end

spec/spec_helper.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
# frozen_string_literal: true
22

33
if ENV['COVERAGE'] == 'yes'
4-
require 'codecov'
54
require 'simplecov'
65
require 'simplecov-console'
76

87
SimpleCov.formatters = [
98
SimpleCov::Formatter::HTMLFormatter,
10-
SimpleCov::Formatter::Console,
11-
SimpleCov::Formatter::Codecov
9+
SimpleCov::Formatter::Console
1210
]
1311

12+
if ENV['CI'] == 'true'
13+
require 'codecov'
14+
SimpleCov.formatters << SimpleCov::Formatter::Codecov
15+
end
16+
1417
SimpleCov.start do
1518
track_files 'lib/**/*.rb'
16-
19+
add_filter 'lib/puppet-strings/version.rb'
1720
add_filter '/spec'
1821
end
1922
end

0 commit comments

Comments
 (0)