From ebbbab5c2eb4346dc2453967655f9bdd594ac8af Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Sat, 28 Nov 2020 00:24:02 -0800 Subject: [PATCH 1/3] test against ruby head (#1208) * CI: add "head" Ruby to matrix * Gemfile: Allow Ruby 3 to use net-http-client 4.x * Gemfile: Select net-http-persistent 4 differently Check for Ruby version 3+ * Gemfile: doc net-http-persistent has no gemspec * redo Co-authored-by: Olle Jonsson Co-authored-by: Olle Jonsson --- .github/workflows/ci.yml | 12 ++++++++---- Gemfile | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8776fa1f0..d0294cba6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,9 +39,15 @@ jobs: build: needs: [linting] runs-on: ubuntu-latest + name: build ${{ matrix.ruby }} strategy: + fail-fast: false matrix: ruby: ['2.4', '2.5', '2.6', '2.7'] + experimental: [false] + include: + - ruby: head + experimental: true steps: - uses: actions/checkout@v1 @@ -49,12 +55,10 @@ jobs: with: ruby-version: ${{ matrix.ruby }} - - name: Install dependencies run: | sudo apt-get install libcurl4-openssl-dev - - name: Build run: | sudo apt-get install libcurl4-openssl-dev @@ -62,6 +66,6 @@ jobs: bundle install --jobs 4 --retry 3 - name: Test - run: | - bundle exec rake + continue-on-error: ${{ matrix.experimental }} + run: bundle exec rake diff --git a/Gemfile b/Gemfile index 8c6f3b4ac..5bc51036b 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,9 @@ group :test, :development do gem 'excon', '>= 0.27.4' gem 'httpclient', '>= 2.2' gem 'multipart-parser' - gem 'net-http-persistent', '~> 3.0' + # TODO: remove this once v4 is released + options = (RUBY_VERSION.start_with?('3') ? { github: 'grosser/net-http-persistent', branch: 'grosser/spec' } : {}) + gem 'net-http-persistent', (RUBY_VERSION.start_with?('3') ? '>= 3.0' : '~> 3.0'), **options gem 'patron', '>= 0.4.2', platforms: :ruby gem 'rack-test', '>= 0.6', require: 'rack/test' gem 'rspec', '~> 3.7' From 47411d815483531648171f6317c300bdde040673 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Tue, 1 Dec 2020 10:21:42 +0100 Subject: [PATCH 2/3] EmHttp adapter: drop superfluous loaded? check (#1213) We are loaded in this section. --- lib/faraday/adapter/em_http.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/faraday/adapter/em_http.rb b/lib/faraday/adapter/em_http.rb index c7dd73876..4d30b375c 100644 --- a/lib/faraday/adapter/em_http.rb +++ b/lib/faraday/adapter/em_http.rb @@ -93,17 +93,15 @@ def request_options(env) dependency do require 'em-http' - if Faraday::Adapter::EMHttp.loaded? - begin - require 'openssl' - rescue LoadError - warn 'Warning: no such file to load -- openssl. ' \ - 'Make sure it is installed if you want HTTPS support' - else - require 'em-http/version' - if EventMachine::HttpRequest::VERSION < '1.1.6' - require 'faraday/adapter/em_http_ssl_patch' - end + begin + require 'openssl' + rescue LoadError + warn 'Warning: no such file to load -- openssl. ' \ + 'Make sure it is installed if you want HTTPS support' + else + require 'em-http/version' + if EventMachine::HttpRequest::VERSION < '1.1.6' + require 'faraday/adapter/em_http_ssl_patch' end end end From e111db34c369b6ff3ae2a58315fb617933885687 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Tue, 1 Dec 2020 22:06:38 -0800 Subject: [PATCH 3/3] Avoid 1 use of keyword hackery (#1211) --- lib/faraday/dependency_loader.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/faraday/dependency_loader.rb b/lib/faraday/dependency_loader.rb index 3f1708f8c..57345646d 100644 --- a/lib/faraday/dependency_loader.rb +++ b/lib/faraday/dependency_loader.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'ruby2_keywords' - module Faraday # DependencyLoader helps Faraday adapters and middleware load dependencies. module DependencyLoader @@ -15,7 +13,7 @@ def dependency(lib = nil) self.load_error = e end - ruby2_keywords def new(*) + def new(*) unless loaded? raise "missing dependency for #{self}: #{load_error.message}" end