From 2cac4b8ec22b9ddd7769a073f926885027c37fa5 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Thu, 20 Feb 2020 09:27:40 +0000 Subject: [PATCH 1/4] (maint) ignore Gemfile.lock dependabot can work directly with gemspec and Gemfile --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 448f943..75811fd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ Gemfile.local # rspec failure tracking .rspec_status + +Gemfile.lock From 93b85b8bbab38755deda5020e1b22d8c37d596e7 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Thu, 13 Feb 2020 10:57:26 +0000 Subject: [PATCH 2/4] (maint) record shared maintenance of the component --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a5d109e..fcdf05a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,2 @@ # Setting ownership to the modules team -* @puppetlabs/modules +* @puppetlabs/modules @puppetlabs/pdk From 68e78540d815ebc38b65ebf21fb04a3c3e2483ba Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Thu, 13 Feb 2020 10:56:16 +0000 Subject: [PATCH 3/4] (maint) drop ruby requirement to 2.1.0 to adjust for PDK's current deps Also adds running tests with 2.1.9 (puppet 4) and 2.4.9 (puppet 5.5) on travis. Fixes #2 --- .travis.yml | 11 ++++++++--- Gemfile | 6 ++++-- Rakefile | 17 ++++++++++++----- puppet-modulebuilder.gemspec | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index b1cb2a4..392e8d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,11 @@ os: linux language: ruby cache: bundler -rvm: - - 2.5.3 -before_install: gem install bundler -v 2.1.4 +jobs: + include: + - rvm: 2.5.7 + before_install: gem install bundler -v 2.1.4 + - rvm: 2.4.9 + before_install: gem install bundler -v 2.1.4 + - rvm: 2.1.9 + script: "bundle exec rake spec # don't try to run rubocop on ancient ruby" diff --git a/Gemfile b/Gemfile index cf2b27b..df8e09b 100644 --- a/Gemfile +++ b/Gemfile @@ -7,8 +7,10 @@ gemspec gem 'rake', '~> 12.0' gem 'rspec', '~> 3.0' -gem 'rubocop' -gem 'rubocop-rspec' +if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0') + gem 'rubocop', '~> 0.68' + gem 'rubocop-rspec', '~> 1.38' +end # Evaluate Gemfile.local and ~/.gemfile if they exist extra_gemfiles = [ diff --git a/Rakefile b/Rakefile index 07e9012..1f8df4d 100644 --- a/Rakefile +++ b/Rakefile @@ -2,12 +2,19 @@ require 'bundler/gem_tasks' require 'rspec/core/rake_task' -require 'rubocop/rake_task' +begin + # make rubocop optional to deal with ruby 2.1 + require 'rubocop/rake_task' -RSpec::Core::RakeTask.new(:spec) + RuboCop::RakeTask.new(:rubocop) do |task| + task.options = %w[-D -S -E] + end -RuboCop::RakeTask.new(:rubocop) do |task| - task.options = %w[-D -S -E] + task default: [:rubocop] +rescue LoadError => e + puts "Can't load 'rubocop/rake_task': #{e.inspect}" end -task default: [:rubocop, :spec] +RSpec::Core::RakeTask.new(:spec) + +task default: [:spec] diff --git a/puppet-modulebuilder.gemspec b/puppet-modulebuilder.gemspec index 900ca3b..fed0f33 100644 --- a/puppet-modulebuilder.gemspec +++ b/puppet-modulebuilder.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| spec.email = ['sheena@puppet.com', 'https://puppetlabs.github.io/iac/'] spec.summary = 'A gem to set up puppet-modulebuilder' spec.homepage = 'https://github.com/puppetlabs/puppet-modulebuilder' - spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0') + spec.required_ruby_version = Gem::Requirement.new('>= 2.1.0') spec.metadata['homepage_uri'] = spec.homepage spec.metadata['source_code_uri'] = 'https://github.com/puppetlabs/puppet-modulebuilder' From 3e100b731bec6585da1480bd9c8267ece52d049d Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Thu, 20 Feb 2020 10:15:37 +0000 Subject: [PATCH 4/4] (maint) add code coverage tracking --- .travis.yml | 2 ++ Gemfile | 4 ++++ appveyor.yml | 1 + spec/spec_helper.rb | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/.travis.yml b/.travis.yml index 392e8d2..b413d87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ cache: bundler jobs: include: - rvm: 2.5.7 + env: + - SIMPLECOV=yes before_install: gem install bundler -v 2.1.4 - rvm: 2.4.9 before_install: gem install bundler -v 2.1.4 diff --git a/Gemfile b/Gemfile index df8e09b..b605464 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,10 @@ gem 'rspec', '~> 3.0' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0') gem 'rubocop', '~> 0.68' gem 'rubocop-rspec', '~> 1.38' + + gem 'codecov', '~> 0.1' + gem 'simplecov', '~> 0.18' + gem 'simplecov-console', '~> 0.6' end # Evaluate Gemfile.local and ~/.gemfile if they exist diff --git a/appveyor.yml b/appveyor.yml index da2e651..86cb2ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,7 @@ --- install: - set PATH=C:\Ruby25-x64\bin;%PATH% + - set SIMPLECOV=yes - gem install bundler -v 2.1.4 - bundle -v - bundle install --retry 2 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a6fb2bb..d590c80 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,40 @@ # frozen_string_literal: true +if ENV['SIMPLECOV'] == 'yes' + begin + require 'simplecov' + require 'simplecov-console' + require 'codecov' + + SimpleCov.formatters = [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::Console, + SimpleCov::Formatter::Codecov, + ] + SimpleCov.start do + track_files 'lib/**/*.rb' + add_filter '/spec' + + # do not track vendored files + add_filter '/vendor' + add_filter '/.vendor' + + # do not track version file, as it is loaded before simplecov initialises and therefore is never gonna be tracked correctly + add_filter 'lib/puppet/modulebuilder/version.rb' + + # do not track gitignored files + # this adds about 4 seconds to the coverage check + # this could definitely be optimized + add_filter do |f| + # system returns true if exit status is 0, which with git-check-ignore means file is ignored + system("git check-ignore --quiet #{f.filename}") + end + end + rescue LoadError + raise 'Add the simplecov, simplecov-console, codecov gems to Gemfile to enable this task' + end +end + require 'puppet/modulebuilder' RSpec.configure do |config|