From e95ed111fc9d7d8445c25ef97b24282beb9e2afe Mon Sep 17 00:00:00 2001 From: Mattia Giuffrida Date: Mon, 23 Sep 2024 10:52:24 +0100 Subject: [PATCH 1/2] Don't register the request/response json middleware for Faraday 1.10+ Faraday 1.10 ships with an out-of-the-box JSON middleware, so we want to to default to that one rather than the faraday_middleware one. --- lib/faraday_middleware.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/faraday_middleware.rb b/lib/faraday_middleware.rb index 4cf0a80e..dd4d68b1 100644 --- a/lib/faraday_middleware.rb +++ b/lib/faraday_middleware.rb @@ -27,13 +27,11 @@ module FaradayMiddleware Faraday::Request.register_middleware \ oauth: -> { OAuth }, oauth2: -> { OAuth2 }, - json: -> { EncodeJson }, method_override: -> { MethodOverride } Faraday::Response.register_middleware \ mashify: -> { Mashify }, rashify: -> { Rashify }, - json: -> { ParseJson }, json_fix: -> { ParseJson::MimeTypeFix }, xml: -> { ParseXml }, marshal: -> { ParseMarshal }, @@ -46,6 +44,13 @@ module FaradayMiddleware Faraday::Middleware.register_middleware \ instrumentation: -> { Instrumentation }, gzip: -> { Gzip } + + # The request/reponse JSON middleware is included in Faraday since + # version 1.10.0, so we only register the middleware if it's not already. + if Gem::Version.new(Faraday::VERSION) < Gem::Version.new('1.10.0') + Faraday::Request.register_middleware(json: -> { EncodeJson }) + Faraday::Response.register_middleware(json: -> { ParseJson }) + end end end From f6d9b7444131988a7ad905488dba8b52e1b69d04 Mon Sep 17 00:00:00 2001 From: Mattia Giuffrida Date: Mon, 23 Sep 2024 10:57:43 +0100 Subject: [PATCH 2/2] Update CI --- .github/workflows/ci.yml | 24 ++++++++++++++---------- .github/workflows/publish.yml | 6 +++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5b50155..f3512f47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,16 +16,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Ruby 2.6 + - name: Set up Ruby 2.7 uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6 + ruby-version: 2.7 - name: Rubocop run: | - gem install bundler + gem install bundler -v 2.4.22 bundle config set without 'development test' bundle config set with 'lint' bundle install @@ -41,16 +41,20 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2'] + ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - - name: Install system dependencies - run: sudo apt install libcurl4-openssl-dev - - name: Install Ruby dependencies - run: bundle install --jobs 4 --retry 3 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install libcurl4-openssl-dev + - name: Build + run: | + gem install bundler -v 2.4.22 + bundle install --jobs 4 --retry 3 - name: Test run: bundle exec rake diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1d82021f..5383eca6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,12 +10,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Ruby 2.6 + - name: Set up Ruby 2.7 uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6.x + ruby-version: 2.7 - name: Publish to RubyGems run: |