Skip to content

Commit d230e80

Browse files
authored
Merge pull request #1688 from puppetlabs/CAT-2381-Puppetcore_update
(CAT-2381) Puppetcore update
2 parents 1e55070 + b39f7ef commit d230e80

File tree

17 files changed

+99
-237
lines changed

17 files changed

+99
-237
lines changed

.fixtures.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ fixtures:
66
"provision": "https://github.com/puppetlabs/provision.git"
77
puppet_agent:
88
repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git'
9-
ref: v4.21.0

.github/workflows/ci.yml

Lines changed: 5 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -9,100 +9,11 @@ on:
99
jobs:
1010
Spec:
1111
uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main"
12-
with:
13-
runs_on: "ubuntu-24.04"
1412
secrets: "inherit"
1513

16-
setup_matrix:
17-
name: "Setup Test Matrix"
18-
needs: "Spec"
19-
runs-on: ubuntu-24.04
20-
outputs:
21-
matrix: ${{ steps.get-matrix.outputs.matrix }}
22-
23-
steps:
24-
- name: Checkout Source
25-
uses: actions/checkout@v3
26-
27-
- name: Activate Ruby 3.1
28-
uses: ruby/setup-ruby@v1
29-
with:
30-
ruby-version: "3.1"
31-
bundler-cache: true
32-
33-
- name: Print bundle environment
34-
run: |
35-
echo ::group::bundler environment
36-
bundle env
37-
echo ::endgroup::
38-
39-
- name: Setup Acceptance Test Matrix
40-
id: get-matrix
41-
run: |
42-
bundle exec matrix_from_metadata_v2 --exclude-platforms '["Debian-12-arm", "Ubuntu-22.04-arm", "RedHat-9-arm"]'
43-
4414
Acceptance:
45-
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
46-
needs:
47-
- setup_matrix
48-
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
49-
50-
runs-on: ubuntu-24.04
51-
strategy:
52-
fail-fast: false
53-
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
54-
55-
env:
56-
PUPPET_GEM_VERSION: '~> 7.24'
57-
FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main'
58-
59-
steps:
60-
- name: "Install Twingate"
61-
uses: "twingate/github-action@v1"
62-
with:
63-
service-key: ${{ secrets.TWINGATE_PUBLIC_REPO_KEY }}
64-
65-
- name: Checkout Source
66-
uses: actions/checkout@v3
67-
68-
- name: Activate Ruby 3.1
69-
uses: ruby/setup-ruby@v1
70-
with:
71-
ruby-version: "3.1"
72-
bundler-cache: true
73-
74-
- name: Print bundle environment
75-
run: |
76-
bundle env
77-
78-
- name: "Disable mysqld apparmor profile"
79-
if: ${{matrix.platforms.provider == 'docker'}}
80-
run: |
81-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
82-
sudo apparmor_parser -R /etc/apparmor.d/disable/usr.sbin.mysqld
83-
sudo systemctl disable apparmor
84-
sudo systemctl stop apparmor
85-
86-
- name: Provision test environment
87-
run: |
88-
bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
89-
FILE='spec/fixtures/litmus_inventory.yaml'
90-
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
91-
92-
- name: Install agent
93-
run: |
94-
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
95-
96-
- name: Install module
97-
run: |
98-
bundle exec rake 'litmus:install_module'
99-
100-
- name: Run acceptance tests
101-
run: |
102-
bundle exec rake 'litmus:acceptance:parallel'
103-
104-
- name: Remove test environment
105-
if: ${{ always() }}
106-
continue-on-error: true
107-
run: |
108-
bundle exec rake 'litmus:tear_down'
15+
needs: Spec
16+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main"
17+
with:
18+
flags: "--nightly --platform-exclude centos-7 --platform-exclude scientific-7 --platform-exclude oraclelinux-7 --platform-exclude almalinux-8 --arch-exclude arm"
19+
secrets: "inherit"

.github/workflows/nightly.yml

Lines changed: 5 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -8,100 +8,11 @@ on:
88
jobs:
99
Spec:
1010
uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main"
11-
with:
12-
runs_on: "ubuntu-24.04"
1311
secrets: "inherit"
1412

