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

CI: Use same Ruby version matrix as Ruby, repair for Faraday 1.0 #228

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
language: ruby
sudo: false

rvm:
- 2.7
- 2.6
- 2.5
- 2.4
- 2.3
- 2.2
- 2.1
- jruby-9.1.7.0

env:
global:
- PARSE_HOST=https://parse-ruby-client-server.herokuapp.com
Expand Down
10 changes: 6 additions & 4 deletions lib/faraday/better_retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ def initialize(app, options = nil)
super(app, options)

# NOTE: Faraday 0.9.1 by default does not retry on POST requests
@options.methods << :post
@options.methods = @options.methods + [:post]
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Could use += but it's not objectively better or anything :)


# NOTE: the default exceptions are lost when custom ones are given
default_exceptions = [
Errno::ETIMEDOUT, 'Timeout::Error', Error::TimeoutError]
Errno::ETIMEDOUT, 'Timeout::Error', TimeoutError]
@options.exceptions.concat(default_exceptions)
end

Expand All @@ -33,8 +33,10 @@ def call(env)
log(env, exception)
retries -= 1
retries_header(env, retries)
sleep sleep_amount(retries + 1)
retry
if (sleep_amount = calculate_sleep_amount(retries + 1, env))
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is calculate_sleep_amount defined? Don't see it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's in the Faraday codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps it's better to do a full replace of the retry middleware - than to patch this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, of course.

sleep sleep_amount
retry
end
end
raise
end
Expand Down
8 changes: 4 additions & 4 deletions lib/parse/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module Parse
# The client that communicates with the Parse server via REST
class Client
RETRIED_EXCEPTIONS = [
'Faraday::Error::TimeoutError',
'Faraday::Error::ParsingError',
'Faraday::Error::ConnectionFailed',
'Faraday::TimeoutError',
'Faraday::ParsingError',
'Faraday::ConnectionFailed',
'Parse::ParseProtocolRetry'
]

Expand Down Expand Up @@ -104,7 +104,7 @@ def request(uri, method = :get, body = nil, query = nil, content_type = nil)

# NOTE: Don't leak our internal libraries to our clients.
# Extend this list of exceptions as needed.
rescue Faraday::Error::ClientError => e
rescue Faraday::ClientError, Faraday::ConnectionFailed => e
raise Parse::ConnectionError, e.message
end

Expand Down
6 changes: 1 addition & 5 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# mocha + minitest
require 'minitest/unit'
require 'mocha/mini_test'
require 'mocha/minitest'

require 'vcr'

Expand All @@ -40,10 +40,6 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'parse-ruby-client'

if RUBY_VERSION[0..2] < '2.2'
YAML::ENGINE.yamler = 'syck' # get ascii strings as strings in fixtures
end

VCR.configure do |c|
c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
c.default_cassette_options = { record: :once }
Expand Down
4 changes: 2 additions & 2 deletions test/middleware/better_retry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def conn(retry_options = {})
default_options = {
logger: @logger,
exceptions: [
'Faraday::Error::TimeoutError',
'Faraday::Error::ParsingError',
'Faraday::TimeoutError',
'Faraday::ParsingError',
'Parse::ParseProtocolRetry'
]
}
Expand Down
2 changes: 1 addition & 1 deletion test/middleware/extend_parse_json_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def conn(_retry_options = {})
end

def test_invalid_json
assert_raises(Faraday::Error::ParsingError) { conn.get('/invalid_json') }
assert_raises(Faraday::ParsingError) { conn.get('/invalid_json') }
end

def test_valid_json
Expand Down
2 changes: 1 addition & 1 deletion test/test_client_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_wraps_connection_errors
VCR.use_cassette('test_client_wraps_connection_errors') do
_stubs, client = stubbed_client do |stub|
stub.get(stub_path) do
raise Faraday::Error::ConnectionFailed, 'message'
raise Faraday::ConnectionFailed, 'message'
end
end

Expand Down