From c20482a2a8d91392c211b9992773d8348c11b9b6 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Thu, 9 Jun 2022 14:51:48 +0200 Subject: [PATCH 1/3] Use bundler-cache option in GitHub Actions This avoids the need to install bundler and adds caching between runs. --- .github/workflows/ruby-rspec.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ruby-rspec.yml b/.github/workflows/ruby-rspec.yml index 6108934..16c60a2 100644 --- a/.github/workflows/ruby-rspec.yml +++ b/.github/workflows/ruby-rspec.yml @@ -22,9 +22,7 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} + bundler-cache: true - name: Build and test with Rspec - run: | - gem install bundler - bundle install --jobs 4 --retry 3 - bundle exec rspec + run: bundle exec rspec From 66df7fe86c30b19f3530066378c59d8206191851 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Thu, 9 Jun 2022 14:55:08 +0200 Subject: [PATCH 2/3] Remove redundant conditionals on RUBY_VERSION The minimum version was declared as Ruby 2.4 so these conditionals do not make sense. Fixes: 05a4e77279ddf6c66913016661099bc320edc1c5 --- puppet_forge.gemspec | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/puppet_forge.gemspec b/puppet_forge.gemspec index ea22bf7..5ff9e17 100644 --- a/puppet_forge.gemspec +++ b/puppet_forge.gemspec @@ -31,8 +31,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "cane" spec.add_development_dependency "yard" spec.add_development_dependency "redcarpet" - - # Install the right pry debugging combo depending on ruby version. - spec.add_development_dependency "pry-debugger" if RUBY_VERSION <= '1.9.3' - spec.add_development_dependency "pry-byebug" if RUBY_VERSION >= '2.0.0' + spec.add_development_dependency "pry-byebug" end From 06102bc9478d9d19fbe12b505639fb253d29ba54 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Thu, 9 Jun 2022 15:04:42 +0200 Subject: [PATCH 3/3] Move to Faraday 2.x It does not attempt to support Faraday 1.x as well because dependency wise it would be impossible to pull in the correct middleware. That is why a hard switch was made. This moves the minimum Ruby version to 2.6 since that's what Faraday 2 has as the minimum version. It also pulls in faraday-follow_redirects, which was previously part of Faraday itself. The registration is now done without a lamba since it's allowed to pass in a constant. CI is also modified to test on all actual Ruby version that currently match the required_ruby_version in the gemspec. That is, 2.6 - 3.1. --- .github/workflows/ruby-rspec.yml | 6 +++++- lib/puppet_forge/connection.rb | 4 ++-- lib/puppet_forge/connection/connection_failure.rb | 2 +- puppet_forge.gemspec | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ruby-rspec.yml b/.github/workflows/ruby-rspec.yml index 16c60a2..d89bcbf 100644 --- a/.github/workflows/ruby-rspec.yml +++ b/.github/workflows/ruby-rspec.yml @@ -14,7 +14,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [2.7, 2.6, 2.5] + ruby: + - '3.1' + - '3.0' + - '2.7' + - '2.6' steps: - uses: actions/checkout@v1 diff --git a/lib/puppet_forge/connection.rb b/lib/puppet_forge/connection.rb index d431346..564749c 100644 --- a/lib/puppet_forge/connection.rb +++ b/lib/puppet_forge/connection.rb @@ -1,7 +1,7 @@ require 'puppet_forge/connection/connection_failure' require 'faraday' -require 'faraday_middleware' +require 'faraday/follow_redirects' module PuppetForge # Provide a common mixin for adding a HTTP connection to classes. @@ -115,7 +115,7 @@ def make_connection(url, adapter_args = nil, opts = {}) end Faraday.new(url, options) do |builder| - builder.use FaradayMiddleware::FollowRedirects + builder.use Faraday::FollowRedirects::Middleware builder.response(:json, :content_type => /\bjson$/, :parser_options => { :symbolize_names => true }) builder.response(:raise_error) builder.use(:connection_failure) diff --git a/lib/puppet_forge/connection/connection_failure.rb b/lib/puppet_forge/connection/connection_failure.rb index df2f27f..1c2ce7a 100644 --- a/lib/puppet_forge/connection/connection_failure.rb +++ b/lib/puppet_forge/connection/connection_failure.rb @@ -22,4 +22,4 @@ def call(env) end end -Faraday::Middleware.register_middleware(:connection_failure => lambda { PuppetForge::Connection::ConnectionFailure }) +Faraday::Middleware.register_middleware(:connection_failure => PuppetForge::Connection::ConnectionFailure) diff --git a/puppet_forge.gemspec b/puppet_forge.gemspec index 5ff9e17..355fda8 100644 --- a/puppet_forge.gemspec +++ b/puppet_forge.gemspec @@ -18,10 +18,10 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.required_ruby_version = '>= 2.4.0' + spec.required_ruby_version = '>= 2.6.0' - spec.add_runtime_dependency "faraday", "~> 1.3" - spec.add_runtime_dependency "faraday_middleware", "~> 1.0" + spec.add_runtime_dependency "faraday", "~> 2.0" + spec.add_runtime_dependency "faraday-follow_redirects", "~> 0.3.0" spec.add_dependency "semantic_puppet", "~> 1.0" spec.add_dependency "minitar"