forked from sous-chefs/percona
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
64 lines (52 loc) · 1.48 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env rake
begin
require "kitchen/rake_tasks"
Kitchen::RakeTasks.new
rescue LoadError
puts "Unable to require `kitchen/rake_tasks`"
end
task default: "test"
desc "Runs all tests"
task test: [:knife, :rubocop, :foodcritic, :chefspec, :kitchen]
desc "Runs foodcritic linter"
task foodcritic: :prepare_sandbox do
sh "bundle exec foodcritic #{sandbox_path} -f any"
end
desc "Runs knife cookbook test"
task knife: :prepare_sandbox do
sh "bundle exec knife cookbook test cookbook -c test/.chef/knife.rb -o #{sandbox_path}/../"
end
desc "Runs specs with chefspec"
task chefspec: :prepare_sandbox do
if Bundler.rubygems.find_name("chef").first.version < Gem::Version.new(11)
puts "Skipping `chefspec` due to older Chef version"
else
sh "bundle exec rspec --color"
end
end
desc "Runs integration tests with test kitchen"
task :kitchen do
if ENV["CI"]
puts "Skipping Kitchen tests for now due to CI environment..."
exit
end
args = ENV["CI"] ? "test --destroy=always" : "verify"
sh "bundle exec kitchen #{args}"
end
desc "Runs RuboCop style checks"
task rubocop: :prepare_sandbox do
sh "bundle exec rubocop #{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