diff --git a/.fixtures.yml b/.fixtures.yml index 632201dc..27acc6f2 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -5,9 +5,7 @@ fixtures: archive: "https://github.com/voxpupuli/puppet-archive.git" augeas_core: "https://github.com/puppetlabs/puppetlabs-augeas_core.git" facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' - puppet_agent: - repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - ref: v4.21.0 + puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' provision: 'https://github.com/puppetlabs/provision.git' symlinks: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42e7a6e0..37bc72b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,6 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" - secrets: "inherit" with: - runs_on: "ubuntu-24.04" + flags: "--nightly --platform-exclude centos-7 --platform-exclude oraclelinux-7 --platform-exclude scientific-7" + secrets: "inherit" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6e3017ba..28a607a5 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -13,6 +13,6 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" - secrets: "inherit" with: - runs_on: "ubuntu-24.04" + flags: "--nightly --platform-exclude centos-7 --platform-exclude oraclelinux-7 --platform-exclude scientific-7" + secrets: "inherit" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c851027..4b3b80fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,6 @@ on: workflow_dispatch: jobs: - release: - name: "Release" + release: uses: "puppetlabs/cat-github-actions/.github/workflows/module_release.yml@main" secrets: "inherit" diff --git a/.puppet-lint.rc b/.puppet-lint.rc index 7c98ce78..ddc7dea2 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,2 +1,9 @@ +--fail-on-warnings --relative ---ignore-paths=examples/*.pp,vendor/**/*.pp,bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp +--no-80chars-check +--no-140chars-check +--no-class_inherits_from_params_class-check +--no-autoloader_layout-check +--no-documentation-check +--no-single_quote_string_with_variables-check +--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp,examples/*.pp,bundle/**/*.pp diff --git a/.rubocop.yml b/.rubocop.yml index 439ea84e..4899d2ea 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,11 +1,14 @@ --- -require: +plugins: - rubocop-performance - rubocop-rspec +- rubocop-rspec_rails +- rubocop-factory_bot +- rubocop-capybara AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.6' + TargetRubyVersion: 3.1 Include: - "**/*.rb" Exclude: @@ -121,6 +124,12 @@ Capybara/CurrentPathExpectation: Enabled: false Capybara/VisibilityMatcher: Enabled: false +FactoryBot/AttributeDefinedStatically: + Enabled: false +FactoryBot/CreateList: + Enabled: false +FactoryBot/FactoryClassName: + Enabled: false Gemspec/DuplicatedAssignment: Enabled: false Gemspec/OrderedDependencies: @@ -295,8 +304,6 @@ Performance/UriDefaultParser: Enabled: false RSpec/Be: Enabled: false -RSpec/Capybara/FeatureMethods: - Enabled: false RSpec/ContainExactly: Enabled: false RSpec/ContextMethod: @@ -305,6 +312,8 @@ RSpec/ContextWording: Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/Dialect: + Enabled: false RSpec/EmptyHook: Enabled: false RSpec/EmptyLineAfterExample: @@ -321,12 +330,6 @@ RSpec/ExpectChange: Enabled: false RSpec/ExpectInHook: Enabled: false -RSpec/FactoryBot/AttributeDefinedStatically: - Enabled: false -RSpec/FactoryBot/CreateList: - Enabled: false -RSpec/FactoryBot/FactoryClassName: - Enabled: false RSpec/HooksBeforeExamples: Enabled: false RSpec/ImplicitBlockExpectation: @@ -501,6 +504,12 @@ Capybara/SpecificFinders: Enabled: false Capybara/SpecificMatcher: Enabled: false +FactoryBot/ConsistentParenthesesStyle: + Enabled: false +FactoryBot/FactoryNameStyle: + Enabled: false +FactoryBot/SyntaxMethods: + Enabled: false Gemspec/DeprecatedAttributeAssignment: Enabled: false Gemspec/DevelopmentDependencies: @@ -601,28 +610,12 @@ RSpec/DuplicatedMetadata: Enabled: false RSpec/ExcessiveDocstringSpacing: Enabled: false -RSpec/FactoryBot/ConsistentParenthesesStyle: - Enabled: false -RSpec/FactoryBot/FactoryNameStyle: - Enabled: false -RSpec/FactoryBot/SyntaxMethods: - Enabled: false RSpec/IdenticalEqualityAssertion: Enabled: false RSpec/NoExpectationExample: Enabled: false RSpec/PendingWithoutReason: Enabled: false -RSpec/Rails/AvoidSetupHook: - Enabled: false -RSpec/Rails/HaveHttpStatus: - Enabled: false -RSpec/Rails/InferredSpecType: - Enabled: false -RSpec/Rails/MinitestAssertions: - Enabled: false -RSpec/Rails/TravelAround: - Enabled: false RSpec/RedundantAround: Enabled: false RSpec/SkipBlockInsideExample: @@ -633,6 +626,16 @@ RSpec/SubjectDeclaration: Enabled: false RSpec/VerifiedDoubleReference: Enabled: false +RSpecRails/AvoidSetupHook: + Enabled: false +RSpecRails/HaveHttpStatus: + Enabled: false +RSpecRails/InferredSpecType: + Enabled: false +RSpecRails/MinitestAssertions: + Enabled: false +RSpecRails/TravelAround: + Enabled: false Security/CompoundHash: Enabled: false Security/IoMethods: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 91592bcc..23d3be99 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,16 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-11-28 17:42:38 UTC using RuboCop version 1.48.1. +# on 2025-10-01 10:09:02 UTC using RuboCop version 1.73.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 4 +RSpec/ExpectInLet: + Exclude: + - 'spec/defines/config/server/service_spec.rb' + # Offense count: 128 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only diff --git a/Gemfile b/Gemfile index 1fbe2c69..0f55d9dd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,66 +1,90 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +# frozen_string_literal: true -def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} +# For puppetcore, set GEM_SOURCE_PUPPETCORE = 'https://rubygems-puppetcore.puppet.com' +gemsource_default = ENV['GEM_SOURCE'] || 'https://rubygems.org' +gemsource_puppetcore = if ENV['PUPPET_FORGE_TOKEN'] + 'https://rubygems-puppetcore.puppet.com' +else + ENV['GEM_SOURCE_PUPPETCORE'] || gemsource_default +end +source gemsource_default + +def location_for(place_or_constraint, fake_constraint = nil, opts = {}) + git_url_regex = /\A(?(?:https?|git)[:@][^#]*)(?:#(?.*))?/ + file_url_regex = %r{\Afile://(?.*)} + + if place_or_constraint && (git_url = place_or_constraint.match(git_url_regex)) + # Git source → ignore :source, keep fake_constraint + [fake_constraint, { git: git_url[:url], branch: git_url[:branch], require: false }].compact + + elsif place_or_constraint && (file_url = place_or_constraint.match(file_url_regex)) + # File source → ignore :source, keep fake_constraint or default >= 0 + [fake_constraint || '>= 0', { path: File.expand_path(file_url[:path]), require: false }] - if place_or_version && (git_url = place_or_version.match(git_url_regex)) - [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact - elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) - ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] else - [place_or_version, { require: false }] + # Plain version constraint → merge opts (including :source if provided) + [place_or_constraint, { require: false }.merge(opts)] + end +end + +# Print debug information if DEBUG_GEMS or VERBOSE is set +def print_gem_statement_for(gems) + puts 'DEBUG: Gem definitions that will be generated:' + gems.each do |gem_name, gem_params| + puts "DEBUG: gem #{([gem_name.inspect] + gem_params.map(&:inspect)).join(', ')}" end end group :development do - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "deep_merge", '~> 1.2.2', require: false gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false - gem "facterdb", '~> 2.1', require: false + gem "facterdb", '~> 2.1', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "facterdb", '~> 3.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "metadata-json-lint", '~> 4.0', require: false - gem "rspec-puppet-facts", '~> 4.0', require: false + gem "json-schema", '< 5.1.1', require: false + gem "rspec-puppet-facts", '~> 4.0', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "rspec-puppet-facts", '~> 5.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "dependency_checker", '~> 1.0.0', require: false gem "parallel_tests", '= 3.12.1', require: false gem "pry", '~> 0.10', require: false gem "simplecov-console", '~> 0.9', require: false - gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '~> 1.50.0', require: false - gem "rubocop-performance", '= 1.16.0', require: false - gem "rubocop-rspec", '= 2.19.0', require: false + gem "puppet-debugger", '~> 1.6', require: false + gem "rubocop", '~> 1.73.0', require: false + gem "rubocop-performance", '~> 1.24.0', require: false + gem "rubocop-rspec", '~> 3.5.0', require: false + gem "rubocop-rspec_rails", '~> 2.31.0', require: false + gem "rubocop-factory_bot", '~> 2.27.0', require: false + gem "rubocop-capybara", '~> 2.22.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "rexml", '>= 3.3.9', require: false + gem "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "rspec-retry", '= 0.4.5', require: false, platforms: [:ruby] end group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 7.0', require: false + gem "puppetlabs_spec_helper", '~> 8.0', require: false + gem "puppet-blacksmith", '~> 7.0', require: false end group :system_tests do - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "puppet_litmus", '~> 2.0', require: false, platforms: [:ruby, :x64_mingw] if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty? + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] if ENV['PUPPET_FORGE_TOKEN'].to_s.empty? gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "serverspec", '~> 2.41', require: false end -puppet_version = ENV['PUPPET_GEM_VERSION'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] - gems = {} +puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil) +facter_version = ENV.fetch('FACTER_GEM_VERSION', nil) +hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil) -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables - -gems['facter'] = location_for(facter_version) if facter_version -gems['hiera'] = location_for(hiera_version) if hiera_version +gems['puppet'] = location_for(puppet_version, nil, { source: gemsource_puppetcore }) +gems['facter'] = location_for(facter_version, nil, { source: gemsource_puppetcore }) +gems['hiera'] = location_for(hiera_version, nil, {}) if hiera_version +# Generate the gem definitions +print_gem_statement_for(gems) if ENV['DEBUG'] gems.each do |gem_name, gem_params| gem gem_name, *gem_params end @@ -68,12 +92,14 @@ end # Evaluate Gemfile.local and ~/.gemfile if they exist extra_gemfiles = [ "#{__FILE__}.local", - File.join(Dir.home, '.gemfile'), + File.join(Dir.home, '.gemfile') ] extra_gemfiles.each do |gemfile| - if File.file?(gemfile) && File.readable?(gemfile) - eval(File.read(gemfile), binding) - end + next unless File.file?(gemfile) && File.readable?(gemfile) + + # rubocop:disable Security/Eval + eval(File.read(gemfile), binding) + # rubocop:enable Security/Eval end # vim: syntax=ruby diff --git a/Rakefile b/Rakefile index 729911dd..d80bbc2b 100644 --- a/Rakefile +++ b/Rakefile @@ -7,4 +7,12 @@ require 'puppet-syntax/tasks/puppet-syntax' require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' PuppetLint.configuration.send('disable_relative') -PuppetLint.configuration.ignore_paths = ["examples/*.pp", "vendor/**/*.pp", "bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp"] +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_140chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_autoloader_layout') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.ignore_paths = [".vendor/**/*.pp", ".bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp", "tests/**/*.pp", "types/**/*.pp", "vendor/**/*.pp", "examples/*.pp", "bundle/**/*.pp"] + diff --git a/metadata.json b/metadata.json index 974e7855..fdf7dd78 100644 --- a/metadata.json +++ b/metadata.json @@ -18,7 +18,7 @@ }, { "name": "puppet/archive", - "version_requirement": ">= 1.0.0 < 8.0.0" + "version_requirement": ">= 1.0.0 < 9.0.0" } ], "operatingsystem_support": [ @@ -88,10 +88,10 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 9.0.0" + "version_requirement": ">= 8.0.0 < 9.0.0" } ], "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "pdk-version": "3.2.0", - "template-ref": "tags/3.2.0.4-0-g5d17ec1" + "pdk-version": "3.5.0 (ga43db72)", + "template-ref": "heads/main-0-g5c7dd04" } diff --git a/spec/acceptance/acceptance_1_readme_spec.rb b/spec/acceptance/acceptance_1_readme_spec.rb index 4bc99270..c78025c7 100644 --- a/spec/acceptance/acceptance_1_readme_spec.rb +++ b/spec/acceptance/acceptance_1_readme_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper_acceptance' confine_array = [ - (os[:family] =~ %r{debian|ubuntu} && os[:release] == '18.04'), - (os[:family].include?('redhat') && os[:release].start_with?('5')), + os[:family] =~ %r{debian|ubuntu} && os[:release] == '18.04', + os[:family].include?('redhat') && os[:release].start_with?('5'), ] stop_test = confine_array.any? diff --git a/spec/acceptance/acceptance_1b_spec.rb b/spec/acceptance/acceptance_1b_spec.rb index f663d678..dc8ee495 100644 --- a/spec/acceptance/acceptance_1b_spec.rb +++ b/spec/acceptance/acceptance_1b_spec.rb @@ -30,7 +30,11 @@ end end - let(:daemon_version) { '1.4.0' } + # NOTE: If tests fail manually apply the below manifest to debug. + # If it then shows an error regarding the commons-daemon--native-src + # update the daemon_version variable below to match the version found by navigating to + # /opt/apache-tomcat/bin/ and checking the shipped version of commons-daemon-native-src. + let(:daemon_version) { '1.4.1' } context 'Initial install Tomcat and verification' do it 'applies the manifest without error' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ae7c1f68..2f7fdae3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,7 +26,7 @@ begin require 'deep_merge' - default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + default_facts.deep_merge!(YAML.safe_load_file(f, permitted_classes: [], permitted_symbols: [], aliases: true)) rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index e2d1858c..417d35df 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -61,12 +61,12 @@ def latest_tomcat_tarball_url(version) require 'net/http' page = Net::HTTP.get(URI("https://tomcat.apache.org/download-#{version}0.cgi")) - url = ((match = page.match(%r{https?://.*?apache-tomcat-(.{4,9}).tar.gz})) && match[0]) + url = (match = page.match(%r{https?://.*?apache-tomcat-(.{4,9}).tar.gz})) && match[0] return url if url - mirror_url = ((match = page.match(%r{(https?://.*?)/})) && match[1]) + mirror_url = (match = page.match(%r{(https?://.*?)/})) && match[1] page = Net::HTTP.get(URI("#{mirror_url}/tomcat/tomcat-#{version}/")) - latest_version = ((match = page.match(%r{href="v(.{4,9})/"})) && match[1]) + latest_version = (match = page.match(%r{href="v(.{4,9})/"})) && match[1] "#{mirror_url}/tomcat/tomcat-#{version}/v#{latest_version}/bin/apache-tomcat-#{latest_version}.tar.gz" end