From 440fcc3ad10714670403a80946895e8fc2be33e5 Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Mon, 8 Jul 2013 11:47:45 +0200 Subject: [PATCH] Add basic travis support --- .travis.yml | 9 +++++++++ Rakefile | 27 +++++++++++++++++++++++++++ test/.chef/knife.rb | 2 ++ test/support/Gemfile | 5 +++++ 4 files changed, 43 insertions(+) create mode 100644 .travis.yml create mode 100644 Rakefile create mode 100644 test/.chef/knife.rb create mode 100644 test/support/Gemfile diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ba955a4 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..9039b24 --- /dev/null +++ b/Rakefile @@ -0,0 +1,27 @@ +#!/usr/bin/env rake + +require 'foodcritic' + +task :default => [:foodcritic] + +FoodCritic::Rake::LintTask.new + +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 files libraries 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 diff --git a/test/.chef/knife.rb b/test/.chef/knife.rb new file mode 100644 index 0000000..9125df1 --- /dev/null +++ b/test/.chef/knife.rb @@ -0,0 +1,2 @@ +cache_type 'BasicFile' +cache_options(:path => "#{ENV['HOME']}/.chef/checksums") diff --git a/test/support/Gemfile b/test/support/Gemfile new file mode 100644 index 0000000..371cfdf --- /dev/null +++ b/test/support/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem 'rake' +gem 'foodcritic' +gem 'chef', '>= 10.12.0'