Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdksync - "(CAT-1618) - Add code coverage to ci" #380

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .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 @@ -18,14 +21,15 @@ jobs:
- ruby-version: '2.7'
puppet_gem_version: '~> 7.0'
- ruby_version: '3.2'
puppet_gem_version: 'https://github.com/puppetlabs/puppet' # puppet8'
puppet_gem_version: '~> 8.0'
runs_on:
- "ubuntu-latest"
- "windows-latest"
name: "spec (${{ matrix.runs_on }} ruby ${{ matrix.ruby_version }} | puppet ${{matrix.puppet_gem_version}})"
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
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- ruby-version: '2.7'
puppet_gem_version: '~> 7.0'
- ruby_version: '3.2'
puppet_gem_version: 'https://github.com/puppetlabs/puppet' # puppet8'
puppet_gem_version: '~> 8.0'
runs_on:
- "ubuntu-latest"
- "windows-latest"
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