From 6fc3a2414f1c2a99bc13a04d5273693efbd02e6e Mon Sep 17 00:00:00 2001 From: Alexey Zapparov Date: Thu, 26 Jun 2025 11:35:46 +0200 Subject: [PATCH 1/6] ci: Rails 7.2, 8.0; Ruby 3.4 * Add Ruby 3.4 to the CI matrix * Add Rail 7.2 to the CI matrix * Add Rail 8.0 to the CI matrix Based on 9b272274c304d03083fdb72040b693d29c7da21a Co-Authored-By: ohbarye --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++-- .gitignore | 1 + README.md | 4 ++-- gemfiles/rails_7.2.gemfile | 19 +++++++++++++++++++ gemfiles/rails_8.0.gemfile | 19 +++++++++++++++++++ 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 gemfiles/rails_7.2.gemfile create mode 100644 gemfiles/rails_8.0.gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e11aa630..cc18dc37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: - "3.1" - "3.2" - "3.3" + - "3.4" # JRuby - jruby-9.3 @@ -31,7 +32,9 @@ jobs: gemfile: - Gemfile - - gemfiles/rails_edge.gemfile # 7.2.0.alpha + - gemfiles/rails_edge.gemfile # 8.1 + - gemfiles/rails_8.0.gemfile + - gemfiles/rails_7.2.gemfile - gemfiles/rails_7.1.gemfile - gemfiles/rails_7.0.gemfile - gemfiles/rails_6.1.gemfile @@ -51,21 +54,47 @@ jobs: # NOTE(ivy): Rails 7 requires Ruby version >= 2.7 - ruby: jruby-9.3 gemfile: gemfiles/rails_edge.gemfile + - ruby: jruby-9.3 + gemfile: gemfiles/rails_7.2.gemfile - ruby: jruby-9.3 gemfile: gemfiles/rails_7.1.gemfile - ruby: jruby-9.3 gemfile: gemfiles/rails_7.0.gemfile - ruby: jruby-9.2 gemfile: gemfiles/rails_edge.gemfile + - ruby: jruby-9.2 + gemfile: gemfiles/rails_7.2.gemfile - ruby: jruby-9.2 gemfile: gemfiles/rails_7.1.gemfile - ruby: jruby-9.2 gemfile: gemfiles/rails_7.0.gemfile - # NOTE: Rails edge requires Ruby version >= 3.1 + # NOTE: Rails 7.2 requires Ruby version >= 3.1 + - ruby: "2.7" + gemfile: gemfiles/rails_7.2.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_7.2.gemfile + # NOTE: Rails 8.0 edge requires Ruby version >= 3.2 + - ruby: "2.7" + gemfile: gemfiles/rails_8.0.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_8.0.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_8.0.gemfile + - ruby: jruby-9.3 + gemfile: gemfiles/rails_8.0.gemfile + - ruby: jruby-9.4 + gemfile: gemfiles/rails_8.0.gemfile + # NOTE: Rails edge requires Ruby version >= 3.2 - ruby: "2.7" gemfile: gemfiles/rails_edge.gemfile - ruby: "3.0" gemfile: gemfiles/rails_edge.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_edge.gemfile + - ruby: jruby-9.3 + gemfile: gemfiles/rails_edge.gemfile + - ruby: jruby-9.4 + gemfile: gemfiles/rails_edge.gemfile env: diff --git a/.gitignore b/.gitignore index 58f437c2..a4687217 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ Gemfile.lock coverage gemfiles/*.lock +gemfiles/vendor pkg/* vendor/bundle \ No newline at end of file diff --git a/README.md b/README.md index 1e6d4289..1d368793 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,9 @@ default, instead it assumes you use a proper log formatter instead. Lograge is actively tested against current and officially supported Ruby and Rails releases. That said, Lograge _should_ work with older releases. -- [Rails](https://endoflife.date/rails): Edge, 7.1, 7.0, 6.1, 6.0, 5.2 +- [Rails](https://endoflife.date/rails): Edge, 8.0, 7.2, 7.1, 7.0, 6.1, 6.0, 5.2 - Rubies: - - [MRI](https://endoflife.date/ruby): HEAD, 3.3, 3.2 3.1, 3.0, 2.7, 2.6 + - [MRI](https://endoflife.date/ruby): HEAD, 3.4, 3.3, 3.2 3.1, 3.0, 2.7, 2.6 - JRuby: HEAD, 9.2, 9.1 - TruffleRuby: HEAD, 21.3 diff --git a/gemfiles/rails_7.2.gemfile b/gemfiles/rails_7.2.gemfile new file mode 100644 index 00000000..a451a5c4 --- /dev/null +++ b/gemfiles/rails_7.2.gemfile @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +# Specify your gem's dependencies in lograge.gemspec +gemspec path: '..' + +group :test do + gem 'actionpack', '~> 7.2.0' + gem 'activerecord', '~> 7.2.0' + # logstash does not release any gems on rubygems, but they have two gemspecs within their repo. + # Using the tag is an attempt of having a stable version to test against where we can ensure that + # we test against the correct code. + gem 'logstash-event', git: 'https://github.com/elastic/logstash', tag: 'v1.5.4' + # logstash 1.5.4 is only supported with jrjackson up to 0.2.9 + gem 'jrjackson', '~> 0.2.9', platforms: :jruby + gem 'lines' + gem 'thread_safe' +end diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile new file mode 100644 index 00000000..63d64639 --- /dev/null +++ b/gemfiles/rails_8.0.gemfile @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +# Specify your gem's dependencies in lograge.gemspec +gemspec path: '..' + +group :test do + gem 'actionpack', '~> 8.0.0' + gem 'activerecord', '~> 8.0.0' + # logstash does not release any gems on rubygems, but they have two gemspecs within their repo. + # Using the tag is an attempt of having a stable version to test against where we can ensure that + # we test against the correct code. + gem 'logstash-event', git: 'https://github.com/elastic/logstash', tag: 'v1.5.4' + # logstash 1.5.4 is only supported with jrjackson up to 0.2.9 + gem 'jrjackson', '~> 0.2.9', platforms: :jruby + gem 'lines' + gem 'thread_safe' +end From b4c794ddb8f841a6c9475db85d2ee0f9ecb09fcf Mon Sep 17 00:00:00 2001 From: Alexey Zapparov Date: Fri, 27 Jun 2025 16:46:28 +0200 Subject: [PATCH 2/6] ci: Require stdlib Logger --- lib/lograge.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/lograge.rb b/lib/lograge.rb index 7ac247ac..7e31653a 100644 --- a/lib/lograge.rb +++ b/lib/lograge.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'logger' require 'lograge/version' require 'lograge/formatters/helpers/method_and_path' require 'lograge/formatters/cee' From 932953ddef5e52e14af64c52f8c8d64568e0214c Mon Sep 17 00:00:00 2001 From: Alexey Zapparov Date: Fri, 27 Jun 2025 17:04:42 +0200 Subject: [PATCH 3/6] ci: Fix Ruby-3.4 failures due to change in #inspect > chruby ruby-3.4 > ruby -e 'puts({ a: 42, "b" => 161 }.inspect)' {a: 42, "b" => 161} > chruby ruby-3.3 > ruby -e 'puts({ a: 42, "b" => 161 }.inspect)' {:a=>42, "b"=>161} > chruby ruby-3.2 > ruby -e 'puts({ a: 42, "b" => 161 }.inspect)' {:a=>42, "b"=>161} See: https://github.com/httprb/http/pull/808#discussion_r2160347585 --- spec/log_subscribers/action_cable_spec.rb | 6 +++--- spec/log_subscribers/action_controller_spec.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/log_subscribers/action_cable_spec.rb b/spec/log_subscribers/action_cable_spec.rb index c1a6c631..0dfa3856 100644 --- a/spec/log_subscribers/action_cable_spec.rb +++ b/spec/log_subscribers/action_cable_spec.rb @@ -33,20 +33,20 @@ context 'with custom_options configured for cee output' do before do - Lograge.formatter = ->(data) { "My test: #{data}" } + Lograge.formatter = ->(data) { "My test: #{data.to_json}" } end it 'combines the hash properly for the output' do Lograge.custom_options = { data: 'value' } subscriber.perform_action(event) - expect(log_output.string).to match(/^My test: {.*:data=>"value"/) + expect(log_output.string).to match(/^My test: {.*"data"\s*:\s*"value"/) end it 'combines the output of a lambda properly' do Lograge.custom_options = ->(_event) { { data: 'value' } } subscriber.perform_action(event) - expect(log_output.string).to match(/^My test: {.*:data=>"value"/) + expect(log_output.string).to match(/^My test: {.*"data"\s*:\s*"value"/) end it 'works when the method returns nil' do diff --git a/spec/log_subscribers/action_controller_spec.rb b/spec/log_subscribers/action_controller_spec.rb index f272fad5..35e60ec5 100644 --- a/spec/log_subscribers/action_controller_spec.rb +++ b/spec/log_subscribers/action_controller_spec.rb @@ -39,20 +39,20 @@ context 'with custom_options configured for cee output' do before do - Lograge.formatter = ->(data) { "My test: #{data}" } + Lograge.formatter = ->(data) { "My test: #{data.to_json}" } end it 'combines the hash properly for the output' do Lograge.custom_options = { data: 'value' } subscriber.process_action(event) - expect(log_output.string).to match(/^My test: {.*:data=>"value"/) + expect(log_output.string).to match(/^My test: {.*"data"\s*:\s*"value"/) end it 'combines the output of a lambda properly' do Lograge.custom_options = ->(_event) { { data: 'value' } } subscriber.process_action(event) - expect(log_output.string).to match(/^My test: {.*:data=>"value"/) + expect(log_output.string).to match(/^My test: {.*"data"\s*:\s*"value"/) end it 'works when the method returns nil' do From beecf7e71766909884073c09badf0ffe2e9c2a51 Mon Sep 17 00:00:00 2001 From: Alexey Zapparov Date: Fri, 27 Jun 2025 17:08:45 +0200 Subject: [PATCH 4/6] ci(gemspec): Replace add_runtime_dependency with add_dependency See: https://github.com/rubygems/rubygems/issues/7799 --- lograge.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lograge.gemspec b/lograge.gemspec index 1cd24598..bb476dec 100644 --- a/lograge.gemspec +++ b/lograge.gemspec @@ -28,8 +28,8 @@ Gem::Specification.new do |s| 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 'request_store', '~> 1.0' + s.add_dependency 'actionpack', '>= 4' + s.add_dependency 'activesupport', '>= 4' + s.add_dependency 'railties', '>= 4' + s.add_dependency 'request_store', '~> 1.0' end From 2f691a62d93fe8580e5421106258c499ae1e7f99 Mon Sep 17 00:00:00 2001 From: Alexey Zapparov Date: Fri, 27 Jun 2025 17:15:39 +0200 Subject: [PATCH 5/6] ci: Add explicit logger dependency for ruby-head --- Gemfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 85c26f57..b4e778a3 100644 --- a/Gemfile +++ b/Gemfile @@ -18,4 +18,8 @@ group :test do gem 'jrjackson', '~> 0.2.9', platforms: :jruby gem 'lines' gem 'thread_safe' + + # Since Ruby-3.4 vendored stdlib logger warns that it will be removed + # Since Ruby-3.5 logger is extracted into a standalone gem + gem 'logger' end From 7d13492694377fd59d2425ee185219f830bd5fda Mon Sep 17 00:00:00 2001 From: Alexey Zapparov Date: Fri, 27 Jun 2025 17:21:34 +0200 Subject: [PATCH 6/6] ci: Exclude rails-8.X + truffleruby --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc18dc37..00046e6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,6 +84,8 @@ jobs: gemfile: gemfiles/rails_8.0.gemfile - ruby: jruby-9.4 gemfile: gemfiles/rails_8.0.gemfile + - ruby: truffleruby-23.0 + gemfile: gemfiles/rails_8.0.gemfile # NOTE: Rails edge requires Ruby version >= 3.2 - ruby: "2.7" gemfile: gemfiles/rails_edge.gemfile @@ -95,6 +97,8 @@ jobs: gemfile: gemfiles/rails_edge.gemfile - ruby: jruby-9.4 gemfile: gemfiles/rails_edge.gemfile + - ruby: truffleruby-23.0 + gemfile: gemfiles/rails_edge.gemfile env: