Skip to content

Commit

Permalink
Test sentry-rails against Rails 8.0.0 (#2444)
Browse files Browse the repository at this point in the history
* Simplify ActiveJob specs setup

We don't need to use Sidekiq for ActiveJob specs, we can use Rails' default
adapters instead.

* Update sentry-rails' Gemfile conditions to support Rails 7.2

* Test against Rails 8.0 on CI

* Update Rails 8 related tests
  • Loading branch information
st0012 authored Oct 28, 2024
1 parent 9bba2ef commit e384446
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/sentry_rails_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
- { 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 }
- { ruby_version: "3.2", rails_version: "8.0.0.rc1" }
- { ruby_version: "3.3", rails_version: "8.0.0.rc1" }
- { ruby_version: "jruby", rails_version: 6.1.0 }
- {
ruby_version: "3.2",
Expand Down
46 changes: 24 additions & 22 deletions sentry-rails/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,49 @@ platform :jruby do
gem "jdbc-sqlite3"
end

ruby_version = Gem::Version.new(RUBY_VERSION)

rails_version = ENV["RAILS_VERSION"]
rails_version = "7.1.0" if rails_version.nil?
rails_version = "7.2.0" if rails_version.nil?
rails_version = Gem::Version.new(rails_version)

if rails_version < Gem::Version.new("6.0.0")
gem "sqlite3", "~> 1.3.0", platform: :ruby
else
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
gem "sqlite3", "~> 1.7.3", platform: :ruby
else
gem "sqlite3", "~> 1.6.9", platform: :ruby
end
end
gem "rails", "~> #{rails_version}"

if rails_version >= Gem::Version.new("8.0.0.alpha")
gem "rails", github: "rails/rails"
gem "rspec-rails"
gem "sqlite3", platform: :ruby
elsif rails_version >= Gem::Version.new("7.1.0")
gem "rails", "~> #{rails_version}"
gem "rspec-rails"
gem "sqlite3", "~> 1.7.3", platform: :ruby
elsif rails_version >= Gem::Version.new("6.1.0")
gem "rspec-rails", "~> 4.0"

if ruby_version >= Gem::Version.new("2.7.0")
gem "sqlite3", "~> 1.7.3", platform: :ruby
else
gem "sqlite3", "~> 1.6.9", platform: :ruby
end
else
gem "rspec-rails", "~> 4.0"
gem "rails", "~> #{rails_version}"
gem "psych", "~> 3.0.0"
end

gem "mini_magick"

gem "sprockets-rails"

gem "sidekiq"


ruby_version = Gem::Version.new(RUBY_VERSION)
if rails_version >= Gem::Version.new("6.0.0")
gem "sqlite3", "~> 1.4.0", platform: :ruby
else
gem "sqlite3", "~> 1.3.0", platform: :ruby
end
end

if ruby_version < Gem::Version.new("2.5.0")
# https://github.com/flavorjones/loofah/pull/267
# loofah changed the required ruby version in a patch so we need to explicitly pin it
gem "loofah", "2.20.0"
end

gem "mini_magick"

gem "sprockets-rails"

gem "benchmark-ips"
gem "benchmark_driver"
gem "benchmark-ipsa"
Expand Down
18 changes: 7 additions & 11 deletions sentry-rails/spec/sentry/rails/activejob_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,17 @@ def perform(event, hint)

context "when we are using an adapter which has a specific integration" do
before do
Sentry.configuration.rails.skippable_job_adapters = ["ActiveJob::QueueAdapters::SidekiqAdapter"]
Sentry.configuration.rails.skippable_job_adapters = ["ActiveJob::QueueAdapters::TestAdapter"]
end

it "does not trigger sentry and re-raises" do
begin
original_queue_adapter = FailedJob.queue_adapter
FailedJob.queue_adapter = :sidekiq
after do
Sentry.configuration.rails.skippable_job_adapters = []
end

expect { FailedJob.perform_now }.to raise_error(FailedJob::TestError)
it "does not trigger sentry and re-raises" do
expect { FailedJob.perform_now }.to raise_error(FailedJob::TestError)

expect(transport.events.size).to eq(0)
ensure
# this doesn't affect test result, but we shouldn't change it anyway
FailedJob.queue_adapter = original_queue_adapter
end
expect(transport.events.size).to eq(0)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@
expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(2)
expect(cache_transaction[:spans][1][:op]).to eq("cache.put")
expect(cache_transaction[:spans][1][:origin]).to eq("auto.cache.rails")
expect(cache_transaction[:spans].count).to eq(1)
expect(cache_transaction[:spans][0][:op]).to eq("cache.put")
expect(cache_transaction[:spans][0][:origin]).to eq("auto.cache.rails")
end

#
it "tracks cache decrement" do
skip("Tracks on Rails 8.0 for all Cache Stores; Until then only MemCached and Redis Stores.") if Rails.version.to_f < 8.0

Expand All @@ -67,9 +66,9 @@
expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(2)
expect(cache_transaction[:spans][1][:op]).to eq("cache.put")
expect(cache_transaction[:spans][1][:origin]).to eq("auto.cache.rails")
expect(cache_transaction[:spans].count).to eq(1)
expect(cache_transaction[:spans][0][:op]).to eq("cache.put")
expect(cache_transaction[:spans][0][:origin]).to eq("auto.cache.rails")
end

it "tracks cache read" do
Expand Down

0 comments on commit e384446

Please sign in to comment.