From fbb7d020405d2e78f8b39edfdbaf79a884c96288 Mon Sep 17 00:00:00 2001 From: Adam McCrea Date: Sat, 12 Oct 2024 13:04:00 -0400 Subject: [PATCH 1/7] Temporarily restrict solid_queue version to get specs passing --- judoscale-solid_queue/judoscale-solid_queue.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/judoscale-solid_queue/judoscale-solid_queue.gemspec b/judoscale-solid_queue/judoscale-solid_queue.gemspec index 020fd1cc..34055eec 100644 --- a/judoscale-solid_queue/judoscale-solid_queue.gemspec +++ b/judoscale-solid_queue/judoscale-solid_queue.gemspec @@ -26,5 +26,5 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.7.0" spec.add_dependency "judoscale-ruby", Judoscale::VERSION - spec.add_dependency "solid_queue", ">= 0.3" + spec.add_dependency "solid_queue", ">= 0.3", "< 0.5" end From 064e97aa58b2287bab896e997361273c0fccf6c1 Mon Sep 17 00:00:00 2001 From: Adam McCrea Date: Sat, 12 Oct 2024 13:38:56 -0400 Subject: [PATCH 2/7] Move past the ActiveModel error New error in Solid Queue 0.8.1 seems related to how we setup our test DB. --- judoscale-solid_queue/judoscale-solid_queue.gemspec | 2 +- judoscale-solid_queue/lib/judoscale/solid_queue.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/judoscale-solid_queue/judoscale-solid_queue.gemspec b/judoscale-solid_queue/judoscale-solid_queue.gemspec index 34055eec..8e0fead3 100644 --- a/judoscale-solid_queue/judoscale-solid_queue.gemspec +++ b/judoscale-solid_queue/judoscale-solid_queue.gemspec @@ -26,5 +26,5 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.7.0" spec.add_dependency "judoscale-ruby", Judoscale::VERSION - spec.add_dependency "solid_queue", ">= 0.3", "< 0.5" + spec.add_dependency "solid_queue", "= 0.8.1" end diff --git a/judoscale-solid_queue/lib/judoscale/solid_queue.rb b/judoscale-solid_queue/lib/judoscale/solid_queue.rb index 7c84579d..461e430b 100644 --- a/judoscale-solid_queue/lib/judoscale/solid_queue.rb +++ b/judoscale-solid_queue/lib/judoscale/solid_queue.rb @@ -1,5 +1,8 @@ # frozen_string_literal: true +# Tests are failing with solid_queue 0.7.1+ unless we require active_model. +# Not sure why since solid_queue depends on activerecord which depends on activemodel. +require "active_model" require "solid_queue" require "judoscale-ruby" require "judoscale/config" From 734743544445cf68801dea7b7abd17b12bd04146 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 14 Oct 2024 11:18:00 -0300 Subject: [PATCH 3/7] Load entire SolidQueue schema file manually into our test DB SolidQueue v0.8+ merged all the migrations into a single schema file that is automatically loaded onto the DB on a Rails app. They suggest a separate DB, which AR will handle automatically by copying over this single file schema to the app, and to use on the same DB one would have to manually move the schema to a migration and execute it. For our case, all we care about is to have SolidQueue schema / tables loaded onto our test DB. We do that by manually loading the lib's schema file via Active Record. We still execute migrations afterwards, even though it's a no-op for current SolidQueue, if they need to make new schema changes in the future, they'll come in the form of migrations. --- judoscale-solid_queue/test/test_helper.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/judoscale-solid_queue/test/test_helper.rb b/judoscale-solid_queue/test/test_helper.rb index 06e4440e..70e07b02 100644 --- a/judoscale-solid_queue/test/test_helper.rb +++ b/judoscale-solid_queue/test/test_helper.rb @@ -41,10 +41,15 @@ class TestRailsApp < Rails::Application Minitest.after_run { ActiveRecord::Tasks::DatabaseTasks.drop(DATABASE_URL) } -ActiveRecord::Base.establish_connection(DATABASE_URL) +ActiveRecord::Base.configurations = {test: {url: DATABASE_URL}} +ActiveRecord::Base.establish_connection(:test) # Suppress migration noise. ENV["VERBOSE"] ||= "false" +# SolidQueue v0.8+ merged migrations into a single schema file, which we load directly into our test DB. +# Migrations are still executed afterwards, as they may add them in the future if schema changes are needed. +SCHEMA_FILE = SolidQueue::Engine.config.paths["lib"].paths.first.join("generators", "solid_queue", "install", "templates", "db", "queue_schema.rb") +ActiveRecord::Tasks::DatabaseTasks.load_schema_current(ActiveRecord.schema_format, SCHEMA_FILE) if SCHEMA_FILE.exist? # Add SolidQueue migration path to Active Record to migrate to the latest automatically. # It seems we can't only set it on `DatabaseTasks` as expected, need to set on the `Migrator` directly instead. ActiveRecord::Migrator.migrations_paths += SolidQueue::Engine.config.paths["db/migrate"].existent From 2fe65a7f5ea2a81956f074ff70a840ecac95c901 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 14 Oct 2024 11:51:51 -0300 Subject: [PATCH 4/7] Revert dependency check to continue support older versions --- judoscale-solid_queue/judoscale-solid_queue.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/judoscale-solid_queue/judoscale-solid_queue.gemspec b/judoscale-solid_queue/judoscale-solid_queue.gemspec index 8e0fead3..020fd1cc 100644 --- a/judoscale-solid_queue/judoscale-solid_queue.gemspec +++ b/judoscale-solid_queue/judoscale-solid_queue.gemspec @@ -26,5 +26,5 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.7.0" spec.add_dependency "judoscale-ruby", Judoscale::VERSION - spec.add_dependency "solid_queue", "= 0.8.1" + spec.add_dependency "solid_queue", ">= 0.3" end From 4ad806076418d3ee60d7fedb5210c23a8fceef9c Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 14 Oct 2024 11:56:22 -0300 Subject: [PATCH 5/7] Add Gemfile to test SolidQueue minimum version 0.3.x This way we can test both minimum and whatever "current/latest" is. (currently v1.0) --- .github/workflows/judoscale-solid_queue-test.yml | 1 + judoscale-solid_queue/Gemfile-solid_queue-0-3 | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 judoscale-solid_queue/Gemfile-solid_queue-0-3 diff --git a/.github/workflows/judoscale-solid_queue-test.yml b/.github/workflows/judoscale-solid_queue-test.yml index 97a7ef57..728c7808 100644 --- a/.github/workflows/judoscale-solid_queue-test.yml +++ b/.github/workflows/judoscale-solid_queue-test.yml @@ -14,6 +14,7 @@ jobs: matrix: gemfile: - Gemfile + - Gemfile-solid_queue-0-3 ruby: - "2.7" - "3.0" diff --git a/judoscale-solid_queue/Gemfile-solid_queue-0-3 b/judoscale-solid_queue/Gemfile-solid_queue-0-3 new file mode 100644 index 00000000..e0a6684b --- /dev/null +++ b/judoscale-solid_queue/Gemfile-solid_queue-0-3 @@ -0,0 +1,10 @@ +source "https://rubygems.org" + +gemspec name: "judoscale-solid_queue" + +gem "judoscale-ruby", path: "../judoscale-ruby" +gem "solid_queue", "~> 0.3.0" +gem "activerecord" +gem "pg" +gem "minitest" +gem "rake" From 7cb5114d112624d4f2df8fb09747cd58c22f13f1 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 14 Oct 2024 12:01:52 -0300 Subject: [PATCH 6/7] Add specific Gemfile for judoscale-rails against v7.1 Update GH matrix to skip unsupported Ruby versions on Rails 7.2 as well, (main Gemfile for now) since it requires Ruby 3.1+. --- .github/workflows/judoscale-rails-test.yml | 7 +++++++ judoscale-rails/Gemfile-rails-7-1 | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 judoscale-rails/Gemfile-rails-7-1 diff --git a/.github/workflows/judoscale-rails-test.yml b/.github/workflows/judoscale-rails-test.yml index 18e795bd..d087deb6 100644 --- a/.github/workflows/judoscale-rails-test.yml +++ b/.github/workflows/judoscale-rails-test.yml @@ -14,6 +14,7 @@ jobs: matrix: gemfile: - Gemfile + - Gemfile-rails-7-1 - Gemfile-rails-7-0 - Gemfile-rails-6-1 ruby: @@ -26,8 +27,14 @@ jobs: exclude: - gemfile: Gemfile ruby: "2.6" + - gemfile: Gemfile + ruby: "2.7" + - gemfile: Gemfile + ruby: "3.0" - gemfile: Gemfile-rails-7-0 ruby: "2.6" + - gemfile: Gemfile-rails-7-1 + ruby: "2.6" runs-on: ubuntu-latest env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps BUNDLE_GEMFILE: ${{ github.workspace }}/judoscale-rails/${{ matrix.gemfile }} diff --git a/judoscale-rails/Gemfile-rails-7-1 b/judoscale-rails/Gemfile-rails-7-1 new file mode 100644 index 00000000..bad1891c --- /dev/null +++ b/judoscale-rails/Gemfile-rails-7-1 @@ -0,0 +1,9 @@ +source "https://rubygems.org" + +gemspec name: "judoscale-rails" + +gem "judoscale-ruby", path: "../judoscale-ruby" +gem "railties", "~> 7.1" +gem "minitest" +gem "minitest-stub-const" +gem "rake" From 4569b0a7b3ad520f63135f45abf3ac9dc478f232 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 15 Oct 2024 14:00:38 -0300 Subject: [PATCH 7/7] Move explicit require of ActiveModel to the test helper We already have a few other requires that were needed there to get tests running, we can keep this new one there too, as it should not be a problem in runtime within a normal Rails environment. (and if it happens to be, we'll learn about it soon enough.) --- judoscale-solid_queue/lib/judoscale/solid_queue.rb | 3 --- judoscale-solid_queue/test/test_helper.rb | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/judoscale-solid_queue/lib/judoscale/solid_queue.rb b/judoscale-solid_queue/lib/judoscale/solid_queue.rb index 461e430b..7c84579d 100644 --- a/judoscale-solid_queue/lib/judoscale/solid_queue.rb +++ b/judoscale-solid_queue/lib/judoscale/solid_queue.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# Tests are failing with solid_queue 0.7.1+ unless we require active_model. -# Not sure why since solid_queue depends on activerecord which depends on activemodel. -require "active_model" require "solid_queue" require "judoscale-ruby" require "judoscale/config" diff --git a/judoscale-solid_queue/test/test_helper.rb b/judoscale-solid_queue/test/test_helper.rb index 70e07b02..58cfd485 100644 --- a/judoscale-solid_queue/test/test_helper.rb +++ b/judoscale-solid_queue/test/test_helper.rb @@ -9,6 +9,9 @@ # https://github.com/rails/solid_queue/commit/5ff6e0178bbe7c0cf93134ea2ef974c1dfc09a09 require "active_support" require "active_support/core_ext/numeric/time" +# It seems SolidQueue v0.7.1+ blows up without requiring activemodel. +# It should be a dependency for them through activerecord, but they may not be requiring it properly. +require "active_model" require "judoscale-solid_queue" require "minitest/autorun"