-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
38 lines (29 loc) · 1.04 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
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core/rake_task"
ENV["SOURCE_IMAGE"] ||= "ubuntu:jammy"
targets = %i(system user)
namespace :test do
targets.each do |target|
namespace target do
node_yaml = "#{__dir__}/spec/#{target}/recipes/node.yml"
test_image = "itamae-plugin:#{target}"
desc "Run itamae to #{target}"
task :itamae do
ENV["TEST_IMAGE"] = "itamae-plugin:#{target}"
sh "itamae docker --node-yaml=#{node_yaml} spec/#{target}/recipes/install.rb --image=#{ENV["SOURCE_IMAGE"]} --tag #{test_image}"
end
desc "Run serverspec tests to #{target}"
RSpec::Core::RakeTask.new(:serverspec) do |t|
ENV["TEST_IMAGE"] = test_image
ENV["NODE_YAML"] = node_yaml
t.pattern = "spec/#{target}/*_spec.rb"
end
end
desc "Run itamae and serverspec tests to #{target} "
task target => ["#{target}:itamae", "#{target}:serverspec"]
end
end
desc "Run test"
task :test => targets.map { |target| "test:#{target}" }
task default: :test