Skip to content

Commit 1d1f170

Browse files
authored
Merge pull request #324 from puppetlabs/maint-matrix
(MAINT) Add matrix for acceptance tests
2 parents 79bf947 + 2ef43c5 commit 1d1f170

File tree

4 files changed

+73
-63
lines changed

4 files changed

+73
-63
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: "ci"
33
on:
44
push:
55
branches:
6-
- "maint"
6+
- "main"
77
pull_request:
88
branches:
99
- "main"
@@ -12,6 +12,19 @@ on:
1212
workflow_dispatch:
1313

1414
jobs:
15-
ci:
15+
16+
spec:
1617
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
1718
secrets: "inherit"
19+
20+
acceptance:
21+
needs: "spec"
22+
strategy:
23+
matrix:
24+
puppet:
25+
- "puppet6"
26+
- "puppet7"
27+
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_acceptance.yml@main"
28+
secrets: "inherit"
29+
with:
30+
target: ${{ matrix.target }}

Gemfile

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,40 @@ else
1414
gem 'puppet', :require => false
1515
end
1616

17-
group :test do
17+
group :development do
1818
gem 'codecov'
19+
20+
gem 'json_spec', '~> 1.1', '>= 1.1.5'
21+
22+
gem 'mdl'
1923
gem 'mocha'
24+
25+
gem 'pry', require: false
26+
gem 'pry-byebug', require: false
27+
gem 'pry-stack_explorer', require: false
2028
gem 'puppetlabs_spec_helper'
21-
gem 'serverspec'
22-
gem 'simplecov-console'
29+
30+
gem 'rake', '~> 10.0'
2331
gem 'rspec', '~> 3.1'
24-
gem 'json_spec', '~> 1.1', '>= 1.1.5'
25-
gem 'mdl'
32+
gem 'rspec-its', '~> 1.0'
33+
gem 'rubocop', '~> 1.6.1', require: false
34+
gem 'rubocop-rspec', '~> 2.0.1', require: false
35+
gem 'rubocop-performance', '~> 1.9.1', require: false
36+
37+
gem 'serverspec'
38+
gem 'simplecov-console', require: false if ENV['COVERAGE'] == 'yes'
39+
gem 'simplecov', require: false if ENV['COVERAGE'] == 'yes'
2640
end
2741

2842
group :acceptance do
2943
gem 'puppet_litmus'
3044
gem 'net-ssh'
3145
end
3246

33-
group :development do
34-
gem 'github_changelog_generator'
35-
gem 'pry'
36-
gem 'pry-byebug'
47+
group :release do
48+
gem 'github_changelog_generator', require: false
3749
end
3850

39-
gem 'rubocop', '~> 1.6.1'
40-
gem 'rubocop-rspec', '~> 2.0.1'
41-
gem 'rubocop-performance', '~> 1.9.1'
42-
4351
# Evaluate Gemfile.local if it exists
4452
if File.exists? "#{__FILE__}.local"
4553
eval(File.read("#{__FILE__}.local"), binding)

Rakefile

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,16 @@
11
# frozen_string_literal: true
22

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'
403
require 'bundler/gem_tasks'
414
require 'puppet-lint/tasks/puppet-lint'
42-
435
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+
4414
RSpec::Core::RakeTask.new(:spec) do |t|
4515
t.exclude_pattern = "spec/acceptance/**/*.rb"
4616
end
@@ -138,13 +108,6 @@ namespace :litmus do
138108
end
139109
end
140110

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-
148111
#### CHANGELOG ####
149112
begin
150113
require 'github_changelog_generator/task'
@@ -177,3 +140,30 @@ rescue LoadError
177140
raise 'Install github_changelog_generator to get access to automatic changelog generation'
178141
end
179142
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

puppet-strings.gemspec

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Gem::Specification.new do |s|
1212
s.summary = 'Puppet documentation via YARD'
1313
s.email = 'info@puppet.com'
1414
s.homepage = 'https://github.com/puppetlabs/puppet-strings'
15-
s.description = s.summary
1615
s.required_ruby_version = '>= 2.5.0'
1716

1817
s.extra_rdoc_files = [
@@ -25,6 +24,6 @@ Gem::Specification.new do |s|
2524
s.files = Dir['CHANGELOG.md', 'README.md', 'LICENSE', 'lib/**/*', 'exe/**/*']
2625

2726
s.add_runtime_dependency 'yard', '~> 0.9.5'
28-
s.add_runtime_dependency 'rgen'
29-
s.requirements << 'puppet, >= 5.0.0'
27+
s.add_runtime_dependency 'rgen', '~> 0.9.0'
28+
s.requirements << 'puppet, >= 6.0.0'
3029
end

0 commit comments

Comments
 (0)