|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -if Bundler.rubygems.find_name('puppet_litmus').any? |
4 | | - require 'puppet_litmus/rake_tasks' |
5 | | - |
6 | | - # This is a _really_ horrible monkey-patch to fix up https://github.com/puppetlabs/bolt/issues/1614 |
7 | | - # Based on resolution https://github.com/puppetlabs/bolt/pull/1620 |
8 | | - # This can be removed once this is fixed, released into Bolt and into Litmus |
9 | | - require 'bolt_spec/run' |
10 | | - module BoltSpec |
11 | | - module Run |
12 | | - class BoltRunner |
13 | | - class << self |
14 | | - alias_method :original_with_runner, :with_runner |
15 | | - end |
16 | | - |
17 | | - def self.with_runner(config_data, inventory_data) |
18 | | - original_with_runner(deep_duplicate_object(config_data), deep_duplicate_object(inventory_data)) { |runner| yield runner } |
19 | | - end |
20 | | - |
21 | | - # From https://github.com/puppetlabs/pdk/blob/main/lib/pdk/util.rb |
22 | | - # Workaround for https://github.com/puppetlabs/bolt/issues/1614 |
23 | | - def self.deep_duplicate_object(object) |
24 | | - if object.is_a?(Array) |
25 | | - object.map { |item| deep_duplicate_object(item) } |
26 | | - elsif object.is_a?(Hash) |
27 | | - hash = object.dup |
28 | | - hash.each_pair { |key, value| hash[key] = deep_duplicate_object(value) } |
29 | | - hash |
30 | | - else |
31 | | - object |
32 | | - end |
33 | | - end |
34 | | - end |
35 | | - end |
36 | | - end |
37 | | -end |
38 | | - |
39 | | -require 'puppetlabs_spec_helper/tasks/fixtures' |
40 | 3 | require 'bundler/gem_tasks' |
41 | 4 | require 'puppet-lint/tasks/puppet-lint' |
42 | | - |
43 | 5 | require 'rspec/core/rake_task' |
| 6 | +require 'puppetlabs_spec_helper/tasks/fixtures' |
| 7 | + |
| 8 | +begin |
| 9 | + require 'puppet_litmus/rake_tasks' |
| 10 | +rescue LoadError |
| 11 | + # Gem not present |
| 12 | +end |
| 13 | + |
44 | 14 | RSpec::Core::RakeTask.new(:spec) do |t| |
45 | 15 | t.exclude_pattern = "spec/acceptance/**/*.rb" |
46 | 16 | end |
@@ -138,13 +108,6 @@ namespace :litmus do |
138 | 108 | end |
139 | 109 | end |
140 | 110 |
|
141 | | -task(:rubocop) do |
142 | | - require 'rubocop' |
143 | | - cli = RuboCop::CLI.new |
144 | | - result = cli.run(%w(-D -f s)) |
145 | | - abort unless result == RuboCop::CLI::STATUS_SUCCESS |
146 | | -end |
147 | | - |
148 | 111 | #### CHANGELOG #### |
149 | 112 | begin |
150 | 113 | require 'github_changelog_generator/task' |
@@ -177,3 +140,30 @@ rescue LoadError |
177 | 140 | raise 'Install github_changelog_generator to get access to automatic changelog generation' |
178 | 141 | end |
179 | 142 | end |
| 143 | + |
| 144 | +desc 'Run acceptance tests' |
| 145 | +task :acceptance do |
| 146 | + |
| 147 | + begin |
| 148 | + if ENV['MATRIX_TARGET'] |
| 149 | + agent_version = ENV['MATRIX_TARGET'].chomp |
| 150 | + else |
| 151 | + agent_version = 'puppet7' |
| 152 | + end |
| 153 | + |
| 154 | + Rake::Task['litmus:provision'].invoke('docker', 'litmusimage/centos:7') |
| 155 | + |
| 156 | + Rake::Task['litmus:install_agent'].invoke(agent_version.to_s) |
| 157 | + |
| 158 | + Rake::Task['litmus:install_modules_from_directory'].invoke('./spec/fixtures/acceptance/modules') |
| 159 | + |
| 160 | + Rake::Task['litmus:install_gems'].invoke |
| 161 | + |
| 162 | + Rake::Task['litmus:acceptance:parallel'].invoke |
| 163 | + |
| 164 | + rescue StandardError => e |
| 165 | + puts e.message |
| 166 | + raise e |
| 167 | + end |
| 168 | + |
| 169 | +end |
0 commit comments