diff --git a/Gemfile b/Gemfile index 93742e84..55314258 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,23 @@ source 'https://rubygems.org' -gem 'chef' -gem 'berkshelf', '~> 2.0' +gem 'berkshelf', '~> 3.0' +gem 'chef', '~> 11.12' +gem 'chefspec', '~> 3.4' +gem 'foodcritic', '~> 3.0' +gem 'thor-foodcritic' +gem 'rake' +gem 'rubocop', '~> 0.18.1' + +group :development do + gem 'guard' + gem 'guard-rspec' + gem 'guard-kitchen' + gem 'guard-rubocop' + gem 'guard-foodcritic' +end group :integration do gem 'test-kitchen', '~> 1.0' - gem 'kitchen-vagrant', '~> 0.11' - gem 'busser' - gem 'busser-serverspec' + gem 'kitchen-vagrant' gem 'kitchen-sharedtests', '~> 0.2.0' end - -gem "foodcritic", "~> 3.0.3" diff --git a/Gemfile.lock b/Gemfile.lock index 811b191e..8fca2381 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,28 +1,25 @@ GEM remote: https://rubygems.org/ specs: - activesupport (3.2.18) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) addressable (2.3.6) - akami (1.2.2) - gyoku (>= 0.4.0) - nokogiri - amq-protocol (1.9.2) - berkshelf (2.0.16) - activesupport (~> 3.2.0) + ast (2.0.0) + berkshelf (3.1.2) addressable (~> 2.3.4) + berkshelf-api-client (~> 1.2) + buff-config (~> 0.4) + buff-extensions (~> 0.4) buff-shell_out (~> 0.1) - chozo (>= 0.6.1) - faraday (~> 0.8.0) - faraday (~> 0.8.5) - hashie (>= 2.0.2) + celluloid (~> 0.16.0.pre) + celluloid-io (~> 0.16.0.pre) + faraday (~> 0.9.0) minitar (~> 0.5.4) - rbzip2 (~> 0.2.0) + octokit (~> 3.0) retryable (~> 1.3.3) - ridley (~> 1.7.0) - solve (~> 0.8.2) - thor (~> 0.18.0) + ridley (~> 3.1) + solve (~> 1.1) + thor (~> 0.18) + berkshelf-api-client (1.2.0) + faraday (~> 0.9.0) buff-config (0.4.0) buff-extensions (~> 0.3) varia_model (~> 0.1) @@ -31,37 +28,50 @@ GEM buff-ruby_engine (0.1.0) buff-shell_out (0.1.1) buff-ruby_engine (~> 0.1.0) - builder (3.2.2) - bunny (1.2.1) - amq-protocol (>= 1.9.2) - busser (0.6.2) - thor (<= 0.19.0) - busser-serverspec (0.2.6) - busser - celluloid (0.15.2) - timers (~> 1.1.0) - celluloid-io (0.15.0) - celluloid (>= 0.15.0) - nio4r (>= 0.5.0) - chef (0.8.10) - bunny (>= 0.6.0) - erubis - extlib + celluloid (0.16.0.pre) + timers (~> 2.0.0) + celluloid-io (0.16.0.pre) + celluloid (>= 0.16.0.pre) + nio4r (>= 1.0.0) + chef (11.12.4) + chef-zero (~> 2.0, >= 2.0.2) + diff-lcs (~> 1.2, >= 1.2.4) + erubis (~> 2.7) + highline (~> 1.6, >= 1.6.9) + json (>= 1.4.4, <= 1.8.1) + mime-types (~> 1.16) + mixlib-authentication (~> 1.3) + mixlib-cli (~> 1.4) + mixlib-config (~> 2.0) + mixlib-log (~> 1.3) + mixlib-shellout (~> 1.4) + net-ssh (~> 2.6) + net-ssh-multi (~> 1.1) + ohai (~> 7.0.4) + pry (~> 0.9) + rest-client (>= 1.0.4, < 1.7.0) + yajl-ruby (~> 1.1) + chef-zero (2.0.2) + hashie (~> 2.0) json - mixlib-authentication (>= 1.1.0) - mixlib-cli (>= 1.1.0) - mixlib-config (>= 1.1.0) - mixlib-log (>= 1.1.0) - moneta - ohai (>= 0.5.0) - chozo (0.6.1) - activesupport (>= 3.2.0) - hashie (>= 2.0.2) - multi_json (>= 1.3.0) + mixlib-log (~> 1.3) + rack + chefspec (3.4.0) + chef (~> 11.0) + fauxhai (~> 2.0) + rspec (~> 2.14) + coderay (1.1.0) + dep-selector-libgecode (1.0.0) + dep_selector (1.0.3) + dep-selector-libgecode (~> 1.0) + ffi (~> 1.9) + diff-lcs (1.2.5) erubis (2.7.0) - extlib (0.9.16) - faraday (0.8.9) - multipart-post (~> 1.2.0) + faraday (0.9.0) + multipart-post (>= 1.2, < 3) + fauxhai (2.1.2) + net-ssh + ohai ffi (1.9.3) foodcritic (3.0.3) erubis @@ -70,28 +80,44 @@ GEM rake treetop (~> 1.4.10) yajl-ruby (~> 1.1.0) + formatador (0.2.4) gherkin (2.11.8) multi_json (~> 1.3) git (1.2.6) - gssapi (1.0.3) - ffi (>= 1.0.1) - gyoku (1.1.1) - builder (>= 2.1.2) + guard (2.6.1) + formatador (>= 0.2.4) + listen (~> 2.7) + lumberjack (~> 1.0) + pry (>= 0.9.12) + thor (>= 0.18.1) + guard-foodcritic (1.0.2) + foodcritic (>= 1.3, < 4.0) + guard (>= 1.0, < 3.0) + guard-kitchen (0.0.2) + guard + mixlib-shellout + guard-rspec (4.2.9) + guard (~> 2.1) + rspec (>= 2.14, < 4.0) + guard-rubocop (1.0.2) + guard (~> 2.0) + rubocop (~> 0.10) hashie (2.1.1) - httpclient (2.3.4.1) - httpi (0.9.7) - rack - i18n (0.6.9) + highline (1.6.21) + hitimes (1.2.1) ipaddress (0.8.0) json (1.8.1) kitchen-sharedtests (0.2.0) git kitchen-vagrant (0.15.0) test-kitchen (~> 1.0) - little-plugger (1.1.3) - logging (1.8.2) - little-plugger (>= 1.1.3) - multi_json (>= 1.8.4) + listen (2.7.5) + celluloid (>= 0.15.2) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + lumberjack (1.0.5) + method_source (0.8.2) + mime-types (1.25.1) minitar (0.5.4) mixlib-authentication (1.3.0) mixlib-log @@ -99,59 +125,87 @@ GEM mixlib-config (2.1.0) mixlib-log (1.6.0) mixlib-shellout (1.4.0) - moneta (0.7.20) - multi_json (1.10.0) - multipart-post (1.2.0) + multi_json (1.10.1) + multipart-post (2.0.0) net-http-persistent (2.9.4) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (2.9.1) + net-ssh-gateway (1.2.0) + net-ssh (>= 2.6.5) + net-ssh-multi (1.2.0) + net-ssh (>= 2.6.5) + net-ssh-gateway (>= 1.2.0) nio4r (1.0.0) nokogiri (1.5.11) - nori (1.1.5) - ohai (6.22.0) + octokit (3.1.0) + sawyer (~> 0.5.3) + ohai (7.0.4) ipaddress + mime-types (~> 1.16) mixlib-cli - mixlib-config + mixlib-config (~> 2.0) mixlib-log - mixlib-shellout + mixlib-shellout (~> 1.2) systemu (~> 2.5.2) yajl-ruby + parser (2.1.9) + ast (>= 1.1, < 3.0) + slop (~> 3.4, >= 3.4.5) polyglot (0.3.4) + powerpack (0.0.9) + pry (0.9.12.6) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) rack (1.5.2) - rake (10.3.1) - rbzip2 (0.2.0) + rainbow (2.0.0) + rake (10.3.2) + rb-fsevent (0.9.4) + rb-inotify (0.9.4) + ffi (>= 0.5.0) + rest-client (1.6.7) + mime-types (>= 1.16) retryable (1.3.5) - ridley (1.7.1) + ridley (3.1.0) addressable buff-config (~> 0.2) buff-extensions (~> 0.3) buff-ignore (~> 1.1) buff-shell_out (~> 0.1) - celluloid (~> 0.15) - celluloid-io (~> 0.15) + celluloid (~> 0.16.0.pre) + celluloid-io (~> 0.16.0.pre) erubis - faraday (>= 0.8.4) + faraday (~> 0.9.0) hashie (>= 2.0.2) json (>= 1.7.7) mixlib-authentication (>= 1.3.0) net-http-persistent (>= 2.8) - net-ssh retryable - solve (>= 0.4.4) - varia_model (~> 0.1) - winrm (~> 1.1.0) - rubyntlm (0.1.1) + semverse (~> 1.1) + varia_model (~> 0.3) + rspec (2.14.1) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + rspec-core (2.14.8) + rspec-expectations (2.14.5) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.6) + rubocop (0.18.1) + json (>= 1.7.7, < 2) + parser (~> 2.1.3) + powerpack (~> 0.0.6) + rainbow (>= 1.99.1, < 3.0) safe_yaml (1.0.3) - savon (0.9.5) - akami (~> 1.0) - builder (>= 2.1.2) - gyoku (>= 0.4.0) - httpi (~> 0.9) - nokogiri (>= 1.4.0) - nori (~> 1.0) - wasabi (~> 1.0) - solve (0.8.2) + sawyer (0.5.4) + addressable (~> 2.3.5) + faraday (~> 0.8, < 0.10) + semverse (1.1.0) + slop (3.5.0) + solve (1.2.0) + dep_selector (~> 1.0) + semverse (~> 1.1) systemu (2.5.2) test-kitchen (1.2.1) mixlib-shellout (~> 1.2) @@ -160,35 +214,35 @@ GEM safe_yaml (~> 1.0) thor (~> 0.18) thor (0.18.1) - timers (1.1.0) + thor-foodcritic (1.1.0) + foodcritic (~> 3.0) + thor + timers (2.0.0) + hitimes treetop (1.4.15) polyglot polyglot (>= 0.3.1) - uuidtools (2.1.4) varia_model (0.3.2) buff-extensions (~> 0.2) hashie (>= 2.0.2) - wasabi (1.0.0) - nokogiri (>= 1.4.0) - winrm (1.1.3) - gssapi (~> 1.0.0) - httpclient (~> 2.2, >= 2.2.0.2) - logging (~> 1.6, >= 1.6.1) - nokogiri (~> 1.5) - rubyntlm (~> 0.1.1) - savon (= 0.9.5) - uuidtools (~> 2.1.2) yajl-ruby (1.1.0) PLATFORMS ruby DEPENDENCIES - berkshelf (~> 2.0) - busser - busser-serverspec - chef - foodcritic (~> 3.0.3) + berkshelf (~> 3.0) + chef (~> 11.12) + chefspec (~> 3.4) + foodcritic (~> 3.0) + guard + guard-foodcritic + guard-kitchen + guard-rspec + guard-rubocop kitchen-sharedtests (~> 0.2.0) - kitchen-vagrant (~> 0.11) + kitchen-vagrant + rake + rubocop (~> 0.18.1) test-kitchen (~> 1.0) + thor-foodcritic diff --git a/Guardfile b/Guardfile new file mode 100644 index 00000000..925722e9 --- /dev/null +++ b/Guardfile @@ -0,0 +1,30 @@ +# Guardfile + +guard :rubocop do + watch(%r{.+\.rb$}) + watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } +end + +guard :foodcritic, cookbook_paths: '.', cli: "-f any --tags ~FC023" do + watch(%r{attributes/.+\.rb$}) + watch(%r{providers/.+\.rb$}) + watch(%r{recipes/.+\.rb$}) + watch(%r{resources/.+\.rb$}) + watch(%r{metadata.rb}) +end + +guard :rspec do + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{^(recipes)/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { 'spec' } +end + +guard :kitchen, all_on_start: false do + watch(%r{test/.+}) + watch(%r{^recipes/(.+)\.rb$}) + watch(%r{^attributes/(.+)\.rb$}) + watch(%r{^files/(.+)}) + watch(%r{^templates/(.+)}) + watch(%r{^providers/(.+)\.rb}) + watch(%r{^resources/(.+)\.rb}) +end \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 00000000..5eb07c38 --- /dev/null +++ b/Rakefile @@ -0,0 +1,57 @@ +#!/usr/bin/env rake +require 'foodcritic' +require 'rspec/core/rake_task' +require 'rubocop/rake_task' + +# General tasks + +# Rubocop before rspec so we don't lint vendored cookbooks +desc "Run all tests except Kitchen (default task)" +task :integration => %w{rubocop foodcritic spec} +task :default => :unit + +# Lint the cookbook +desc "Run linters" +task :lint => [ :rubocop, :foodcritic ] + +# Run the whole shebang +desc "Run all tests" +task :test => [ :lint, :integration ] + +# RSpec +desc 'Run chefspec tests' +task :spec do + puts "Running Chefspec tests" + RSpec::Core::RakeTask.new(:spec) +end + +# Foodcritic +desc 'Run foodcritic lint checks' +task :foodcritic do + if Gem::Version.new('1.9.2') <= Gem::Version.new(RUBY_VERSION.dup) + puts "Running Foodcritic tests..." + FoodCritic::Rake::LintTask.new do |t| + t.options = { :fail_tags => ['correctness'] } + puts "done." + end + else + puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2." + end +end + +# Rubocop +desc 'Run Rubocop lint checks' +task :rubocop do + Rubocop::RakeTask.new +end + +begin + require 'kitchen/rake_tasks' + Kitchen::RakeTasks.new + + desc "Alias for kitchen:all" + task :acceptance => "kitchen:all" + +rescue LoadError + puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI'] +end \ No newline at end of file diff --git a/Thorfile b/Thorfile index f769503d..15b092f6 100644 --- a/Thorfile +++ b/Thorfile @@ -2,6 +2,8 @@ require 'bundler' require 'bundler/setup' +require 'thor/foodcritic' + require 'kitchen_sharedtests' require 'kitchen/sharedtests_thor_tasks'