Skip to content

Commit ce90975

Browse files
(CAT-2463) Update Gemfile (pdk update)
Signed-off-by: Gavin Didrichsen <gavin.didrichsen@gmail.com>
1 parent 82e4092 commit ce90975

File tree

6 files changed

+79
-59
lines changed

6 files changed

+79
-59
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ jobs:
1515
needs: Spec
1616
uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main"
1717
secrets: "inherit"
18-
with:
19-
flags: "--nightly"

.github/workflows/nightly.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ jobs:
1414
needs: Spec
1515
uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main"
1616
secrets: "inherit"
17-
with:
18-
flags: "--nightly"

.rubocop.yml

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
2-
require:
2+
plugins:
33
- rubocop-performance
44
- rubocop-rspec
5+
- rubocop-rspec_rails
6+
- rubocop-factory_bot
7+
- rubocop-capybara
58
AllCops:
69
NewCops: enable
710
DisplayCopNames: true
@@ -121,6 +124,12 @@ Capybara/CurrentPathExpectation:
121124
Enabled: false
122125
Capybara/VisibilityMatcher:
123126
Enabled: false
127+
FactoryBot/AttributeDefinedStatically:
128+
Enabled: false
129+
FactoryBot/CreateList:
130+
Enabled: false
131+
FactoryBot/FactoryClassName:
132+
Enabled: false
124133
Gemspec/DuplicatedAssignment:
125134
Enabled: false
126135
Gemspec/OrderedDependencies:
@@ -295,8 +304,6 @@ Performance/UriDefaultParser:
295304
Enabled: false
296305
RSpec/Be:
297306
Enabled: false
298-
RSpec/Capybara/FeatureMethods:
299-
Enabled: false
300307
RSpec/ContainExactly:
301308
Enabled: false
302309
RSpec/ContextMethod:
@@ -305,6 +312,8 @@ RSpec/ContextWording:
305312
Enabled: false
306313
RSpec/DescribeClass:
307314
Enabled: false
315+
RSpec/Dialect:
316+
Enabled: false
308317
RSpec/EmptyHook:
309318
Enabled: false
310319
RSpec/EmptyLineAfterExample:
@@ -321,12 +330,6 @@ RSpec/ExpectChange:
321330
Enabled: false
322331
RSpec/ExpectInHook:
323332
Enabled: false
324-
RSpec/FactoryBot/AttributeDefinedStatically:
325-
Enabled: false
326-
RSpec/FactoryBot/CreateList:
327-
Enabled: false
328-
RSpec/FactoryBot/FactoryClassName:
329-
Enabled: false
330333
RSpec/HooksBeforeExamples:
331334
Enabled: false
332335
RSpec/ImplicitBlockExpectation:
@@ -501,6 +504,12 @@ Capybara/SpecificFinders:
501504
Enabled: false
502505
Capybara/SpecificMatcher:
503506
Enabled: false
507+
FactoryBot/ConsistentParenthesesStyle:
508+
Enabled: false
509+
FactoryBot/FactoryNameStyle:
510+
Enabled: false
511+
FactoryBot/SyntaxMethods:
512+
Enabled: false
504513
Gemspec/DeprecatedAttributeAssignment:
505514
Enabled: false
506515
Gemspec/DevelopmentDependencies:
@@ -601,28 +610,12 @@ RSpec/DuplicatedMetadata:
601610
Enabled: false
602611
RSpec/ExcessiveDocstringSpacing:
603612
Enabled: false
604-
RSpec/FactoryBot/ConsistentParenthesesStyle:
605-
Enabled: false
606-
RSpec/FactoryBot/FactoryNameStyle:
607-
Enabled: false
608-
RSpec/FactoryBot/SyntaxMethods:
609-
Enabled: false
610613
RSpec/IdenticalEqualityAssertion:
611614
Enabled: false
612615
RSpec/NoExpectationExample:
613616
Enabled: false
614617
RSpec/PendingWithoutReason:
615618
Enabled: false
616-
RSpec/Rails/AvoidSetupHook:
617-
Enabled: false
618-
RSpec/Rails/HaveHttpStatus:
619-
Enabled: false
620-
RSpec/Rails/InferredSpecType:
621-
Enabled: false
622-
RSpec/Rails/MinitestAssertions:
623-
Enabled: false
624-
RSpec/Rails/TravelAround:
625-
Enabled: false
626619
RSpec/RedundantAround:
627620
Enabled: false
628621
RSpec/SkipBlockInsideExample:
@@ -633,6 +626,16 @@ RSpec/SubjectDeclaration:
633626
Enabled: false
634627
RSpec/VerifiedDoubleReference:
635628
Enabled: false
629+
RSpecRails/AvoidSetupHook:
630+
Enabled: false
631+
RSpecRails/HaveHttpStatus:
632+
Enabled: false
633+
RSpecRails/InferredSpecType:
634+
Enabled: false
635+
RSpecRails/MinitestAssertions:
636+
Enabled: false
637+
RSpecRails/TravelAround:
638+
Enabled: false
636639
Security/CompoundHash:
637640
Enabled: false
638641
Security/IoMethods:

