-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
56 lines (46 loc) · 1.34 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
current_dir = File.dirname(__FILE__)
client_cfg = "#{current_dir}/test/chef-config"
task default: ['test']
desc 'Run all tests'
task test: [:style, :unit]
def run_command(command)
if File.exist?('Gemfile.lock')
sh %(bundle exec #{command})
else
sh %(cinc exec #{command})
end
end
task :destroy_all do
run_command('rm -rf Gemfile.lock && rm -rf Berksfile.lock && rm -rf cookbooks/')
end
desc 'Vendor your cookbooks/'
task berks_vendor: :clean do
run_command('berks vendor cookbooks')
end
desc 'Upload data to chef-zero server'
task knife_upload: :berks_vendor do
run_command('knife upload . --force -c test/chef-config/knife.rb')
end
desc 'Create Chef Key'
task :create_key do
unless File.exist?("#{client_cfg}/validator.pem")
File.binwrite("#{client_cfg}/validator.pem", OpenSSL::PKey::RSA.new(2048).to_pem)
end
unless File.exist?("#{client_cfg}/fakeclient.pem")
File.binwrite("#{client_cfg}/fakeclient.pem", OpenSSL::PKey::RSA.new(2048).to_pem)
end
end
desc 'Blow everything away'
task clean: [:destroy_all]
# CI tasks
require 'cookstyle'
require 'rubocop/rake_task'
desc 'Run RuboCop (cookstyle) tests'
RuboCop::RakeTask.new(:style) do |task|
task.options << '--display-cop-names'
end
desc 'Run RSpec (unit) tests'
task :unit do
run_command('rm -f Berksfile.lock')
run_command('rspec --format documentation --color')
end