diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5738adb..97811fe9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,4 +14,6 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + with: + flags: "--latest-agent" secrets: "inherit" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 63a0ac78..bdeafb83 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -13,24 +13,6 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + with: + flags: "--latest-agent" secrets: "inherit" - - on-failure-workflow-restarter-proxy: - # (1) run this job after the "acceptance" job and... - needs: [Acceptance, Spec] - # (2) continue ONLY IF "acceptance" fails - if: always() && needs.Acceptance.result == 'failure' || needs.Spec.result == 'failure' - runs-on: ubuntu-latest - steps: - # (3) checkout this repository in order to "see" the following custom action - - name: Checkout repository - uses: actions/checkout@v4 - - # (4) "use" the custom action to retrigger the failed "acceptance job" above - - name: Trigger reusable workflow - uses: "puppetlabs/cat-github-actions/.github/actions/workflow-restarter-proxy@main" - env: - SOURCE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - repository: ${{ github.repository }} - run_id: ${{ github.run_id }} diff --git a/.rubocop.yml b/.rubocop.yml index c3409f41..4760bb7f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,16 +1,16 @@ --- inherit_from: .rubocop_todo.yml -plugins: - - rubocop-rspec - - rubocop-rspec_rails - - rubocop-performance - - rubocop-factory_bot - - rubocop-capybara +plugins: +- rubocop-performance +- rubocop-rspec +- rubocop-rspec_rails +- rubocop-factory_bot +- rubocop-capybara AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: '3.1' + TargetRubyVersion: 3.1 Include: - "**/*.rb" Exclude: @@ -125,6 +125,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: @@ -299,8 +305,6 @@ Performance/UriDefaultParser: Enabled: false RSpec/Be: Enabled: false -RSpec/Dialect: - Enabled: false RSpec/ContainExactly: Enabled: false RSpec/ContextMethod: @@ -309,6 +313,8 @@ RSpec/ContextWording: Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/Dialect: + Enabled: false RSpec/EmptyHook: Enabled: false RSpec/EmptyLineAfterExample: @@ -325,12 +331,6 @@ RSpec/ExpectChange: Enabled: false RSpec/ExpectInHook: Enabled: false -FactoryBot/AttributeDefinedStatically: - Enabled: false -FactoryBot/CreateList: - Enabled: false -FactoryBot/FactoryClassName: - Enabled: false RSpec/HooksBeforeExamples: Enabled: false RSpec/ImplicitBlockExpectation: @@ -505,6 +505,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: @@ -605,28 +611,12 @@ RSpec/DuplicatedMetadata: Enabled: false RSpec/ExcessiveDocstringSpacing: Enabled: false -FactoryBot/ConsistentParenthesesStyle: - Enabled: false -FactoryBot/FactoryNameStyle: - Enabled: false -FactoryBot/SyntaxMethods: - Enabled: false RSpec/IdenticalEqualityAssertion: Enabled: false RSpec/NoExpectationExample: Enabled: false RSpec/PendingWithoutReason: Enabled: false -RSpecRails/AvoidSetupHook: - Enabled: false -RSpecRails/HaveHttpStatus: - Enabled: false -RSpecRails/InferredSpecType: - Enabled: false -RSpecRails/MinitestAssertions: - Enabled: false -RSpecRails/TravelAround: - Enabled: false RSpec/RedundantAround: Enabled: false RSpec/SkipBlockInsideExample: @@ -637,6 +627,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 c87dc433..03a9e5c4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-09-30 14:23:25 UTC using RuboCop version 1.73.2. +# on 2025-10-01 08:51:22 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 diff --git a/Gemfile b/Gemfile index c407c11e..65616e42 100644 --- a/Gemfile +++ b/Gemfile @@ -1,39 +1,65 @@ -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.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", '~> 3.0', 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 "json-schema", '< 5.1.1', require: false - gem "rspec-puppet-facts", '~> 5.0', 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 "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 "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 "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "github_changelog_generator", require: false gem "ruby-pwsh", require: false end @@ -43,7 +69,8 @@ group :development, :release_prep do 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 @@ -53,18 +80,12 @@ puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil) facter_version = ENV.fetch('FACTER_GEM_VERSION', nil) hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil) -# If PUPPET_FORGE_TOKEN is set then use authenticated source for both puppet and facter, since facter is a transitive dependency of puppet -# Otherwise, do as before and use location_for to fetch gems from the default source -if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty? - gems['puppet'] = ['~> 8.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }] - gems['facter'] = ['~> 4.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }] -else - gems['puppet'] = location_for(puppet_version) - gems['facter'] = location_for(facter_version) if facter_version -end - -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 @@ -72,12 +93,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/metadata.json b/metadata.json index 51a1974c..ce8c5223 100644 --- a/metadata.json +++ b/metadata.json @@ -41,7 +41,7 @@ "desired-state-configuration", "dsc" ], - "pdk-version": "3.4.0", + "pdk-version": "3.5.0", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "heads/main-0-g1a55f8d" + "template-ref": "heads/main-0-g5c7dd04" }