Skip to content

Commit

Permalink
ruby upgrade to 3.2.1 (#92)
Browse files Browse the repository at this point in the history
* Upgrade ruby to 3.2.1, bump nokogiri and rbtree

* fix YAML load syntax

* use CGI instead of URI for deprecated URI methods

* use register_scheme syntax instead of deprecated @@schemes for setting custom schemas

* update ruby version in git hub workflow

* Adding conditional version behaviour.

* Include ruby version in cache.

* Correct URI library version.

* Don't fail fast - check all versions.

* We don't currently run docs or rubocop.

---------

Co-authored-by: Sai Kumar Koptagiri <saikumarkotagiri9@gmail.com>
  • Loading branch information
TreyE and saikumar9 authored Aug 2, 2023
1 parent 3431b2a commit 62b5818
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Rubocop and Rspec
name: Rspec
on: push

jobs:
rspec:
strategy:
fail-fast: false
matrix:
ruby_version: ["2.7.5", "3.0.5", "3.1.4", "3.2.2"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -14,14 +18,14 @@ jobs:
sudo rabbitmqctl set_permissions -p event_source guest ".*" ".*" ".*"
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
ruby-version: ${{ matrix.ruby_version }}
- name: Cache Gems
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-event_source-gems-${{ hashFiles('**/Gemfile.lock') }}-${{ hashFiles('**/Gemfile' ) }}
key: ${{ runner.os }}-${{matrix.ruby_version}}-event_source-gems-${{ hashFiles('**/Gemfile.lock') }}-${{ hashFiles('**/Gemfile' ) }}
restore-keys: |
${{ runner.os }}-event_source-gems-${{ hashFiles('**/Gemfile.lock') }}-${{ hashFiles('**/Gemfile' ) }}
${{ runner.os }}-${{matrix.ruby_version}}-event_source-gems-${{ hashFiles('**/Gemfile.lock') }}-${{ hashFiles('**/Gemfile' ) }}
- name: bundle install
run: |
bundle config path vendor/bundle
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.6
3.2.1
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PATH
faraday_middleware (~> 1.0)
logging (~> 2.3.0)
mime-types
nokogiri (>= 1.12.5)
nokogiri (>= 1.13.0)
oj (~> 3.11)
ox (~> 2.14)
resque-bus (~> 0.7.0)
Expand Down Expand Up @@ -200,7 +200,7 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0901)
mini_mime (1.1.2)
mini_portile2 (2.6.1)
mini_portile2 (2.8.1)
minitest (5.14.4)
mongo (2.14.0)
bson (>= 4.8.2, < 5.0.0)
Expand All @@ -213,8 +213,8 @@ GEM
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.8)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
nokogiri (1.14.2)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
oj (3.13.9)
ox (2.14.5)
Expand All @@ -232,7 +232,7 @@ GEM
multi_json
redis
raabro (1.4.0)
racc (1.6.0)
racc (1.6.2)
rack (2.2.3)
rack-protection (2.1.0)
rack
Expand Down Expand Up @@ -266,7 +266,7 @@ GEM
thor (~> 1.0)
rainbow (3.0.0)
rake (13.0.6)
rbtree (0.4.4)
rbtree (0.4.6)
redis (4.5.1)
redis-namespace (1.8.1)
redis (>= 3.0.4)
Expand Down
2 changes: 1 addition & 1 deletion event_source.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'faraday', '~> 1.4.1'
spec.add_dependency 'faraday_middleware', '~> 1.0'
spec.add_dependency 'logging', '~> 2.3.0'
spec.add_dependency 'nokogiri', '>= 1.12.5'
spec.add_dependency 'nokogiri', '>= 1.13.0'
spec.add_dependency 'mime-types'
spec.add_dependency 'oj', '~> 3.11'
spec.add_dependency 'ox', '~> 2.14'
Expand Down
1 change: 1 addition & 0 deletions lib/event_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require 'active_support/all' # TODO: Remove ActiveSupport dependency

require 'event_source/version'
require 'event_source/ruby_versions'
require 'event_source/error'
require 'event_source/inflector'
require 'event_source/logging'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Operations
module AsyncApiConf
# load channel params from given file path
class LoadPath
send(:include, Dry::Monads[:result, :do, :try])
include Dry::Monads[:result, :do, :try]

def call(path:)
file_io = yield read(path)
Expand All @@ -27,7 +27,7 @@ def read(path)

def deserialize(file_io)
Try do
YAML.safe_load(file_io, [Symbol])
YAML.load(file_io)
end.to_result
end

Expand Down
2 changes: 1 addition & 1 deletion lib/event_source/protocols/amqp/bunny_connection_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def connection_credentials_from_server(server)
if URI(url)
amqp_url = URI.parse(url)
return {} unless amqp_url.userinfo
{ username: URI.unescape(amqp_url.user), password: URI.unescape(amqp_url.password) }
{ username: CGI.unescape(amqp_url.user), password: CGI.unescape(amqp_url.password) }
else
{}
end
Expand Down
14 changes: 14 additions & 0 deletions lib/event_source/ruby_versions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module EventSource
# Helper class to tell us under which ruby version we are operating.
class RubyVersions
CURRENT_VERSION = Gem::Version.new(RUBY_VERSION)

VERSION_THREE = Gem::Version.new("3.0.0")
VERSION_THREE_ONE = Gem::Version.new("3.1.0")

LESS_THAN_THREE = CURRENT_VERSION < VERSION_THREE
LESS_THAN_THREE_ONE = CURRENT_VERSION < VERSION_THREE_ONE
end
end
7 changes: 6 additions & 1 deletion lib/event_source/uris/amqp_uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ module URI
class AMQP < Generic
DEFAULT_PORT = 5672
end
@@schemes['AMQP'] = AMQP

if EventSource::RubyVersions::LESS_THAN_THREE_ONE
@@schemes['AMQP'] = AMQP
else
register_scheme 'AMQP', AMQP
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@

# rubocop:disable Lint/UriEscapeUnescape
let(:connection_url) do
"amqp://#{URI.escape(username)}:#{URI.escape(password)}@localhost:5672"
"amqp://#{CGI.escape(username)}:#{CGI.escape(password)}@localhost:5672"
end
# rubocop:enable Lint/UriEscapeUnescape

Expand Down

0 comments on commit 62b5818

Please sign in to comment.