diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 028abc5..8c23a50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..4f02189 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -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 }} diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 92fb0d5..d737759 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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' diff --git a/Gemfile b/Gemfile index b7a1226..670d1fe 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb b/lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb index 56480ed..ebd8934 100644 --- a/lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb +++ b/lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb @@ -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 diff --git a/lib/puppetfile-resolver/puppetfile/parser/r10k_eval/dsl.rb b/lib/puppetfile-resolver/puppetfile/parser/r10k_eval/dsl.rb index 3f3d6e3..576df41 100644 --- a/lib/puppetfile-resolver/puppetfile/parser/r10k_eval/dsl.rb +++ b/lib/puppetfile-resolver/puppetfile/parser/r10k_eval/dsl.rb @@ -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 diff --git a/puppetfile-resolver.gemspec b/puppetfile-resolver.gemspec index e411eab..b85e2ad 100644 --- a/puppetfile-resolver.gemspec +++ b/puppetfile-resolver.gemspec @@ -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