Skip to content

Commit

Permalink
Centralize Ruby Version to .ruby-version (#521)
Browse files Browse the repository at this point in the history
* Set .ruby-version to 3.2.2

* Remove ruby version definition in CI/CD
it will be read from .ruby-version

* Set required_ruby_version to >= 2.7.0

* Remove TargetRubyVersion in RuboCop config
reads from required_ruby_version in RuboCop 1.61+

* Autocorrect lint violations after updating to Rubocop 1.62.1
  • Loading branch information
jenshenny authored Apr 11, 2024
1 parent 012db60 commit fa197f6
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 23 deletions.
1 change: 0 additions & 1 deletion .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
-
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
-
name: Ruby Linting
Expand Down
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ inherit_gem:
rubocop-shopify: rubocop.yml

AllCops:
TargetRubyVersion: 2.7
NewCops: enable
Exclude:
- test/allow_list_bench.rb
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.2
30 changes: 17 additions & 13 deletions Gemfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/net_http/12_bulkhead_quotes_in_forks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
SEMIAN_PARAMETERS = {
bulkhead: true,
quota: 1, # Tickets calculated base on number of workers
timeout: 1, # Timeout in seconds (1 sec) to wait to get a free ticket.
timeout: 1, # Timeout in seconds (1 sec) to wait to get a free ticket.
circuit_breaker: false,
}

Expand Down
3 changes: 2 additions & 1 deletion lib/semian/mysql2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ def acquire_semian_resource(**)

def raw_semian_options
return query_options[:semian] if query_options.key?(:semian)
return query_options["semian"] if query_options.key?("semian")

query_options["semian"] if query_options.key?("semian")
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/semian/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def resource_exceptions

def raw_semian_options
return options[:semian] if options.key?(:semian)
return options["semian"] if options.key?("semian")

options["semian"] if options.key?("semian")
end

def raise_if_out_of_memory(reply)
Expand Down
2 changes: 2 additions & 0 deletions semian.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Gem::Specification.new do |s|
"source_code_uri" => "https://github.com/Shopify/semian",
}

s.required_ruby_version = ">= 2.7.0"

s.files = Dir["{lib,ext}/**/**/*.{rb,h,c}"]
s.files += ["LICENSE.md", "README.md"]
s.extensions = ["ext/semian/extconf.rb"]
Expand Down
2 changes: 1 addition & 1 deletion test/adapters/grpc_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TestGRPC < Minitest::Test
}

DEFAULT_SEMIAN_CONFIGURATION = proc do |host|
if host == SemianConfig["toxiproxy_upstream_host"] && \
if host == SemianConfig["toxiproxy_upstream_host"] &&
port == SemianConfig["toxiproxy_upstream_port"] # disable if toxiproxy
next nil
end
Expand Down
4 changes: 2 additions & 2 deletions test/adapters/net_http_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TestNetHTTP < Minitest::Test
error_timeout: 10,
}.freeze
DEFAULT_SEMIAN_CONFIGURATION = proc do |host, port|
if host == SemianConfig["toxiproxy_upstream_host"] && \
if host == SemianConfig["toxiproxy_upstream_host"] &&
port == SemianConfig["toxiproxy_upstream_port"] # disable if toxiproxy
next nil
end
Expand Down Expand Up @@ -311,7 +311,7 @@ def test_use_custom_configuration_to_combine_endpoints_into_one_resource
sample_env = "development"

semian_configuration_proc = proc do |host, port|
if host == SemianConfig["toxiproxy_upstream_host"] && \
if host == SemianConfig["toxiproxy_upstream_host"] &&
port == SemianConfig["toxiproxy_upstream_port"] # disable if toxiproxy
next nil
end
Expand Down
5 changes: 3 additions & 2 deletions test/adapters/redis_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,15 @@ def with_readonly_mode(client)
def new_config(**options)
options[:host] = SemianConfig["toxiproxy_upstream_host"] if options[:host].nil?
semian_options = SEMIAN_OPTIONS.merge(options.delete(:semian) || {})
RedisClient.config(**{
RedisClient.config(
port: SemianConfig["redis_toxiproxy_port"],
reconnect_attempts: 0,
db: 1,
timeout: REDIS_TIMEOUT,
semian: semian_options,
driver: redis_driver,
}.merge(options))
**options,
)
end

def connect_to_redis!(semian_options = {})
Expand Down

0 comments on commit fa197f6

Please sign in to comment.