Skip to content

Commit b9e1470

Browse files
authored
Merge pull request #1 from puppetlabs/bug-fix_ruby3_incompatibility
(bug) - Fix ruby 3.x incompatibility
2 parents 8008a19 + f717ce2 commit b9e1470

File tree

7 files changed

+152
-77
lines changed

7 files changed

+152
-77
lines changed

.github/workflows/ci.yml

+21-34
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,31 @@
1-
name: CI for Puppetfile Resolver
1+
name: "ci"
22

33
on:
4-
push:
5-
branches:
6-
- main
74
pull_request:
85
branches:
9-
- main
6+
- "main"
7+
workflow_dispatch:
108

119
jobs:
12-
build:
13-
name: CI Tasks
10+
spec:
1411
strategy:
1512
fail-fast: false
1613
matrix:
17-
ruby: [2.7]
18-
check: [rspec]
19-
os: [ubuntu-latest, windows-latest]
14+
ruby_version:
15+
- '2.7'
16+
- '3.2'
2017
include:
21-
# Run linting
22-
- ruby: 2.7
23-
os: ubuntu-latest
24-
check: rubocop
25-
# Test on the oldest ruby we support
26-
- ruby: 2.5
27-
os: ubuntu-latest
28-
check: rspec
29-
runs-on: ${{ matrix.os }}
30-
steps:
31-
- uses: actions/checkout@v2
32-
- uses: ruby/setup-ruby@v1
33-
with:
34-
ruby-version: ${{ matrix.ruby }}
35-
bundler-cache: true
36-
- name: Output Ruby Information
37-
run: |
38-
echo "Ruby version"
39-
ruby --version
40-
echo "gem version"
41-
gem --version
42-
echo "bundler version"
43-
bundle -v
44-
- run: bundle exec ${{ matrix.check }}
18+
- ruby_version: '2.7'
19+
puppet_version: '~> 7.0'
20+
- ruby_version: '3.2'
21+
puppet_version: '~> 8.0'
22+
runs-on:
23+
- ubuntu-latest
24+
- windows-latest
25+
name: "spec (ruby ${{ matrix.ruby_version }} | puppet ${{ matrix.puppet_version }} - ${{ matrix.runs-on }})"
26+
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
27+
secrets: "inherit"
28+
with:
29+
ruby_version: ${{ matrix.ruby_version }}
30+
puppet_gem_version: ${{ matrix.puppet_version }}
31+
runs_on: ${{ matrix.runs-on }}

.github/workflows/nightly.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "nightly"
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
spec:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
ruby_version:
14+
- '2.7'
15+
- '3.2'
16+
include:
17+
- ruby_version: '2.7'
18+
puppet_version: '~> 7.0'
19+
- ruby_version: '3.2'
20+
puppet_version: '~> 8.0'
21+
runs-on:
22+
- ubuntu-latest
23+
- windows-latest
24+
name: "spec (ruby ${{ matrix.ruby_version }} | puppet ${{ matrix.puppet_version }} - ${{ matrix.runs-on }})"
25+
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
26+
secrets: "inherit"
27+
with:
28+
ruby_version: ${{ matrix.ruby_version }}
29+
puppet_gem_version: ${{ matrix.puppet_version }}
30+
runs_on: ${{ matrix.runs-on }}

.rubocop_todo.yml

+82-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,82 @@
1-
# This configuration was generated by
2-
# `rubocop --auto-gen-config`
3-
# on 2019-11-04 20:38:19 +0800 using RuboCop version 0.76.0.
4-
# The point is for the user to remove these configuration records
5-
# one by one as the offenses are removed from the code base.
6-
# Note that changes in the inspected code, or installation of new
7-
# versions of RuboCop, may require this file to be generated again.
8-
9-
# Offense count: 2
10-
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
11-
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
12-
Naming/FileName:
13-
Exclude:
14-
- 'lib/puppetfile-resolver.rb'
15-
- 'puppetfile-cli.rb'
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2023-10-27 07:36:27 UTC using RuboCop version 1.48.1.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 1
10+
# This cop supports unsafe autocorrection (--autocorrect-all).
11+
Lint/DuplicateRequire:
12+
Exclude:
13+
- 'lib/puppetfile-resolver/spec_searchers/git/gclone.rb'
14+
15+
# Offense count: 1
16+
Lint/MissingSuper:
17+
Exclude:
18+
- 'lib/puppetfile-resolver/puppetfile/parser/errors.rb'
19+
20+
# Offense count: 2
21+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
22+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
23+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
24+
Naming/FileName:
25+
Exclude:
26+
- 'lib/puppetfile-resolver.rb'
27+
- 'puppetfile-cli.rb'
28+
29+
# Offense count: 27
30+
# This cop supports safe autocorrection (--autocorrect).
31+
# Configuration parameters: EnforcedStyle.
32+
# SupportedStyles: separated, grouped
33+
Style/AccessorGrouping:
34+
Exclude:
35+
- 'lib/puppetfile-resolver/models/module_dependency.rb'
36+
- 'lib/puppetfile-resolver/models/module_specification.rb'
37+
- 'lib/puppetfile-resolver/puppetfile/document.rb'
38+
- 'lib/puppetfile-resolver/puppetfile/git_module.rb'
39+
- 'lib/puppetfile-resolver/puppetfile/validation_errors.rb'
40+
- 'lib/puppetfile-resolver/resolver.rb'
41+
- 'lib/puppetfile-resolver/spec_searchers/configuration.rb'
42+
43+
# Offense count: 1
44+
# This cop supports safe autocorrection (--autocorrect).
45+
# Configuration parameters: AllowedMethods, AllowedPatterns.
46+
# AllowedMethods: ==, equal?, eql?
47+
Style/ClassEqualityComparison:
48+
Exclude:
49+
- 'lib/puppetfile-resolver/util.rb'
50+
51+
# Offense count: 1
52+
Style/CombinableLoops:
53+
Exclude:
54+
- 'lib/puppetfile-resolver/puppetfile/document.rb'
55+
56+
# Offense count: 1
57+
# Configuration parameters: AllowedMethods.
58+
# AllowedMethods: respond_to_missing?
59+
Style/OptionalBooleanParameter:
60+
Exclude:
61+
- 'lib/puppetfile-resolver/cache/base.rb'
62+
63+
# Offense count: 1
64+
# This cop supports safe autocorrection (--autocorrect).
65+
Style/RedundantAssignment:
66+
Exclude:
67+
- 'lib/puppetfile-resolver/puppetfile/parser/r10k_eval/module/local.rb'
68+
69+
# Offense count: 3
70+
# This cop supports safe autocorrection (--autocorrect).
71+
Style/RedundantRegexpEscape:
72+
Exclude:
73+
- 'lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb'
74+
75+
# Offense count: 7
76+
# This cop supports unsafe autocorrection (--autocorrect-all).
77+
# Configuration parameters: Mode.
78+
Style/StringConcatenation:
79+
Exclude:
80+
- 'lib/puppetfile-resolver/cache/persistent.rb'
81+
- 'lib/puppetfile-resolver/spec_searchers/git/github.rb'
82+
- 'lib/puppetfile-resolver/spec_searchers/git/gitlab.rb'

