Skip to content

Instantly share code, notes, and snippets.

@jeremymv2
Created March 4, 2016 23:10
Show Gist options
  • Save jeremymv2/f646d9e73e56709cd224 to your computer and use it in GitHub Desktop.
Save jeremymv2/f646d9e73e56709cd224 to your computer and use it in GitHub Desktop.
gem 'test-kitchen', '1.4.2'
gem 'rubocop', '= 0.36.0'
gem 'foodcritic', '= 5.0.0'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'foodcritic'
require 'kitchen/cli'
# Style tests. Rubocop and Foodcritic
namespace :style do
desc 'Run Ruby style checks'
RuboCop::RakeTask.new(:ruby)
desc 'Run Chef style checks'
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
fail_tags: ['any'],
tags: ['~FC005']
}
end
end
desc 'Run all style checks'
task style: ['style:chef', 'style:ruby']
# Rspec and ChefSpec
desc 'Run ChefSpec examples'
RSpec::Core::RakeTask.new(:spec)
# Integration tests. Kitchen.ci
namespace :integration do
desc 'Run Test Kitchen with Vagrant'
task :vagrant do
Kitchen.logger = Kitchen.default_file_logger
Kitchen::Config.new.instances.each do |instance|
instance.test(:always)
end
end
task :ec2 do
ENV['KITCHEN_YAML'] = './.kitchen.ec2.yml'
Kitchen::CLI.new([], concurrency: 5, destroy: 'always').test
end
task :ec2_singlethread do
ENV['KITCHEN_YAML'] = './.kitchen.ec2.yml'
Kitchen::CLI.new([], destroy: 'always').test
end
end
# Default
task default: ['style', 'spec', 'integration:vagrant']
task ec2: ['style', 'spec', 'integration:ec2']
task ec2_singlethread: ['style', 'spec', 'integration:ec2_singlethread']
task test: ['style', 'spec']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment