diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a82c3a11..b155d088f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,4 +39,3 @@ jobs: ruby_version: ${{ matrix.ruby_version }} rake_task: 'acceptance:local' runs_on: ${{ matrix.os }} - diff --git a/Rakefile b/Rakefile index 8dfb155a2..ff377d384 100644 --- a/Rakefile +++ b/Rakefile @@ -49,11 +49,16 @@ end namespace :acceptance do desc 'Run acceptance tests against current code' + + task :env do + ENV['PDK_PUPPET_VERSION'] = RUBY_VERSION.split('.')[0].include?('3') ? '8' : '7' + end + RSpec::Core::RakeTask.new(:local) do |t| t.rspec_opts = '--tag ~package' # Exclude package specific examples t.pattern = 'spec/acceptance/**/*_spec.rb' end - task local: [:binstubs] + task local: [:binstubs, :env] task local_parallel: [:binstubs] do require 'parallel_tests' diff --git a/lib/pdk/module/metadata.rb b/lib/pdk/module/metadata.rb index 3a4a5973c..ee4e8f2b1 100644 --- a/lib/pdk/module/metadata.rb +++ b/lib/pdk/module/metadata.rb @@ -81,7 +81,7 @@ class Metadata OPERATING_SYSTEMS[os_name] end.flatten, 'requirements' => [ - { 'name' => 'puppet', 'version_requirement' => '>= 6.21.0 < 8.0.0' } + { 'name' => 'puppet', 'version_requirement' => '>= 7.24 < 9.0.0' } ] }.freeze diff --git a/spec/acceptance/support/in_a_new_module.rb b/spec/acceptance/support/in_a_new_module.rb index 6d55f1aa9..2e48dcbd1 100644 --- a/spec/acceptance/support/in_a_new_module.rb +++ b/spec/acceptance/support/in_a_new_module.rb @@ -10,7 +10,11 @@ '--skip-interview', '--template-url', template ] - env = { 'PDK_ANSWER_FILE' => File.join(Dir.pwd, "#{name}_answers.json") } + env = { + 'PDK_ANSWER_FILE' => File.join(Dir.pwd, "#{name}_answers.json"), + 'PDK_PUPPET_VERSION' => ENV.fetch('PDK_PUPPET_VERSION', '7') + } + output, status = Open3.capture2e(env, *argv) raise "Failed to create test module:\n#{output}" unless status.success? diff --git a/spec/acceptance/version_changer_spec.rb b/spec/acceptance/version_changer_spec.rb index bf555d075..5507c1e5c 100644 --- a/spec/acceptance/version_changer_spec.rb +++ b/spec/acceptance/version_changer_spec.rb @@ -89,16 +89,25 @@ class version_select { its(:stderr) { is_expected.not_to match(%r{Using Puppet file://}i) } end - # Note that there is no guarantee that the main branch of puppet is compatible with the PDK under test - # so we can only test that the validate command is using the expected puppet gem location - describe command('pdk validate --puppet-dev') do - its(:stderr) { is_expected.to match(%r{Using Puppet file://}i) } - end + context 'when PDK_PUPPET_VERSION is set' do + around do |example| + pdk_puppet_version = ENV.fetch('PDK_PUPPET_VERSION', nil) + ENV['PDK_PUPPET_VERSION'] = nil + example.run + ENV['PDK_PUPPET_VERSION'] = pdk_puppet_version + end - # Note that there is no guarantee that the main branch of puppet is compatible with the PDK under test - # so we can only test that the test command is using the expected puppet gem location - describe command('pdk test unit --puppet-dev') do - its(:stderr) { is_expected.to match(%r{Using Puppet file://}i) } + # Note that there is no guarantee that the main branch of puppet is compatible with the PDK under test + # so we can only test that the validate command is using the expected puppet gem location + describe command('pdk validate --puppet-dev') do + its(:stderr) { is_expected.to match(%r{Using Puppet file://}i) } + end + + # Note that there is no guarantee that the main branch of puppet is compatible with the PDK under test + # so we can only test that the test command is using the expected puppet gem location + describe command('pdk test unit --puppet-dev') do + its(:stderr) { is_expected.to match(%r{Using Puppet file://}i) } + end end end end diff --git a/spec/unit/pdk/cli/validate_spec.rb b/spec/unit/pdk/cli/validate_spec.rb index ce7988a1b..f3a28bc61 100644 --- a/spec/unit/pdk/cli/validate_spec.rb +++ b/spec/unit/pdk/cli/validate_spec.rb @@ -6,8 +6,8 @@ let(:pretty_validator_names) { PDK::Validate.validator_names.join(', ') } let(:report) { instance_double(PDK::Report).as_null_object } - let(:ruby_version) { '2.4.3' } - let(:puppet_version) { '5.4.0' } + let(:ruby_version) { '3.2.2' } + let(:puppet_version) { '8.0.1' } let(:module_path) { '/path/to/testmodule' } let(:context) { PDK::Context::Module.new(module_path, module_path) } diff --git a/spec/unit/pdk/util/puppet_version_spec.rb b/spec/unit/pdk/util/puppet_version_spec.rb index cafa5e9a0..f8c053b19 100644 --- a/spec/unit/pdk/util/puppet_version_spec.rb +++ b/spec/unit/pdk/util/puppet_version_spec.rb @@ -469,8 +469,8 @@ def result(pe_version) let(:metadata) { PDK::Module::Metadata.new } context 'with default metadata' do - it 'searches for a Puppet gem >= 6.21.0 < 8.0.0' do - requirement = Gem::Requirement.create(['>= 6.21.0', '< 8.0.0']) + it 'searches for a Puppet gem >= 7.24.0 < 9.0.0' do + requirement = Gem::Requirement.create(['>= 7.24.0', '< 9.0.0']) expect(described_class.instance).to receive(:find_gem).with(requirement) described_class.from_module_metadata(metadata)