15-
setup_matrix:
16-
name: "Setup Test Matrix"
17-
needs: "Spec"
18-
runs-on: ubuntu-24.04
19-
outputs:
20-
matrix: ${{ steps.get-matrix.outputs.matrix }}
21-
22-
steps:
23-
- name: Checkout Source
24-
uses: actions/checkout@v3
25-
26-
- name: Activate Ruby 3.1
27-
uses: ruby/setup-ruby@v1
28-
with:
29-
ruby-version: "3.1"
30-
bundler-cache: true
31-
32-
- name: Print bundle environment
33-
run: |
34-
echo ::group::bundler environment
35-
bundle env
36-
echo ::endgroup::
37-
38-
- name: Setup Acceptance Test Matrix
39-
id: get-matrix
40-
run: |
41-
bundle exec matrix_from_metadata_v2 --exclude-platforms '["Debian-12-arm", "Ubuntu-22.04-arm", "RedHat-9-arm"]'
42-
4313
Acceptance:
44-
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
45-
needs:
46-
- setup_matrix
47-
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
48-
49-
runs-on: ubuntu-24.04
50-
strategy:
51-
fail-fast: false
52-
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
53-
54-
env:
55-
PUPPET_GEM_VERSION: '~> 7.24'
56-
FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main'
57-
58-
steps:
59-
- name: "Install Twingate"
60-
uses: "twingate/github-action@v1"
61-
with:
62-
service-key: ${{ secrets.TWINGATE_PUBLIC_REPO_KEY }}
63-
64-
- name: Checkout Source
65-
uses: actions/checkout@v3
66-
67-
- name: Activate Ruby 3.1
68-
uses: ruby/setup-ruby@v1
69-
with:
70-
ruby-version: "3.1"
71-
bundler-cache: true
72-
73-
- name: Print bundle environment
74-
run: |
75-
bundle env
76-
77-
- name: "Disable mysqld apparmor profile"
78-
if: ${{matrix.platforms.provider == 'docker'}}
79-
run: |
80-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
81-
sudo apparmor_parser -R /etc/apparmor.d/disable/usr.sbin.mysqld
82-
sudo systemctl disable apparmor
83-
sudo systemctl stop apparmor
84-
85-
- name: Provision test environment
86-
run: |
87-
bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
88-
FILE='spec/fixtures/litmus_inventory.yaml'
89-
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
90-
91-
- name: Install agent
92-
run: |
93-
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
94-
95-
- name: Install module
96-
run: |
97-
bundle exec rake 'litmus:install_module'
98-
99-
- name: Run acceptance tests
100-
run: |
101-
bundle exec rake 'litmus:acceptance:parallel'
102-
103-
- name: Remove test environment
104-
if: ${{ always() }}
105-
continue-on-error: true
106-
run: |
107-
bundle exec rake 'litmus:tear_down'
14+
needs: Spec
15+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main"
16+
with:
17+
flags: "--nightly --platform-exclude centos-7 --platform-exclude scientific-7 --platform-exclude oraclelinux-7 --platform-exclude almalinux-8 --arch-exclude arm"
18+
secrets: "inherit"

.puppet-lint.rc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
--fail-on-warnings
12
--relative
3+
--no-80chars-check
4+
--no-140chars-check
5+
--no-class_inherits_from_params_class-check
6+
--no-autoloader_layout-check
7+
--no-documentation-check
8+
--no-single_quote_string_with_variables-check
29
--no-anchor_resource-check
310
--no-params_empty_string_assignment-check
11+
--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
22
inherit_from: .rubocop_todo.yml
3+
34
require:
45
- rubocop-performance
56
- rubocop-rspec
67
AllCops:
78
NewCops: enable
89
DisplayCopNames: true
9-
TargetRubyVersion: '2.6'
10+
TargetRubyVersion: 3.1
1011
Include:
1112
- "**/*.rb"
1213
Exclude:

Gemfile

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,101 @@
1-
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
1+
# frozen_string_literal: true
22

