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

Support Rails 7.2 on CI #2382

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions .github/workflows/sentry_rails_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- { ruby_version: "2.7", rails_version: 5.2.0 }
- { ruby_version: "2.7", rails_version: 6.0.0 }
- { ruby_version: "2.7", rails_version: 6.1.0 }
- { ruby_version: "3.1", rails_version: 7.2.0 }
- { ruby_version: "3.2", rails_version: 7.2.0 }
- { ruby_version: "3.3", rails_version: 7.2.0 }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I know it's ultimately a business decision, but IMO we should drop support or at least stop running CI against Ruby 2.4, 2.5 and Rails 5.0 and 5.1.
Otherwise, with the release of Rails 8.0 in the near future, we'll be running so many jobs on CI for each PR.

Copy link
Member

Choose a reason for hiding this comment

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

I will prepare a major soon and remove, just need some time since I'm busy with another larger project

- { ruby_version: "jruby", rails_version: 6.1.0 }
- {
ruby_version: "3.2",
Expand Down
6 changes: 4 additions & 2 deletions sentry-rails/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ else
end
end

if rails_version >= Gem::Version.new("7.2.0.alpha")
if rails_version >= Gem::Version.new("8.0.0.alpha")
gem "rails", github: "rails/rails"
gem "rspec-rails"
elsif rails_version >= Gem::Version.new("7.1.0")
gem "rails", "~> #{rails_version}"
gem "rspec-rails"
else
gem "rspec-rails", "~> 4.0"
gem "rails", "~> #{rails_version}"
gem "psych", "~> 3.0.0"
end
Expand All @@ -39,7 +42,6 @@ gem "sprockets-rails"

gem "sidekiq"

gem "rspec-rails", "~> 4.0"

ruby_version = Gem::Version.new(RUBY_VERSION)

Expand Down
9 changes: 8 additions & 1 deletion sentry-rails/spec/dummy/test_rails_app/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

require 'sentry/rails'

ActiveSupport::Deprecation.silenced = true
ActiveSupport::Deprecation.silenced = true if ActiveSupport::Deprecation.respond_to?(:silenced)
ActiveRecord::Base.logger = Logger.new(nil)
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: "db")

Expand Down Expand Up @@ -57,6 +57,13 @@ def self.name
app.config.eager_load = true
app.config.active_job.queue_adapter = :test

# Eager load namespaces can be accumulated after repeated initializations and make initialization
# slower after each run
# This is especially obvious in Rails 7.2, because of https://github.com/rails/rails/pull/49987, but other constants's
# accumulation can also cause slowdown
# Because this is not necessary for the test, we can simply clear it here
app.config.eager_load_namespaces.clear

configure_app(app)

app.routes.append do
Expand Down
2 changes: 2 additions & 0 deletions sentry-rails/spec/isolated/active_job_activation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# for https://github.com/getsentry/sentry-ruby/issues/1249
require "active_job/railtie"
# Rails 7.2 added HealthCheckController, which requires ActionController
require "action_controller/railtie"
require "active_support/all"
require "sentry/rails"
require "minitest/autorun"
Expand Down
8 changes: 7 additions & 1 deletion sentry-rails/spec/sentry/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
require "rails/generators/test_case"
require "generators/sentry_generator"

behavior_module = if defined?(Rails::Generators::Testing::Behaviour)
Rails::Generators::Testing::Behaviour

Check warning on line 8 in sentry-rails/spec/sentry/generator_spec.rb

View check run for this annotation

Codecov / codecov/patch

sentry-rails/spec/sentry/generator_spec.rb#L8

Added line #L8 was not covered by tests
else
Rails::Generators::Testing::Behavior
end

RSpec.describe SentryGenerator do
include ::Rails::Generators::Testing::Behaviour
include behavior_module
include FileUtils
self.destination File.expand_path('../../tmp', __dir__)
self.generator_class = described_class
Expand Down
14 changes: 11 additions & 3 deletions sentry-rails/spec/sentry/rails/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
Sentry.get_current_client.transport
end

let(:expected_initial_active_record_connections_count) do
if Gem::Version.new(Rails.version) < Gem::Version.new('7.2.0')
1
else
0

Check warning on line 12 in sentry-rails/spec/sentry/rails/client_spec.rb

View check run for this annotation

Codecov / codecov/patch

sentry-rails/spec/sentry/rails/client_spec.rb#L12

Added line #L12 was not covered by tests
end
end

before do
expect(ActiveRecord::Base.connection_pool.stat[:busy]).to eq(1)
expect(ActiveRecord::Base.connection_pool.stat[:busy]).to eq(expected_initial_active_record_connections_count)
end

def send_events
Expand Down Expand Up @@ -35,7 +43,7 @@

expect(transport.events.count).to eq(5)

expect(ActiveRecord::Base.connection_pool.stat[:busy]).to eq(1)
expect(ActiveRecord::Base.connection_pool.stat[:busy]).to eq(expected_initial_active_record_connections_count)
end
end

Expand All @@ -53,7 +61,7 @@

expect(transport.events.count).to eq(5)

expect(ActiveRecord::Base.connection_pool.stat[:busy]).to eq(1)
expect(ActiveRecord::Base.connection_pool.stat[:busy]).to eq(expected_initial_active_record_connections_count)
end
end
end
Loading