diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 0c29e60..f6ef0f9 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -6,5 +6,6 @@ on: jobs: tests: uses: Invoca/ruby-test-matrix-workflow/.github/workflows/ruby-test-matrix.yml@main + secrets: inherit with: pre-test-hook: "mkdir -p tmp" diff --git a/spec/simplecov_helper.rb b/spec/simplecov_helper.rb new file mode 100644 index 0000000..2e8cc2d --- /dev/null +++ b/spec/simplecov_helper.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +unless ENV["NO_COVERAGE"] == "true" + require "simplecov" + + SimpleCov.start do + add_filter "/spec/" + track_files "lib/**/*.rb" + + if ENV["GITHUB_ACTIONS"] + require "simplecov-lcov" + + SimpleCov::Formatter::LcovFormatter.config do |config| + config.report_with_single_file = true + config.single_report_path = "coverage/lcov.info" + end + + formatter SimpleCov::Formatter::LcovFormatter + else + formatter SimpleCov::Formatter::HTMLFormatter + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 270ff87..3b63d66 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,26 +1,12 @@ # frozen_string_literal: true +require_relative "simplecov_helper" + require 'rspec_junit_formatter' require 'process_settings' require 'pry' -if ENV['GITHUB_ACTIONS'].presence - require 'simplecov' - require 'simplecov-lcov' - - SimpleCov.start do - SimpleCov::Formatter::LcovFormatter.config do |c| - c.report_with_single_file = true - c.single_report_path = 'coverage/lcov.info' - end - - formatter SimpleCov::Formatter::LcovFormatter - - add_filter %w[version.rb initializer.rb] - end -end - RSpec.configure do |config| config.add_formatter :progress config.add_formatter RspecJunitFormatter, ENV['JUNIT_OUTPUT'].presence || 'spec/reports/rspec.xml'