diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index feec48d3..8b23ac07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ on: - "main" workflow_dispatch: +env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + jobs: spec: strategy: @@ -18,7 +21,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" @@ -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 }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index b7af4460..f8aae476 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -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" diff --git a/Gemfile b/Gemfile index 5cf8c0a3..4cea4dd9 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Rakefile b/Rakefile index 9a7c6f9c..0e55d365 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fc3c86fe..67402308 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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