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

Require Ruby 2.3+ / InSpec 1.47+ and update dev deps #221

Merged
merged 14 commits into from
Jan 23, 2019
21 changes: 11 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
sudo: required
branches:
only:
- master
language: ruby
cache: bundler
dist: xenial
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:
- 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: 2.6.0
- rvm: ruby-head
allow_failures:
- rvm: ruby-head
12 changes: 4 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link

@jerryaldrichiii jerryaldrichiii Jan 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ❤️you so much for these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worked for a company that changed the case of their name to be all lowercase (so cool). I spent years slowly fixing it all.

- 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)
Expand Down Expand Up @@ -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:**
Expand Down Expand Up @@ -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)*
- Add WinRM support to Verifier \(pending full support in Train\). [\#5](https://github.com/inspec/kitchen-inspec/pull/5) ([fnichol](https://github.com/fnichol))
18 changes: 4 additions & 14 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@
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
gem "guard-rspec", require: nil
gem "guard-rubocop", require: nil
end

group :test do
gem "bundler", "~> 1.10"
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 "codeclimate-test-reporter", :require => nil
gem "rspec"
gem "simplecov", "~> 0.12"
gem "countloc", "~> 0.4"
Expand All @@ -33,5 +24,4 @@ end

group :tools do
gem "pry", "~> 0.10"
gem "github_changelog_generator", "1.13.1"
end
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.27.0
1.0.0
7 changes: 3 additions & 4 deletions kitchen-inspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ 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.1.0"
spec.add_dependency "inspec", ">=0.34.0", "<4.0.0"
spec.required_ruby_version = ">= 2.3.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
File renamed without changes.
8 changes: 3 additions & 5 deletions lib/kitchen/verifier/inspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Author:: Fletcher Nichol (<[email protected]>)
# Author:: Christoph Hartmann (<[email protected]>)
#
# 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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
29 changes: 7 additions & 22 deletions spec/kitchen/verifier/inspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -372,8 +362,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(
Expand All @@ -389,8 +378,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(
Expand All @@ -403,8 +391,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)
Expand All @@ -415,8 +402,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)
Expand Down Expand Up @@ -471,7 +457,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"),
}
Expand All @@ -485,10 +471,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
Expand Down
7 changes: 2 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author:: Fletcher Nichol (<[email protected]>)
#
# 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.
Expand All @@ -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"
Expand Down