2016-12-15 08:53:01 +00:00
|
|
|
#!/usr/bin/env rake
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
require 'rake/testtask'
|
|
|
|
require 'rubocop/rake_task'
|
|
|
|
|
|
|
|
# Rubocop
|
|
|
|
desc 'Run Rubocop lint checks'
|
|
|
|
task :rubocop do
|
|
|
|
RuboCop::RakeTask.new
|
|
|
|
end
|
|
|
|
|
2017-01-27 18:38:04 +00:00
|
|
|
# Minitest
|
|
|
|
Rake::TestTask.new do |t|
|
|
|
|
t.libs << 'libraries'
|
|
|
|
t.libs << 'test/unit'
|
|
|
|
t.pattern = "test/unit/**/*_test.rb"
|
|
|
|
end
|
|
|
|
|
2016-12-15 08:53:01 +00:00
|
|
|
# lint the project
|
|
|
|
desc 'Run robocop linter'
|
|
|
|
task lint: [:rubocop]
|
|
|
|
|
|
|
|
# run tests
|
2017-01-27 18:38:04 +00:00
|
|
|
task default: [:lint, :test]
|
2016-12-15 08:53:01 +00:00
|
|
|
|
|
|
|
namespace :test do
|
|
|
|
# run inspec check to verify that the profile is properly configured
|
|
|
|
task :check do
|
|
|
|
dir = File.join(File.dirname(__FILE__))
|
|
|
|
sh("bundle exec inspec check #{dir}")
|
|
|
|
end
|
2017-01-16 15:14:24 +00:00
|
|
|
|
2017-02-16 20:22:33 +00:00
|
|
|
task :integration_no_cleanup do
|
2017-01-16 15:14:24 +00:00
|
|
|
integration_dir = "test/integration"
|
|
|
|
|
|
|
|
puts "----> Build"
|
|
|
|
sh("cd #{integration_dir}/build/ && terraform plan")
|
|
|
|
sh("cd #{integration_dir}/build/ && terraform apply")
|
|
|
|
|
|
|
|
puts "----> Verify"
|
|
|
|
sh("bundle exec inspec exec #{integration_dir}/verify")
|
|
|
|
end
|
|
|
|
|
2017-02-16 20:22:33 +00:00
|
|
|
task :integration do
|
|
|
|
Rake::Task["test:cleanup"].execute
|
|
|
|
Rake::Task["test:integration_no_cleanup"].execute
|
|
|
|
Rake::Task["test:cleanup"].execute
|
|
|
|
end
|
|
|
|
|
2017-01-16 15:14:24 +00:00
|
|
|
task :cleanup do
|
|
|
|
integration_dir = "test/integration"
|
|
|
|
puts "----> Destroy"
|
|
|
|
sh("cd #{integration_dir}/build/ && terraform destroy -force")
|
|
|
|
end
|
2016-12-15 08:53:01 +00:00
|
|
|
end
|