Gemfile

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
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

@@ -30,9 +52,12 @@ group :development do
3052
gem "pry", '~> 0.10', require: false
3153
gem "simplecov-console", '~> 0.9', require: false
3254
gem "puppet-debugger", '~> 1.6', require: false
33-
gem "rubocop", '~> 1.50.0', require: false
34-
gem "rubocop-performance", '= 1.16.0', require: false
35-
gem "rubocop-rspec", '= 2.19.0', require: false
55+
gem "rubocop", '~> 1.73.0', require: false
56+
gem "rubocop-performance", '~> 1.24.0', require: false
57+
gem "rubocop-rspec", '~> 3.5.0', require: false
58+
gem "rubocop-rspec_rails", '~> 2.31.0', require: false
59+
gem "rubocop-factory_bot", '~> 2.27.0', require: false
60+
gem "rubocop-capybara", '~> 2.22.0', require: false
3661
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
3762
gem "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw]
3863
end
@@ -53,31 +78,27 @@ puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil)
5378
facter_version = ENV.fetch('FACTER_GEM_VERSION', nil)
5479
hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil)
5580

56-
# If PUPPET_FORGE_TOKEN is set then use authenticated source for both puppet and facter, since facter is a transitive dependency of puppet
57-
# Otherwise, do as before and use location_for to fetch gems from the default source
58-
if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
59-
gems['puppet'] = ['~> 8.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }]
60-
gems['facter'] = ['~> 4.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }]
61-
else
62-
gems['puppet'] = location_for(puppet_version)
63-
gems['facter'] = location_for(facter_version) if facter_version
64-
end
65-
66-
gems['hiera'] = location_for(hiera_version) if hiera_version
81+
gems['puppet'] = location_for(puppet_version, nil, { source: gemsource_puppetcore })
82+
gems['facter'] = location_for(facter_version, nil, { source: gemsource_puppetcore })
83+
gems['hiera'] = location_for(hiera_version, nil, {}) if hiera_version
6784

85+
# Generate the gem definitions
86+
print_gem_statement_for(gems) if ENV['DEBUG']
6887
gems.each do |gem_name, gem_params|
6988
gem gem_name, *gem_params
7089
end
7190

7291
# Evaluate Gemfile.local and ~/.gemfile if they exist
7392
extra_gemfiles = [
7493
"#{__FILE__}.local",
75-
File.join(Dir.home, '.gemfile'),
94+
File.join(Dir.home, '.gemfile')
7695
]
7796

7897
extra_gemfiles.each do |gemfile|
79-
if File.file?(gemfile) && File.readable?(gemfile)
80-
eval(File.read(gemfile), binding)
81-
end
98+
next unless File.file?(gemfile) && File.readable?(gemfile)
99+
100+
# rubocop:disable Security/Eval
101+
eval(File.read(gemfile), binding)
102+
# rubocop:enable Security/Eval
82103
end
83104
# vim: syntax=ruby

metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@
104104
],
105105
"description": "This module simply manages /etc/motd or the Windows Logon Message as a template, showing interpolation of system attributes",
106106
"template-url": "https://github.com/puppetlabs/pdk-templates.git#main",
107-
"template-ref": "heads/main-0-g11c0f3d",
108-
"pdk-version": "3.5.0"
107+
"template-ref": "heads/main-0-g5c7dd04",
108+
"pdk-version": "3.5.1"
109109
}

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
begin
2828
require 'deep_merge'
29-
default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true))
29+
default_facts.deep_merge!(YAML.safe_load_file(f, permitted_classes: [], permitted_symbols: [], aliases: true))
3030
rescue StandardError => e
3131
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
3232
end

0 commit comments

Comments
 (0)