Skip to content

Commit

Permalink
chore: Test matrix & sample app dependency updates & cleanup (#197)
Browse files Browse the repository at this point in the history
* Bundle update all sample apps, make sure they are all running/working

* Expand Ruby support via test coverage

* Test against Rails / DH / GJ / Que against Active Record v7.0

The main Gemfile points to AR latest, which is currently v7.1, and we
have tests against v6.1, this adds testing for the intermediate v7.0 as
well to make sure we cover all those versions.

* Run tests for against Sidekiq v6

The main Gemfile is testing Sidekiq v7, we have a separate Gemfile for
v5, this adds v6 as well.

* Update to the latest checkout action

This fixes action warnings in GH about old node versions used by the
checkout@v2. The latest v4 is using node20 and should eliminate all
those warnings.

    The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2.
    For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/

    Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v2.
    For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

* Copy over full GoodJob migration to silence warnings

GoodJob was complaining that some migrations needed to be executed,
apparently because we were only creating the main `good_jobs` table and
associated indexes.

That table has now a few more columns and there's a few other tables, to
keep it simple I copied over the full thing, which makes it easier to
update again in the future as well.

I also updated the DelayedJob migration with the index creation that was
missing, just to keep it a full raw copy of the migration similar to
GoodJob.

* Supress migration messages from DJ/GJ

Make the test output less noisy without those migration messages,
specially now that GJ is larger with all the tables/indexes.

* Skip Ruby 3.2+ and AR 6.1 tests on Good Job

We're getting an error due to Ruby 3.2+ and kwargs apparently, some
Rails 6.1 incompatibility with latest Ruby versions.

    ArgumentError: wrong number of arguments (given 1, expected 0)
        test/metrics_collector_test.rb:57:in `block (3 levels) in <module:Judoscale>'

Rails has fixed most of those on 6-1-stable branch, but no stable release
is planned any time soon (that branch is receiving security fixes only),
so let's just skip instead of running everything against the branch for
simplicity, since we're running our tests on other versions and it's a
known Rails 6-1 issue.

* Test against Que v1.x

The main Gemfile on judoscale-que will install the latest Que version,
which means it should be covering v2.x, so the secondary que-2 Gemfile
was likely testing a similar version.

We need a separate Gemfile that enforces installation of Que v1.x in
order to test it against judoscale-que. v1.x doesn't support Ruby 3+
though, so we only test it against Ruby 2.x and the related Active
Record versions that support the same Ruby.

* Switch database names on sample apps / test dbs back to judoscale_*

* Update some Rails Autoscale instances to Judoscale

Some comments / tests / sample apps copy were referencing Rails
Autoscale from a previous renaming, update those to Judoscale to match
the code / libs across the board.

Rails Autoscale is supported alongside Judoscale, but we're referencing
things as Judoscale.

* Switch sample apps to use request catcher

The previous request inspector endpoint seems to have expired and we'd
have to generate a new one, and request catcher seems to be working as
before, so switching it back for simplicity since we can just hit
whatever subdomain there and it shows up.

* Document the new/correct port that changed with heroku local

* Remove invalid references for application stylesheets

These apps have no styles, so no such file exists. This was turning into
a 404 request shown in the logs.
  • Loading branch information
carlosantoniodasilva authored Apr 22, 2024
1 parent a0f3b70 commit ece24a5
Show file tree
Hide file tree
Showing 70 changed files with 649 additions and 480 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/judoscale-delayed_job-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ jobs:
matrix:
gemfile:
- Gemfile
- Gemfile-activerecord-7-0
- Gemfile-activerecord-6-1
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
exclude:
- gemfile: Gemfile
ruby: "2.6"
- gemfile: Gemfile-activerecord-7-0
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-delayed_job/${{ matrix.gemfile }}
Expand All @@ -38,7 +43,7 @@ jobs:
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/judoscale-good_job-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,27 @@ jobs:
matrix:
gemfile:
- Gemfile
- Gemfile-activerecord-7-0
- Gemfile-activerecord-6-1
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
exclude:
- gemfile: Gemfile
ruby: "2.6"
- gemfile: Gemfile-activerecord-7-0
ruby: "2.6"
# AR 6.1 stable doesn't play nice with Ruby 3.2+. Fixes have been backported
# https://github.com/rails/rails/pull/46895, but no release is planned.
# To avoid testing against 6-1-stable branch, we'll just skip those for now.
- gemfile: Gemfile-activerecord-6-1
ruby: "3.3"
- gemfile: Gemfile-activerecord-6-1
ruby: "3.2"
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-good_job/${{ matrix.gemfile }}
Expand All @@ -38,7 +50,7 @@ jobs:
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/judoscale-que-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,29 @@ jobs:
matrix:
gemfile:
- Gemfile
- Gemfile-activerecord-7-0
- Gemfile-activerecord-6-1
- Gemfile-que-2
- Gemfile-que-1
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
exclude:
- gemfile: Gemfile
ruby: "2.6"
- gemfile: Gemfile-que-2
- gemfile: Gemfile-activerecord-7-0
ruby: "2.6"
- gemfile: Gemfile-que-1
ruby: "3.3"
- gemfile: Gemfile-que-1
ruby: "3.2"
- gemfile: Gemfile-que-1
ruby: "3.1"
- gemfile: Gemfile-que-1
ruby: "3.0"
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-que/${{ matrix.gemfile }}
Expand All @@ -41,7 +52,7 @@ jobs:
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/judoscale-rack-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ jobs:
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
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-rack/${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/judoscale-rails-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@ jobs:
matrix:
gemfile:
- Gemfile
- Gemfile-rails-7-0
- Gemfile-rails-6-1
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
exclude:
- gemfile: Gemfile
ruby: "2.6"
- gemfile: Gemfile-rails-7-0
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 }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/judoscale-resque-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ jobs:
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
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-resque/${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/judoscale-ruby-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ jobs:
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
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-ruby/${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/judoscale-sidekiq-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
ruby:
- "2.7"
- "3.1"
- "3.3"
redis:
- "5.0"
- "6.0"
Expand All @@ -39,7 +40,7 @@ jobs:
- 6379:6379

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/judoscale-sidekiq-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ jobs:
matrix:
gemfile:
- Gemfile
- Gemfile-sidekiq-6
- Gemfile-sidekiq-5
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
exclude:
# Sidekiq 7.0 requires Ruby 2.7
- gemfile: Gemfile
Expand All @@ -28,7 +31,7 @@ jobs:
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/judoscale-sidekiq/${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- '3.1'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
9 changes: 9 additions & 0 deletions judoscale-delayed_job/Gemfile-activerecord-7-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source "https://rubygems.org"

gemspec name: "judoscale-delayed_job"

gem "judoscale-ruby", path: "../judoscale-ruby"
gem "activerecord", "~> 7.0"
gem "pg"
gem "minitest"
gem "rake"
2 changes: 1 addition & 1 deletion judoscale-delayed_job/test/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module Judoscale
describe DelayedJob do
it "adds itself as an adapter with information to be reported to the Rails Autoscale API" do
it "adds itself as an adapter with information to be reported to the Judoscale API" do
adapter = Judoscale.adapters.detect { |adapter| adapter.identifier == :"judoscale-delayed_job" }
_(adapter).wont_be_nil
_(adapter.metrics_collector).must_equal Judoscale::DelayedJob::MetricsCollector
Expand Down
28 changes: 16 additions & 12 deletions judoscale-delayed_job/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

require "active_record"

DATABASE_NAME = "rails_autoscale_delayed_job_test"
DATABASE_NAME = "judoscale_delayed_job_test"
DATABASE_USERNAME = "postgres"
DATABASE_URL = "postgres://#{DATABASE_USERNAME}:@localhost/#{DATABASE_NAME}"

Expand All @@ -21,17 +21,21 @@
ActiveRecord::Schema.define do
# https://github.com/collectiveidea/delayed_job_active_record/blob/master/lib/generators/delayed_job/templates/migration.rb#L3
# standard:disable all
create_table :delayed_jobs do |table|
table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
table.text :handler, null: false # YAML-encoded string of the object that will do work
table.text :last_error # reason for last failure (See Note below)
table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
table.datetime :locked_at # Set when a client is working on this object
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
table.string :locked_by # Who is working on this object (if locked)
table.string :queue # The name of the queue this job is in
table.timestamps null: true
suppress_messages do
create_table :delayed_jobs do |table|
table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
table.text :handler, null: false # YAML-encoded string of the object that will do work
table.text :last_error # reason for last failure (See Note below)
table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
table.datetime :locked_at # Set when a client is working on this object
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
table.string :locked_by # Who is working on this object (if locked)
table.string :queue # The name of the queue this job is in
table.timestamps null: true
end

add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
end
# standard:enable all
end
Expand Down
9 changes: 9 additions & 0 deletions judoscale-good_job/Gemfile-activerecord-7-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source "https://rubygems.org"

gemspec name: "judoscale-good_job"

gem "judoscale-ruby", path: "../judoscale-ruby"
gem "activerecord", "~> 7.0"
gem "pg"
gem "minitest"
gem "rake"
2 changes: 1 addition & 1 deletion judoscale-good_job/test/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module Judoscale
describe GoodJob do
it "adds itself as an adapter with information to be reported to the Rails Autoscale API" do
it "adds itself as an adapter with information to be reported to the Judoscale API" do
adapter = Judoscale.adapters.detect { |adapter| adapter.identifier == :"judoscale-good_job" }
_(adapter).wont_be_nil
_(adapter.metrics_collector).must_equal Judoscale::GoodJob::MetricsCollector
Expand Down
Loading

0 comments on commit ece24a5

Please sign in to comment.