Skip to content

Commit

Permalink
Merge pull request #1 from puppetlabs/bug-fix_ruby3_incompatibility
Browse files Browse the repository at this point in the history
(bug) - Fix ruby 3.x incompatibility
  • Loading branch information
GSPatton committed Oct 27, 2023
2 parents 8008a19 + f717ce2 commit b9e1470
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 77 deletions.
55 changes: 21 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,31 @@
name: CI for Puppetfile Resolver
name: "ci"

on:
push:
branches:
- main
pull_request:
branches:
- main
- "main"
workflow_dispatch:

jobs:
build:
name: CI Tasks
spec:
strategy:
fail-fast: false
matrix:
ruby: [2.7]
check: [rspec]
os: [ubuntu-latest, windows-latest]
ruby_version:
- '2.7'
- '3.2'
include:
# Run linting
- ruby: 2.7
os: ubuntu-latest
check: rubocop
# Test on the oldest ruby we support
- ruby: 2.5
os: ubuntu-latest
check: rspec
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Output Ruby Information
run: |
echo "Ruby version"
ruby --version
echo "gem version"
gem --version
echo "bundler version"
bundle -v
- run: bundle exec ${{ matrix.check }}
- ruby_version: '2.7'
puppet_version: '~> 7.0'
- ruby_version: '3.2'
puppet_version: '~> 8.0'
runs-on:
- ubuntu-latest
- windows-latest
name: "spec (ruby ${{ matrix.ruby_version }} | puppet ${{ matrix.puppet_version }} - ${{ matrix.runs-on }})"
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
secrets: "inherit"
with:
ruby_version: ${{ matrix.ruby_version }}
puppet_gem_version: ${{ matrix.puppet_version }}
runs_on: ${{ matrix.runs-on }}
30 changes: 30 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "nightly"

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
spec:
strategy:
fail-fast: false
matrix:
ruby_version:
- '2.7'
- '3.2'
include:
- ruby_version: '2.7'
puppet_version: '~> 7.0'
- ruby_version: '3.2'
puppet_version: '~> 8.0'
runs-on:
- ubuntu-latest
- windows-latest
name: "spec (ruby ${{ matrix.ruby_version }} | puppet ${{ matrix.puppet_version }} - ${{ matrix.runs-on }})"
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
secrets: "inherit"
with:
ruby_version: ${{ matrix.ruby_version }}
puppet_gem_version: ${{ matrix.puppet_version }}
runs_on: ${{ matrix.runs-on }}
97 changes: 82 additions & 15 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,82 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-11-04 20:38:19 +0800 using RuboCop version 0.76.0.
# 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: 2
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# 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
Naming/FileName:
Exclude:
- 'lib/puppetfile-resolver.rb'
- 'puppetfile-cli.rb'
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-10-27 07:36:27 UTC using RuboCop version 1.48.1.
# 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: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/DuplicateRequire:
Exclude:
- 'lib/puppetfile-resolver/spec_searchers/git/gclone.rb'

# Offense count: 1
Lint/MissingSuper:
Exclude:
- 'lib/puppetfile-resolver/puppetfile/parser/errors.rb'

# Offense count: 2
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
# 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
Naming/FileName:
Exclude:
- 'lib/puppetfile-resolver.rb'
- 'puppetfile-cli.rb'

# Offense count: 27
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: separated, grouped
Style/AccessorGrouping:
Exclude:
- 'lib/puppetfile-resolver/models/module_dependency.rb'
- 'lib/puppetfile-resolver/models/module_specification.rb'
- 'lib/puppetfile-resolver/puppetfile/document.rb'
- 'lib/puppetfile-resolver/puppetfile/git_module.rb'
- 'lib/puppetfile-resolver/puppetfile/validation_errors.rb'
- 'lib/puppetfile-resolver/resolver.rb'
- 'lib/puppetfile-resolver/spec_searchers/configuration.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedMethods, AllowedPatterns.
# AllowedMethods: ==, equal?, eql?
Style/ClassEqualityComparison:
Exclude:
- 'lib/puppetfile-resolver/util.rb'

# Offense count: 1
Style/CombinableLoops:
Exclude:
- 'lib/puppetfile-resolver/puppetfile/document.rb'

# Offense count: 1
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/puppetfile-resolver/cache/base.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantAssignment:
Exclude:
- 'lib/puppetfile-resolver/puppetfile/parser/r10k_eval/module/local.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpEscape:
Exclude:
- 'lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb'

# Offense count: 7
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'lib/puppetfile-resolver/cache/persistent.rb'
- 'lib/puppetfile-resolver/spec_searchers/git/github.rb'
- 'lib/puppetfile-resolver/spec_searchers/git/gitlab.rb'
41 changes: 15 additions & 26 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
source 'https://rubygems.org'

# Specify your gem's dependencies in pdk.gemspec
gemspec

group :development do
gem 'rspec', '>= 3.2', :require => false
gem 'pry'
if RUBY_VERSION =~ /^2\.1\./
gem "rubocop", "<= 0.57.2", :require => false, :platforms => [:ruby, :x64_mingw]
gem 'rake', '~> 12.3', :require => false
else
gem "rubocop", "~> 0.80", :require => false, :platforms => [:ruby, :x64_mingw]
gem 'rake', '>= 10.4', :require => false
end
group :test do
gem 'rake'
gem 'rspec', '~> 3.1'
gem 'rspec-collection_matchers', '~> 1.0'
gem 'rspec-its', '~> 1.0'

gem "yard", :require => false
gem 'redcarpet', :require => false
gem 'github-markup', :require => false
end
gem 'rubocop', '~> 1.48.1'
gem 'rubocop-rspec', '~> 2.19'
gem 'rubocop-performance', '~> 1.16'

# Evaluate Gemfile.local and ~/.gemfile if they exist
extra_gemfiles = [
"#{__FILE__}.local",
File.join(Dir.home, '.gemfile'),
]
gem 'codecov'
gem 'simplecov'
end

extra_gemfiles.each do |gemfile|
if File.file?(gemfile) && File.readable?(gemfile)
eval(File.read(gemfile), binding)
end
group :development do
gem 'pry'
gem 'yard'
end
# vim: syntax=ruby
2 changes: 1 addition & 1 deletion lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.parse(puppetfile_contents)
rescue StandardError, LoadError => e
# Find the originating error from within the puppetfile
loc = e.backtrace_locations
.select { |item| item.absolute_path == PUPPETFILE_MONIKER }
.select { |item| item.path == PUPPETFILE_MONIKER }
.first
start_line_number = loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
end_line_number = loc.nil? ? puppetfile_contents.lines.count - 1 : loc.lineno - 1 # Line numbers from ruby are base 1
Expand Down
2 changes: 1 addition & 1 deletion lib/puppetfile-resolver/puppetfile/parser/r10k_eval/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def method_missing(method_name, *_args) # rubocop:disable Style/MethodMissingSup

def find_load_line_number
loc = Kernel.caller_locations
.find { |call_loc| call_loc.absolute_path == ::PuppetfileResolver::Puppetfile::Parser::R10KEval::PUPPETFILE_MONIKER }
.find { |call_loc| call_loc.path == ::PuppetfileResolver::Puppetfile::Parser::R10KEval::PUPPETFILE_MONIKER }
loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
end
end
Expand Down
2 changes: 2 additions & 0 deletions puppetfile-resolver.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency 'molinillo', '~> 0.6'
spec.add_runtime_dependency 'semantic_puppet', '~> 1.0'

spec.add_development_dependency 'webrick', '~> 1.8'
end

0 comments on commit b9e1470

Please sign in to comment.