Permalink
Browse files

Adding Travis CI testing for foodcritic and knife cookbook test

  • Loading branch information...
1 parent 15d92b4 commit 9875243dbdac543aa0d03e9406610c145005506c @nathenharvey nathenharvey committed Jul 13, 2012
Showing with 53 additions and 0 deletions.
  1. +9 −0 .travis.yml
  2. +3 −0 README.md
  3. +34 −0 Rakefile
  4. +2 −0 test/.chef/knife.rb
  5. +5 −0 test/support/Gemfile
View
@@ -0,0 +1,9 @@
+language: ruby
+gemfile:
+ - test/support/Gemfile
+rvm:
+ - 1.9.2
+ - 1.9.3
+script:
+ - bundle exec rake knife
+ - bundle exec rake foodcritic
View
@@ -1,3 +1,6 @@
+# <a name="title"></a> magic_shell [![Build Status](https://secure.travis-ci.org/customink-webops/magic_shell.png)](http://travis-ci.org/customink-webops/magic_shell)
+
+
Description
===========
View
@@ -0,0 +1,34 @@
+#!/usr/bin/env rake
+
+task :default => 'foodcritic'
+
+desc "Runs foodcritic linter"
+task :foodcritic do
+ Rake::Task[:prepare_sandbox].execute
+
+ if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
+ sh "foodcritic -f any #{sandbox_path}"
+ else
+ puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
+ end
+end
+
+desc "Runs knife cookbook test"
+task :knife do
+ Rake::Task[:prepare_sandbox].execute
+
+ sh "bundle exec knife cookbook test cookbook -c test/.chef/knife.rb -o #{sandbox_path}/../"
+end
+
+task :prepare_sandbox do
+ files = %w{*.md *.rb attributes definitions libraries files providers recipes resources templates}
+
+ rm_rf sandbox_path
+ mkdir_p sandbox_path
+ cp_r Dir.glob("{#{files.join(',')}}"), sandbox_path
+end
+
+private
+def sandbox_path
+ File.join(File.dirname(__FILE__), %w(tmp cookbooks cookbook))
+end
View
@@ -0,0 +1,2 @@
+cache_type 'BasicFile'
+cache_options(:path => "#{ENV['HOME']}/.chef/checksums")
View
@@ -0,0 +1,5 @@
+source "https://rubygems.org"
+
+gem 'rake'
+gem 'foodcritic'
+gem 'chef', '~> 10.12.0'

0 comments on commit 9875243

Please sign in to comment.