Skip to content

Commit

Permalink
"(CAT-1618) - Add code coverage to ci"
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbreen28 committed Jan 15, 2024
1 parent 1707d5b commit 4c5280e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- "main"
workflow_dispatch:

env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

jobs:
spec:
strategy:
Expand All @@ -26,6 +29,7 @@ jobs:
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
secrets: "inherit"
with:
rake_task: "spec:coverage"
ruby_version: ${{ matrix.ruby_version }}
puppet_gem_version: ${{ matrix.puppet_gem_version }}
runs_on: ${{ matrix.runs_on }}
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ group :development do
gem 'serverspec'
gem 'simplecov', require: false
gem 'simplecov-console', require: false
gem 'codecov', require: false

gem 'redcarpet'
end
Expand Down
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ RSpec::Core::RakeTask.new(:spec) do |t|
t.exclude_pattern = "spec/acceptance/**/*.rb"
end

namespace :spec do
desc 'Run RSpec code examples with coverage collection'
task :coverage do
ENV['COVERAGE'] = 'yes'
Rake::Task['spec'].execute
end
end


RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = "spec/unit/**/*.rb"
end
Expand Down
11 changes: 7 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# frozen_string_literal: true

if ENV['COVERAGE'] == 'yes'
require 'codecov'
require 'simplecov'
require 'simplecov-console'

SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Console,
SimpleCov::Formatter::Codecov
SimpleCov::Formatter::Console
]

if ENV['CI'] == 'true'
require 'codecov'
SimpleCov.formatters << SimpleCov::Formatter::Codecov
end

SimpleCov.start do
track_files 'lib/**/*.rb'

add_filter 'lib/puppet-strings/version.rb'
add_filter '/spec'
end
end
Expand Down

0 comments on commit 4c5280e

Please sign in to comment.