Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support both faraday 1.x and 2.x #618

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

DocX
Copy link
Contributor

@DocX DocX commented Jun 21, 2023

  • Remove specific version dependency for faraday from gemfile. This allows users to use any version in their application.
  • Update code to support both 1.x and 2.x versions - there is one small difference in use of auth middleware (see docs)
  • Use faraday-follow_redirects gem that is compatible with 1.x and 2.x as well - instead of deprecated faraday_middleware gem
  • Added CI groups for each faraday 1 and faraday 2 Gemfiles
  • Added mention to CHANGELOG

@DocX DocX force-pushed the support-faraday-2 branch 3 times, most recently from 1d74e8a to 6803e3a Compare June 22, 2023 08:23
@DocX
Copy link
Contributor Author

DocX commented Jun 22, 2023

cc @cben please review when you get time

@cben
Copy link
Collaborator

cben commented Jun 25, 2023

Looks great, just some questions on the version range, should it really be "any version"

@cben
Copy link
Collaborator

cben commented Jun 25, 2023

ref: https://lostisland.github.io/faraday/middleware/authentication documents both v2 and v1 APIs used here ✔️

@DocX
Copy link
Contributor Author

DocX commented Jun 26, 2023

should it really be "any version"

good point, I've added condition for >= 1 and < 3 - so that matches 1.x and 2.x.

@DocX DocX force-pushed the support-faraday-2 branch from 6803e3a to f6d7628 Compare June 26, 2023 08:57
@DocX
Copy link
Contributor Author

DocX commented Jun 28, 2023

cc @cben I've fixed the faraday version range

@@ -15,6 +15,7 @@ jobs:
strategy:
matrix:
ruby: [ '2.7', '3.0', '3.1', '3.2', 'ruby-head', 'truffleruby-head' ]
gemfile: ["test/gemfiles/Gemfile.faraday-1", "test/gemfiles/Gemfile.faraday-2"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍
This approach won't scale to many libraries, but for now it's OK and addresses a real concern that people making changes won't realize they need to to test both versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could separate it to its own single test to test the Faraday 1 with just one specific ruby version. And use Faraday 2 in the all ruby versions test. I think ruby version should not influence the faraday behaviour, and it is more orthogonal test to testing all ruby versions as well.

@@ -32,8 +32,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'net-smtp'
spec.add_development_dependency 'forking_test_runner'

spec.add_dependency 'faraday', '~> 1.1'
spec.add_dependency 'faraday_middleware', '~> 1.0'
spec.add_dependency 'faraday'
Copy link
Collaborator

@cben cben Jun 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Oops, this were the "some questions" I thought I sent but left "Pending" 🤦‍♂️
Good thing you inferred my meaning anyway 👍 LGTM now]

  • Should we keep >= 1.1 constraint? I don't remember/see any record why Replace rest_client with faraday #466 started from 1.1 in the first place, probably it was simply the latest version then?
    I don't see obviously-critical things in faraday changelog but at this point it's imho safer to keep it (if anybody really needs a faraday older then 1.1, the onus should be on them to test and make a PR).

  • Should this add a < 3.0 constraint, as we're only testing 1.y & 2.y and can't know what future breaking changes 3.0 may bring?

@cben cben merged commit ab42294 into ManageIQ:master Jun 30, 2023
@DocX DocX deleted the support-faraday-2 branch July 3, 2023 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants