forked from dev-sec/puppet-os-hardening
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile.local
27 lines (22 loc) · 879 Bytes
/
Rakefile.local
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
desc 'Run kitchen integration tests'
task :kitchen do
concurrency = ENV['CONCURRENCY'] || 1
instance = ENV['INSTANCE'] || ''
SSH_KEY_FILE = '~/.ssh/do_ci'
SSH_KEY_ENV_VAR_NAME = 'CI_SSH_KEY'
if ENV['CI'] && ENV['KITCHEN_LOCAL_YAML'] == 'kitchen.do.yml'
puts 'Preparing CI environment for DigitalOcean...'
['DIGITALOCEAN_ACCESS_TOKEN', 'DIGITALOCEAN_SSH_KEY_IDS', SSH_KEY_ENV_VAR_NAME].each do |var|
unless ENV[var]
puts "#{var} isn't defined. Skipping the task"
exit
end
end
ssh_file = File.expand_path(SSH_KEY_FILE)
dir = File.dirname(ssh_file)
Dir.mkdir(dir, 0o700) unless Dir.exist?(dir)
File.open(ssh_file, 'w') { |f| f.puts Base64.decode64(ENV[SSH_KEY_ENV_VAR_NAME]) }
File.chmod(0o600, ssh_file)
end
sh('sh', '-c', "bundle exec kitchen test --destroy=always -c #{concurrency} #{instance}")
end