Gemfile

+15-26
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
1-
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
1+
source 'https://rubygems.org'
22

3-
# Specify your gem's dependencies in pdk.gemspec
43
gemspec
54

6-
group :development do
7-
gem 'rspec', '>= 3.2', :require => false
8-
gem 'pry'
9-
if RUBY_VERSION =~ /^2\.1\./
10-
gem "rubocop", "<= 0.57.2", :require => false, :platforms => [:ruby, :x64_mingw]
11-
gem 'rake', '~> 12.3', :require => false
12-
else
13-
gem "rubocop", "~> 0.80", :require => false, :platforms => [:ruby, :x64_mingw]
14-
gem 'rake', '>= 10.4', :require => false
15-
end
5+
group :test do
6+
gem 'rake'
7+
gem 'rspec', '~> 3.1'
8+
gem 'rspec-collection_matchers', '~> 1.0'
9+
gem 'rspec-its', '~> 1.0'
1610

17-
gem "yard", :require => false
18-
gem 'redcarpet', :require => false
19-
gem 'github-markup', :require => false
20-
end
11+
gem 'rubocop', '~> 1.48.1'
12+
gem 'rubocop-rspec', '~> 2.19'
13+
gem 'rubocop-performance', '~> 1.16'
2114

22-
# Evaluate Gemfile.local and ~/.gemfile if they exist
23-
extra_gemfiles = [
24-
"#{__FILE__}.local",
25-
File.join(Dir.home, '.gemfile'),
26-
]
15+
gem 'codecov'
16+
gem 'simplecov'
17+
end
2718

28-
extra_gemfiles.each do |gemfile|
29-
if File.file?(gemfile) && File.readable?(gemfile)
30-
eval(File.read(gemfile), binding)
31-
end
19+
group :development do
20+
gem 'pry'
21+
gem 'yard'
3222
end
33-
# vim: syntax=ruby

lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def self.parse(puppetfile_contents)
2121
rescue StandardError, LoadError => e
2222
# Find the originating error from within the puppetfile
2323
loc = e.backtrace_locations
24-
.select { |item| item.absolute_path == PUPPETFILE_MONIKER }
24+
.select { |item| item.path == PUPPETFILE_MONIKER }
2525
.first
2626
start_line_number = loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
2727
end_line_number = loc.nil? ? puppetfile_contents.lines.count - 1 : loc.lineno - 1 # Line numbers from ruby are base 1

lib/puppetfile-resolver/puppetfile/parser/r10k_eval/dsl.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def method_missing(method_name, *_args) # rubocop:disable Style/MethodMissingSup
4141

4242
def find_load_line_number
4343
loc = Kernel.caller_locations
44-
.find { |call_loc| call_loc.absolute_path == ::PuppetfileResolver::Puppetfile::Parser::R10KEval::PUPPETFILE_MONIKER }
44+
.find { |call_loc| call_loc.path == ::PuppetfileResolver::Puppetfile::Parser::R10KEval::PUPPETFILE_MONIKER }
4545
loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
4646
end
4747
end

puppetfile-resolver.gemspec

+2
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ Gem::Specification.new do |spec|
2020

2121
spec.add_runtime_dependency 'molinillo', '~> 0.6'
2222
spec.add_runtime_dependency 'semantic_puppet', '~> 1.0'
23+
24+
spec.add_development_dependency 'webrick', '~> 1.8'
2325
end

0 commit comments

Comments
 (0)