3-
def location_for(place_or_version, fake_version = nil)
4-
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
5-
file_url_regex = %r{\Afile:\/\/(?<path>.*)}
3+
# For puppetcore, set GEM_SOURCE_PUPPETCORE = 'https://rubygems-puppetcore.puppet.com'
4+
gemsource_default = ENV['GEM_SOURCE'] || 'https://rubygems.org'
5+
gemsource_puppetcore = if ENV['PUPPET_FORGE_TOKEN']
6+
'https://rubygems-puppetcore.puppet.com'
7+
else
8+
ENV['GEM_SOURCE_PUPPETCORE'] || gemsource_default
9+
end
10+
source gemsource_default
11+
12+
def location_for(place_or_constraint, fake_constraint = nil, opts = {})
13+
git_url_regex = /\A(?<url>(?:https?|git)[:@][^#]*)(?:#(?<branch>.*))?/
14+
file_url_regex = %r{\Afile://(?<path>.*)}
15+
16+
if place_or_constraint && (git_url = place_or_constraint.match(git_url_regex))
17+
# Git source → ignore :source, keep fake_constraint
18+
[fake_constraint, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
19+
20+
elsif place_or_constraint && (file_url = place_or_constraint.match(file_url_regex))
21+
# File source → ignore :source, keep fake_constraint or default >= 0
22+
[fake_constraint || '>= 0', { path: File.expand_path(file_url[:path]), require: false }]
623

7-
if place_or_version && (git_url = place_or_version.match(git_url_regex))
8-
[fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
9-
elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
10-
['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
1124
else
12-
[place_or_version, { require: false }]
25+
# Plain version constraint → merge opts (including :source if provided)
26+
[place_or_constraint, { require: false }.merge(opts)]
27+
end
28+
end
29+
30+
# Print debug information if DEBUG_GEMS or VERBOSE is set
31+
def print_gem_statement_for(gems)
32+
puts 'DEBUG: Gem definitions that will be generated:'
33+
gems.each do |gem_name, gem_params|
34+
puts "DEBUG: gem #{([gem_name.inspect] + gem_params.map(&:inspect)).join(', ')}"
1335
end
1436
end
1537

1638
group :development do
17-
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))
18-
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))
19-
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))
2039
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))
2140
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))
2241
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))
2342
gem "deep_merge", '~> 1.2.2', require: false
2443
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
25-
gem "facterdb", '~> 2.1', require: false
44+
gem "facterdb", '~> 2.1', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
45+
gem "facterdb", '~> 3.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
2646
gem "metadata-json-lint", '~> 4.0', require: false
27-
gem "rspec-puppet-facts", '~> 4.0', require: false
47+
gem "json-schema", '< 5.1.1', require: false
48+
gem "rspec-puppet-facts", '~> 4.0', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
49+
gem "rspec-puppet-facts", '~> 5.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
2850
gem "dependency_checker", '~> 1.0.0', require: false
2951
gem "parallel_tests", '= 3.12.1', require: false
3052
gem "pry", '~> 0.10', require: false
3153
gem "simplecov-console", '~> 0.9', require: false
32-
gem "puppet-debugger", '~> 1.0', require: false
54+
gem "puppet-debugger", '~> 1.6', require: false
3355
gem "rubocop", '~> 1.50.0', require: false
3456
gem "rubocop-performance", '= 1.16.0', require: false
3557
gem "rubocop-rspec", '= 2.19.0', require: false
3658
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
37-
gem "rexml", '>= 3.3.9', require: false
59+
gem "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw]
3860
end
3961
group :development, :release_prep do
4062
gem "puppet-strings", '~> 4.0', require: false
41-
gem "puppetlabs_spec_helper", '~> 7.0', require: false
63+
gem "puppetlabs_spec_helper", '~> 8.0', require: false
64+
gem "puppet-blacksmith", '~> 7.0', require: false
4265
end
4366
group :system_tests do
44-
gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
67+
gem "puppet_litmus", '~> 2.0', require: false, platforms: [:ruby, :x64_mingw] if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
68+
gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] if ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
4569
gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw]
4670
gem "serverspec", '~> 2.41', require: false
4771
end
4872

49-
puppet_version = ENV['PUPPET_GEM_VERSION']
50-
facter_version = ENV['FACTER_GEM_VERSION']
51-
hiera_version = ENV['HIERA_GEM_VERSION']
52-
5373
gems = {}
74+
puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil)
75+
facter_version = ENV.fetch('FACTER_GEM_VERSION', nil)
76+
hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil)
5477

55-
gems['puppet'] = location_for(puppet_version)
56-
57-
# If facter or hiera versions have been specified via the environment
58-
# variables
59-
60-
gems['facter'] = location_for(facter_version) if facter_version
61-
gems['hiera'] = location_for(hiera_version) if hiera_version
78+
gems['puppet'] = location_for(puppet_version, nil, { source: gemsource_puppetcore })
79+
gems['facter'] = location_for(facter_version, nil, { source: gemsource_puppetcore })
80+
gems['hiera'] = location_for(hiera_version, nil, {}) if hiera_version
6281

82+
# Generate the gem definitions
83+
print_gem_statement_for(gems) if ENV['DEBUG']
6384
gems.each do |gem_name, gem_params|
6485
gem gem_name, *gem_params
6586
end
6687

6788
# Evaluate Gemfile.local and ~/.gemfile if they exist
6889
extra_gemfiles = [
6990
"#{__FILE__}.local",
70-
File.join(Dir.home, '.gemfile'),
91+
File.join(Dir.home, '.gemfile')
7192
]
7293

7394
extra_gemfiles.each do |gemfile|
74-
if File.file?(gemfile) && File.readable?(gemfile)
75-
eval(File.read(gemfile), binding)
76-
end
95+
next unless File.file?(gemfile) && File.readable?(gemfile)
96+
97+
# rubocop:disable Security/Eval
98+
eval(File.read(gemfile), binding)
99+
# rubocop:enable Security/Eval
77100
end
78101
# vim: syntax=ruby

Rakefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@ require 'puppet-syntax/tasks/puppet-syntax'
77
require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings'
88

99
PuppetLint.configuration.send('disable_relative')
10+
PuppetLint.configuration.send('disable_80chars')
11+
PuppetLint.configuration.send('disable_140chars')
12+
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
13+
PuppetLint.configuration.send('disable_autoloader_layout')
14+
PuppetLint.configuration.send('disable_documentation')
15+
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
1016
PuppetLint.configuration.send('disable_anchor_resource')
1117
PuppetLint.configuration.send('disable_params_empty_string_assignment')
18+
PuppetLint.configuration.fail_on_warnings = true
19+
PuppetLint.configuration.ignore_paths = [".vendor/**/*.pp", ".bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp", "tests/**/*.pp", "types/**/*.pp", "vendor/**/*.pp"]
20+

0 commit comments

Comments
 (0)