From d5f6b70c059daf734be4b503706b7bcc597a6224 Mon Sep 17 00:00:00 2001 From: y-yagi Date: Fri, 31 May 2024 00:10:09 +0900 Subject: [PATCH] Fix broken CI (#390) * Rails edge requires Ruby version >= 3.1 Ref: https://github.com/rails/rails/pull/50491 * Fix Rubocop offences * Add `mutex_m`a and `base64` to dev dependencies `mutex_m` and `base64` are bundled gem since Ruby 3.4. Rails uses `mutex_m` and `base64` and newer versions add those as dependencies. Ref: https://github.com/rails/rails/pull/48907 But, old Rails aren't supported. So we need to add those gems to run CI. --- .github/workflows/ci.yml | 5 +++++ lib/lograge/formatters/graylog2.rb | 2 +- lib/lograge/formatters/key_value_deep.rb | 2 +- lib/lograge/formatters/l2met.rb | 2 +- lib/lograge/log_subscribers/base.rb | 2 +- lograge.gemspec | 4 +++- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2a091f9..9a7786a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,11 @@ jobs: gemfile: gemfiles/rails_7.1.gemfile - ruby: jruby-9.2 gemfile: gemfiles/rails_7.0.gemfile + # NOTE: Rails edge requires Ruby version >= 3.1 + - ruby: "2.7" + gemfile: gemfiles/rails_edge.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_edge.gemfile env: diff --git a/lib/lograge/formatters/graylog2.rb b/lib/lograge/formatters/graylog2.rb index 82a6a869..84f4d486 100644 --- a/lib/lograge/formatters/graylog2.rb +++ b/lib/lograge/formatters/graylog2.rb @@ -13,7 +13,7 @@ def call(data) end def underscore_prefix(key) - "_#{key}".to_sym + :"_#{key}" end def short_message(data) diff --git a/lib/lograge/formatters/key_value_deep.rb b/lib/lograge/formatters/key_value_deep.rb index bee43e25..704bcafd 100644 --- a/lib/lograge/formatters/key_value_deep.rb +++ b/lib/lograge/formatters/key_value_deep.rb @@ -4,7 +4,7 @@ module Lograge module Formatters class KeyValueDeep < KeyValue def call(data) - super flatten_keys(data) + super(flatten_keys(data)) end protected diff --git a/lib/lograge/formatters/l2met.rb b/lib/lograge/formatters/l2met.rb index b15d60ff..63c46f17 100644 --- a/lib/lograge/formatters/l2met.rb +++ b/lib/lograge/formatters/l2met.rb @@ -40,7 +40,7 @@ def additional_fields(data) def format(key, value) key = "measure#page.#{key}" if value.is_a?(Float) - super(key, value) + super end def modify_payload(data) diff --git a/lib/lograge/log_subscribers/base.rb b/lib/lograge/log_subscribers/base.rb index 46cc7a30..a9c26557 100644 --- a/lib/lograge/log_subscribers/base.rb +++ b/lib/lograge/log_subscribers/base.rb @@ -61,7 +61,7 @@ def get_error_status_code(exception_class_name) end def extract_allocations(event) - if (allocations = (event.respond_to?(:allocations) && event.allocations)) + if (allocations = event.respond_to?(:allocations) && event.allocations) { allocations: allocations } else {} diff --git a/lograge.gemspec b/lograge.gemspec index fe7ce53a..1cd24598 100644 --- a/lograge.gemspec +++ b/lograge.gemspec @@ -22,12 +22,14 @@ Gem::Specification.new do |s| s.files = `git ls-files lib LICENSE.txt`.split("\n") + s.add_development_dependency 'base64' + s.add_development_dependency 'mutex_m' s.add_development_dependency 'rspec', '~> 3.1' s.add_development_dependency 'rubocop', '~> 1.23' s.add_development_dependency 'simplecov', '~> 0.21' s.add_runtime_dependency 'actionpack', '>= 4' s.add_runtime_dependency 'activesupport', '>= 4' - s.add_runtime_dependency 'railties', '>= 4' + s.add_runtime_dependency 'railties', '>= 4' s.add_runtime_dependency 'request_store', '~> 1.0' end