/
Rakefile
executable file
·60 lines (50 loc) · 1.42 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
# Checks if we are inside Travis CI.
#
# @return [Boolean] whether we are inside Travis CI.
# @example
# travis? #=> false
def travis?
ENV['TRAVIS'] == 'true'
end
namespace :style do
desc 'Run Ruby style checks'
task :ruby do
sh '/opt/chefdk/embedded/bin/cookstyle --version'
sh '/opt/chefdk/embedded/bin/cookstyle'
end
desc 'Run Chef style checks'
task :chef do
sh '/opt/chefdk/embedded/bin/foodcritic --version'
sh '/opt/chefdk/embedded/bin/foodcritic -f any . --exclude spec'
end
end
desc 'Run styling tests'
task style: ['style:ruby', 'style:chef']
namespace :unit do
desc 'Run ChefSpec'
task :spec do
sh 'rm -f Policyfile.lock.json'
sh '/opt/chefdk/embedded/bin/chef exec rspec'
end
end
desc 'Run unit tests'
task unit: ['unit:spec']
namespace :integration do
def run_kitchen
sh '[ -e Policyfile.lock.json ] || /opt/chefdk/embedded/bin/chef install'
sh "kitchen test #{ENV['KITCHEN_ARGS']} #{ENV['KITCHEN_INSTANCE']}"
end
desc 'Run Test Kitchen integration tests using vagrant'
task :vagrant do
ENV.delete('KITCHEN_LOCAL_YAML')
run_kitchen
end
desc 'Run Test Kitchen integration tests using dokken'
task :dokken do
ENV['KITCHEN_LOCAL_YAML'] = '.kitchen.dokken.yml'
run_kitchen
end
end
desc 'Run Test Kitchen integration tests'
task integration: travis? ? %w(integration:dokken) : %w(integration:vagrant)
task default: [:style, :unit, :integration]