From 326bcdd9830bf22843fcb7c70904c034d839f920 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:22:51 -0800 Subject: [PATCH 01/14] Remove github_changelog_generator dep We use expeditor now Signed-off-by: Tim Smith --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index b6e84bb..28992bc 100644 --- a/Gemfile +++ b/Gemfile @@ -33,5 +33,4 @@ end group :tools do gem "pry", "~> 0.10" - gem "github_changelog_generator", "1.13.1" end From 3a90c1555e2c86bca59abe50c49cf98eca51283e Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:23:11 -0800 Subject: [PATCH 02/14] Remove bundler dep in the gemfile This does nothing, but break things on bundler 2.x Signed-off-by: Tim Smith --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 28992bc..ee97415 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,6 @@ group :guard do end group :test do - gem "bundler", "~> 1.10" gem "minitest", "~> 5.5" gem "rake", "~> 11.0" gem "chefstyle", "0.4.0" From 910b820ae5a58303ed1b5d48a144ced13d19d153 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:23:36 -0800 Subject: [PATCH 03/14] Require Ruby 2.3 or later Remove support for EOL Ruby Signed-off-by: Tim Smith --- Gemfile | 7 ------- kitchen-inspec.gemspec | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index ee97415..5e80135 100644 --- a/Gemfile +++ b/Gemfile @@ -2,13 +2,6 @@ source "https://rubygems.org" gemspec -if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2.2") - gem "json", "< 2.0" - gem "rack", "< 2.0" - gem "ruby_dep", "< 1.4.0" - gem "listen", "< 3.0.0" -end - group :guard do gem "guard-rspec", :require => nil gem "guard-rubocop", :require => nil diff --git a/kitchen-inspec.gemspec b/kitchen-inspec.gemspec index aa95218..1755af7 100644 --- a/kitchen-inspec.gemspec +++ b/kitchen-inspec.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0") .grep(/LICENSE|^lib|/) spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 2.1.0" + spec.required_ruby_version = ">= 2.3.0" spec.add_dependency "inspec", ">=0.34.0", "<4.0.0" spec.add_dependency "test-kitchen", "~> 1.6" spec.add_dependency "hashie", "~> 3.4" From 1011c9c5eb52a4c8cbd383c6f4c5d3fadd24acc6 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:25:56 -0800 Subject: [PATCH 04/14] Remove unused Code Climate support We're not using this anymore. Stop carrying around the baggage. Signed-off-by: Tim Smith --- Gemfile | 1 - spec/spec_helper.rb | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 5e80135..d2b964b 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,6 @@ group :test do gem "rake", "~> 11.0" gem "chefstyle", "0.4.0" gem "concurrent-ruby", "~> 1.0" - gem "codeclimate-test-reporter", :require => nil gem "rspec" gem "simplecov", "~> 0.12" gem "countloc", "~> 0.4" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5c47d7b..ca8c77d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,7 @@ # # Author:: Fletcher Nichol () # -# Copyright (C) 2015, Chef Software Inc. +# Copyright (C) 2015-2018, Chef Software Inc. # # Licensed under the Apache License, Version 2.0 (the 'License"); # you may not use this file except in compliance with the License. @@ -16,10 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -if ENV["CODECLIMATE_REPO_TOKEN"] - require "codeclimate-test-reporter" - CodeClimate::TestReporter.start -elsif ENV["COVERAGE"] +if ENV["COVERAGE"] require "simplecov" SimpleCov.profiles.define "gem" do command_name "Specs" From 498260b873eaae378afb58797d5751f506f4b8b1 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:26:23 -0800 Subject: [PATCH 05/14] Update rake and chefstyle Bring our deps up to date. Signed-off-by: Tim Smith --- Gemfile | 8 ++++---- Rakefile | 6 +++--- lib/kitchen/verifier/inspec.rb | 2 +- spec/kitchen/verifier/inspec_spec.rb | 25 ++++++++++--------------- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index d2b964b..0a7f585 100644 --- a/Gemfile +++ b/Gemfile @@ -3,14 +3,14 @@ source "https://rubygems.org" gemspec group :guard do - gem "guard-rspec", :require => nil - gem "guard-rubocop", :require => nil + gem "guard-rspec", require: nil + gem "guard-rubocop", require: nil end group :test do gem "minitest", "~> 5.5" - gem "rake", "~> 11.0" - gem "chefstyle", "0.4.0" + gem "rake", "~> 12.0" + gem "chefstyle", "0.12.0" gem "concurrent-ruby", "~> 1.0" gem "rspec" gem "simplecov", "~> 0.12" diff --git a/Rakefile b/Rakefile index 8e5396f..d3571b3 100644 --- a/Rakefile +++ b/Rakefile @@ -9,7 +9,7 @@ require "rubocop/rake_task" RSpec::Core::RakeTask.new(:spec) desc "Run all test suites" -task :test => [:spec] +task test: [:spec] # Rubocop desc "Run Rubocop lint checks" @@ -30,9 +30,9 @@ task :stats do end desc "Run all quality tasks" -task :quality => [:lint, :stats] +task quality: [:lint, :stats] -task :default => [:test, :quality] +task default: [:test, :quality] # Automatically generate a changelog for this project. Only loaded if # the necessary gem is installed. diff --git a/lib/kitchen/verifier/inspec.rb b/lib/kitchen/verifier/inspec.rb index cfc75f8..5033af1 100644 --- a/lib/kitchen/verifier/inspec.rb +++ b/lib/kitchen/verifier/inspec.rb @@ -142,7 +142,7 @@ def local_suite_files base = File.join(base, "inspec") if legacy_mode # only return the directory if it exists - Pathname.new(base).exist? ? [{ :path => base }] : [] + Pathname.new(base).exist? ? [{ path: base }] : [] end # Takes config[:inspec_tests] and modifies any value with a key of :path by adding the full path diff --git a/spec/kitchen/verifier/inspec_spec.rb b/spec/kitchen/verifier/inspec_spec.rb index cb99152..09c8665 100644 --- a/spec/kitchen/verifier/inspec_spec.rb +++ b/spec/kitchen/verifier/inspec_spec.rb @@ -122,9 +122,9 @@ it "inspec version warn for backend_cache" do config[:backend_cache] = true stub_const("Inspec::VERSION", "1.46.0") - expect_any_instance_of(Logger).to receive(:warn). - with("backend_cache requires InSpec version >= 1.47.0"). - and_return("captured") + expect_any_instance_of(Logger).to receive(:warn) + .with("backend_cache requires InSpec version >= 1.47.0") + .and_return("captured") config = verifier.send(:runner_options, transport) expect(config.to_hash).to include(backend_cache: true) end @@ -372,8 +372,7 @@ allow(Inspec::Runner).to receive(:new).and_return(runner) - expect(runner).to receive(:add_target).with({ :path => - File.join( + expect(runner).to receive(:add_target).with({ path: File.join( config[:test_base_path], "germany" ) }, hash_including( @@ -389,8 +388,7 @@ allow(Inspec::Runner).to receive(:new).and_return(runner) - expect(runner).to receive(:add_target).with({ :path => - File.join( + expect(runner).to receive(:add_target).with({ path: File.join( config[:test_base_path], "germany" ) }, hash_including( @@ -403,8 +401,7 @@ it "find test directory for runner" do ensure_suite_directory("germany") allow(Inspec::Runner).to receive(:new).and_return(runner) - expect(runner).to receive(:add_target).with({ :path => - File.join( + expect(runner).to receive(:add_target).with({ path: File.join( config[:test_base_path], "germany" ) }, anything) @@ -415,8 +412,7 @@ it "find test directory for runner if legacy" do create_legacy_test_directories allow(Inspec::Runner).to receive(:new).and_return(runner) - expect(runner).to receive(:add_target).with({ :path => - File.join( + expect(runner).to receive(:add_target).with({ path: File.join( config[:test_base_path], "germany", "inspec" ) }, anything) @@ -471,7 +467,7 @@ let(:config) do { - inspec_tests: [{ :url => "https://github.com/nathenharvey/tmp_compliance_profile" }], + inspec_tests: [{ url: "https://github.com/nathenharvey/tmp_compliance_profile" }], kitchen_root: kitchen_root, test_base_path: File.join(kitchen_root, "test", "integration"), } @@ -485,10 +481,9 @@ it "find test directory and remote profile" do ensure_suite_directory("local") allow(Inspec::Runner).to receive(:new).and_return(runner) - expect(runner).to receive(:add_target).with({ :path => - File.join(config[:test_base_path], "local") }, anything) + expect(runner).to receive(:add_target).with({ path: File.join(config[:test_base_path], "local") }, anything) expect(runner).to receive(:add_target).with( - { :url => "https://github.com/nathenharvey/tmp_compliance_profile" }, anything) + { url: "https://github.com/nathenharvey/tmp_compliance_profile" }, anything) verifier.call({}) end end From 60a4284defdd3ed8c316ff6ffe93e07a83faf36a Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:29:56 -0800 Subject: [PATCH 06/14] Rename the kitchen file No one likes hidden files. Signed-off-by: Tim Smith --- .kitchen.yml => kitchen.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .kitchen.yml => kitchen.yml (100%) diff --git a/.kitchen.yml b/kitchen.yml similarity index 100% rename from .kitchen.yml rename to kitchen.yml From 006f1b9db3665c054be92f9481e964e910fd8071 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:37:50 -0800 Subject: [PATCH 07/14] Require InSpec 1.47+ Since we ship kitchen-inspec in DK for 99.9% of users they already have a fully up-to-date InSpec. This just allows us to remove a conditional and a test. Signed-off-by: Tim Smith --- kitchen-inspec.gemspec | 2 +- lib/kitchen/verifier/inspec.rb | 2 -- spec/kitchen/verifier/inspec_spec.rb | 10 ---------- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/kitchen-inspec.gemspec b/kitchen-inspec.gemspec index 1755af7..5f96db1 100644 --- a/kitchen-inspec.gemspec +++ b/kitchen-inspec.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| .grep(/LICENSE|^lib|/) spec.require_paths = ["lib"] spec.required_ruby_version = ">= 2.3.0" - spec.add_dependency "inspec", ">=0.34.0", "<4.0.0" + spec.add_dependency "inspec", ">=1.47.0", "<4.0.0" spec.add_dependency "test-kitchen", "~> 1.6" spec.add_dependency "hashie", "~> 3.4" end diff --git a/lib/kitchen/verifier/inspec.rb b/lib/kitchen/verifier/inspec.rb index 5033af1..78795e2 100644 --- a/lib/kitchen/verifier/inspec.rb +++ b/lib/kitchen/verifier/inspec.rb @@ -207,8 +207,6 @@ def runner_options(transport, state = {}, platform = nil, suite = nil) # rubocop # check to make sure we have a valid version for caching if config[:backend_cache] - backend_cache_msg = "backend_cache requires InSpec version >= 1.47.0" - logger.warn backend_cache_msg if Gem::Version.new(::Inspec::VERSION) < Gem::Version.new("1.47.0") runner_options[:backend_cache] = config[:backend_cache] else # default to false until we default to true in inspec diff --git a/spec/kitchen/verifier/inspec_spec.rb b/spec/kitchen/verifier/inspec_spec.rb index 09c8665..fff13c2 100644 --- a/spec/kitchen/verifier/inspec_spec.rb +++ b/spec/kitchen/verifier/inspec_spec.rb @@ -118,16 +118,6 @@ config = verifier.send(:runner_options, transport) expect(config.to_hash).to include(backend_cache: false) end - - it "inspec version warn for backend_cache" do - config[:backend_cache] = true - stub_const("Inspec::VERSION", "1.46.0") - expect_any_instance_of(Logger).to receive(:warn) - .with("backend_cache requires InSpec version >= 1.47.0") - .and_return("captured") - config = verifier.send(:runner_options, transport) - expect(config.to_hash).to include(backend_cache: true) - end end describe "#finalize_config!" do From 39b7f19e6eab513c4912b278d1ec8b9574189227 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:41:29 -0800 Subject: [PATCH 08/14] Fix capitalization of InSpec Signed-off-by: Tim Smith --- CHANGELOG.md | 12 ++++-------- lib/kitchen/verifier/inspec.rb | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd21619..99e03af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,13 +134,13 @@ - \[QUESTION\] kitchen-inspec formatter [\#147](https://github.com/inspec/kitchen-inspec/issues/147) - Executing inspec against a container from within the host [\#145](https://github.com/inspec/kitchen-inspec/issues/145) -- Option to specify path to Inspec test with kitchen-inspec [\#139](https://github.com/inspec/kitchen-inspec/issues/139) +- Option to specify path to InSpec test with kitchen-inspec [\#139](https://github.com/inspec/kitchen-inspec/issues/139) - False attribute value is not initializing [\#138](https://github.com/inspec/kitchen-inspec/issues/138) - Failed to complete \#verify action: \[no implicit conversion of nil into String\] [\#135](https://github.com/inspec/kitchen-inspec/issues/135) - Using tags/versioning for supermarket inspec profiles [\#134](https://github.com/inspec/kitchen-inspec/issues/134) - chef exec kitchen verify fails for inspec tests [\#132](https://github.com/inspec/kitchen-inspec/issues/132) - Intermittent SSH failures [\#127](https://github.com/inspec/kitchen-inspec/issues/127) -- Inspec Test Location [\#124](https://github.com/inspec/kitchen-inspec/issues/124) +- InSpec Test Location [\#124](https://github.com/inspec/kitchen-inspec/issues/124) - Output file support for multiple platforms and multiple test suites [\#121](https://github.com/inspec/kitchen-inspec/issues/121) - Custom inspec resources not loaded: 'undefined method' [\#120](https://github.com/inspec/kitchen-inspec/issues/120) - kitchen ec2 verifier broken [\#106](https://github.com/inspec/kitchen-inspec/issues/106) @@ -424,7 +424,7 @@ **Closed issues:** -- Inspec does not gracefully allow transports other than winrm and ssh. [\#31](https://github.com/inspec/kitchen-inspec/issues/31) +- InSpec does not gracefully allow transports other than winrm and ssh. [\#31](https://github.com/inspec/kitchen-inspec/issues/31) - Specify inspec output formats in .kitchen.yml [\#26](https://github.com/inspec/kitchen-inspec/issues/26) **Merged pull requests:** @@ -483,8 +483,4 @@ **Fixed bugs:** -- Add WinRM support to Verifier \(pending full support in Train\). [\#5](https://github.com/inspec/kitchen-inspec/pull/5) ([fnichol](https://github.com/fnichol)) - - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file +- Add WinRM support to Verifier \(pending full support in Train\). [\#5](https://github.com/inspec/kitchen-inspec/pull/5) ([fnichol](https://github.com/fnichol)) \ No newline at end of file diff --git a/lib/kitchen/verifier/inspec.rb b/lib/kitchen/verifier/inspec.rb index 78795e2..cb26fc4 100644 --- a/lib/kitchen/verifier/inspec.rb +++ b/lib/kitchen/verifier/inspec.rb @@ -3,7 +3,7 @@ # Author:: Fletcher Nichol () # Author:: Christoph Hartmann () # -# Copyright (C) 2015, Chef Software Inc. +# Copyright (C) 2015-2019, Chef Software Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ def call(state) exit_code = runner.run # 101 is a success as well (exit with no fails but has skipped controls) return if exit_code == 0 || exit_code == 101 - raise ActionFailed, "Inspec Runner returns #{exit_code}" + raise ActionFailed, "InSpec Runner returns #{exit_code}" end private From 800551266015ef59dc5775728994cfc99854ff46 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:46:30 -0800 Subject: [PATCH 09/14] Update ruby versions to test in Travis Signed-off-by: Tim Smith --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7de0e8e..304edc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,28 +14,28 @@ before_install: - bundle --version matrix: include: - - rvm: 2.3.7 - - rvm: 2.4.4 + - rvm: 2.3.8 + - rvm: 2.4.5 bundler_args: "--without guard tools" script: bundle exec rake $SUITE env: SUITE="test:integration" OS='default profile contains_inspec' - - rvm: 2.4.4 + - rvm: 2.4.5 bundler_args: "--without guard tools" script: bundle exec rake $SUITE env: SUITE="test:integration" OS='backwards' - - rvm: 2.4.4 + - rvm: 2.4.5 bundler_args: "--without guard tools" script: bundle exec rake $SUITE env: SUITE="test:integration" OS='duplicates' - - rvm: 2.4.4 + - rvm: 2.4.5 bundler_args: "--without guard tools" script: bundle exec rake $SUITE env: SUITE="test:integration" OS='supermarket' - - rvm: 2.4.4 + - rvm: 2.4.5 bundler_args: "--without guard tools" script: bundle exec rake $SUITE env: SUITE="test:integration" OS='attributes-inline attributes-file' - - rvm: 2.5.1 + - rvm: 2.5.3 - rvm: ruby-head allow_failures: - rvm: ruby-head From c0944edc208383caa5ce0e487358b44a8710a286 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:49:33 -0800 Subject: [PATCH 10/14] Force the bundler install in Travis and install the integration gems We need these gems for testing in Travis Signed-off-by: Tim Smith --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 304edc4..4d268ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,11 @@ language: ruby cache: bundler services: - docker -bundler_args: "--without integration guard tools" +bundler_args: "--without guard tools" before_install: - gem update --system - gem --version - - rvm @global do gem install bundler + - rvm @global do gem install bundler -f - bundle --version matrix: include: From 40c1cd2e9d9f9b7cf5a942cfc2a47a3bef5a65a0 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:50:06 -0800 Subject: [PATCH 11/14] Update version to 1.0.0 Signed-off-by: Tim Smith --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 81566e4..3eefcb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.27.0 \ No newline at end of file +1.0.0 From 733a11ed9a627d3d2e8aa064edba8fe9416ee827 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:53:49 -0800 Subject: [PATCH 12/14] Properly limit the files we ship in the gem The extra `|` was catching everything Signed-off-by: Tim Smith --- kitchen-inspec.gemspec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kitchen-inspec.gemspec b/kitchen-inspec.gemspec index 5f96db1..75f2752 100644 --- a/kitchen-inspec.gemspec +++ b/kitchen-inspec.gemspec @@ -14,8 +14,7 @@ Gem::Specification.new do |spec| spec.description = spec.summary spec.homepage = "https://github.com/inspec/kitchen-inspec" - spec.files = `git ls-files -z`.split("\x0") - .grep(/LICENSE|^lib|/) + spec.files = `git ls-files -z`.split("\x0").grep(/LICENSE|^lib/) spec.require_paths = ["lib"] spec.required_ruby_version = ">= 2.3.0" spec.add_dependency "inspec", ">=1.47.0", "<4.0.0" From e0850d81326c4bcf0822a353251a4f507c966bf4 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:55:58 -0800 Subject: [PATCH 13/14] Test on xenial in Travis Also disable sudo since they ignore this config now. Signed-off-by: Tim Smith --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4d268ca..4ddab22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ -sudo: required branches: only: - master language: ruby cache: bundler +dist: xenial services: - docker bundler_args: "--without guard tools" From c4fc9164236314d6f342de267d08e3277920925c Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 18 Jan 2019 23:57:26 -0800 Subject: [PATCH 14/14] Add Ruby 2.6.0 testing to Travis Make sure we test on everything we support Signed-off-by: Tim Smith --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4ddab22..61f1872 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ matrix: script: bundle exec rake $SUITE env: SUITE="test:integration" OS='attributes-inline attributes-file' - rvm: 2.5.3 + - rvm: 2.6.0 - rvm: ruby-head allow_failures: - rvm: ruby-head