From a30aa1d72a63fe7e4960bee21e3f581bcc22ca3e Mon Sep 17 00:00:00 2001 From: Irving Caro <112433591+betterment-coding-agent@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:06:36 -0600 Subject: [PATCH 1/8] Drop EOL Ruby and Rails versions support --- .github/workflows/ci.yml | 17 +---------------- .rubocop.yml | 2 +- .ruby-version | 2 +- Appraisals | 12 ------------ delayed.gemspec | 6 +++--- 5 files changed, 6 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46e7533..56b8016 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,26 +8,11 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['2.6', '2.7', '3.0', '3.1', '3.2'] + ruby: ['3.0', '3.1', '3.2'] gemfile: - - gemfiles/rails_5_2.gemfile - - gemfiles/rails_6_0.gemfile - gemfiles/rails_6_1.gemfile - gemfiles/rails_7_0.gemfile - gemfiles/rails_7_1.gemfile - exclude: - - ruby: '3.2' - gemfile: gemfiles/rails_5_2.gemfile - - ruby: '3.1' - gemfile: gemfiles/rails_5_2.gemfile - - ruby: '3.0' - gemfile: gemfiles/rails_5_2.gemfile - - ruby: '2.7' - gemfile: gemfiles/rails_7_1.gemfile - - ruby: '2.6' - gemfile: gemfiles/rails_7_1.gemfile - - ruby: '2.6' - gemfile: gemfiles/rails_7_0.gemfile services: postgres: image: postgres diff --git a/.rubocop.yml b/.rubocop.yml index 637eed7..a729fa2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,7 +9,7 @@ inherit_mode: - Exclude AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 3.0 Exclude: - 'lib/generators/delayed/templates/*.rb' NewCops: enable diff --git a/.ruby-version b/.ruby-version index a603bb5..be94e6f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.5 +3.2.2 diff --git a/Appraisals b/Appraisals index 8e8f0c3..8b21269 100644 --- a/Appraisals +++ b/Appraisals @@ -1,15 +1,3 @@ -appraise 'rails-5-2' do - gem 'actionmailer', '~> 5.2.0' - gem 'activejob', '~> 5.2.0' - gem 'activerecord', '~> 5.2.0' -end - -appraise 'rails-6-0' do - gem 'actionmailer', '~> 6.0.0' - gem 'activejob', '~> 6.0.0' - gem 'activerecord', '~> 6.0.0' -end - appraise 'rails-6-1' do gem 'actionmailer', '~> 6.1.0' gem 'activejob', '~> 6.1.0' diff --git a/delayed.gemspec b/delayed.gemspec index 0e4b0b9..7412835 100644 --- a/delayed.gemspec +++ b/delayed.gemspec @@ -18,15 +18,15 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.summary = 'a multi-threaded, SQL-driven ActiveJob backend used at Betterment to process millions of background jobs per day' - spec.version = '0.5.2' + spec.version = '0.6.0' spec.metadata = { 'changelog_uri' => 'https://github.com/betterment/delayed/blob/main/CHANGELOG.md', 'bug_tracker_uri' => 'https://github.com/betterment/delayed/issues', 'source_code_uri' => 'https://github.com/betterment/delayed', 'rubygems_mfa_required' => 'true', } - spec.required_ruby_version = '>= 2.6' + spec.required_ruby_version = '>= 3.0' - spec.add_dependency 'activerecord', '>= 5.2' + spec.add_dependency 'activerecord', '>= 6.1' spec.add_dependency 'concurrent-ruby' end From 0c3d6592f3a62780b7dcf0d4403d2b99876d8fc7 Mon Sep 17 00:00:00 2001 From: Irving Caro <112433591+betterment-coding-agent@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:09:11 -0600 Subject: [PATCH 2/8] Bump linter ruby version --- .github/workflows/linter.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 857bb4d..70cd6c7 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -8,10 +8,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Ruby 2.7 + - name: Set up Ruby 3.0 uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.0 bundler-cache: true - name: Run Linter run: bundle exec rubocop --parallel From 72d66dccd65623593793ea6524549723a2aaa165 Mon Sep 17 00:00:00 2001 From: Irving Caro <112433591+betterment-coding-agent@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:13:20 -0600 Subject: [PATCH 3/8] rubocop --only Style/RedundantFreeze -a --- lib/delayed.rb | 2 +- lib/delayed/backend/base.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/delayed.rb b/lib/delayed.rb index 2fb9782..eacc736 100644 --- a/lib/delayed.rb +++ b/lib/delayed.rb @@ -39,7 +39,7 @@ module Delayed autoload :PerformableMailer, 'delayed/performable_mailer' - mattr_accessor(:default_log_level) { 'info'.freeze } + mattr_accessor(:default_log_level) { 'info' } mattr_accessor(:plugins) do [ Delayed::Plugins::Instrumentation, diff --git a/lib/delayed/backend/base.rb b/lib/delayed/backend/base.rb index 62369bf..75e3c3c 100644 --- a/lib/delayed/backend/base.rb +++ b/lib/delayed/backend/base.rb @@ -55,7 +55,7 @@ def failed? end alias failed failed? - ParseObjectFromYaml = %r{!ruby/\w+:([^\s]+)}.freeze # rubocop:disable Naming/ConstantName + ParseObjectFromYaml = %r{!ruby/\w+:([^\s]+)} # rubocop:disable Naming/ConstantName def name # rubocop:disable Metrics/AbcSize @name ||= payload_object.job_data['job_class'] if payload_object.respond_to?(:job_data) From ca827c12633d8707b8f856112d63a6bbe3005207 Mon Sep 17 00:00:00 2001 From: Irving Caro <112433591+betterment-coding-agent@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:22:23 -0600 Subject: [PATCH 4/8] Remove Ruby 2.7 guards --- .rubocop_todo.yml | 84 +++++++++++++++++++++++++++---- lib/delayed/performable_method.rb | 8 +-- 2 files changed, 74 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7364103..22515be 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 99999` -# on 2023-01-20 19:16:15 UTC using RuboCop version 1.43.0. +# on 2023-12-28 21:25:50 UTC using RuboCop version 1.59.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -33,6 +33,7 @@ Lint/ConstantDefinitionInBlock: - 'spec/message_sending_spec.rb' # Offense count: 2 +# Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Exclude: - 'lib/delayed/message_sending.rb' @@ -50,7 +51,7 @@ Lint/SuppressedException: - 'lib/delayed/backend/base.rb' # Offense count: 4 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes, Max. +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. Metrics/AbcSize: Exclude: - 'lib/delayed/message_sending.rb' @@ -58,17 +59,15 @@ Metrics/AbcSize: - 'lib/delayed/worker.rb' # Offense count: 1 -RSpec/AnyInstance: +# This cop supports safe autocorrection (--autocorrect). +Performance/StringIdentifierArgument: Exclude: - - 'spec/delayed/job_spec.rb' + - 'lib/delayed/monitor.rb' -# Offense count: 18 -# This cop supports unsafe autocorrection (--autocorrect-all). -RSpec/BeEq: +# Offense count: 1 +RSpec/AnyInstance: Exclude: - 'spec/delayed/job_spec.rb' - - 'spec/delayed/priority_spec.rb' - - 'spec/message_sending_spec.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -165,11 +164,10 @@ Rake/DuplicateTask: Exclude: - 'Rakefile' -# Offense count: 4 +# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). Security/YAMLLoad: Exclude: - - 'spec/delayed/serialization/active_record_spec.rb' - 'spec/helper.rb' - 'spec/yaml_ext_spec.rb' @@ -180,6 +178,70 @@ Style/FetchEnvVar: Exclude: - 'spec/helper.rb' +# Offense count: 57 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'Appraisals' + - 'Rakefile' + - 'app/models/delayed/job.rb' + - 'delayed.gemspec' + - 'gemfiles/rails_5_2.gemfile' + - 'gemfiles/rails_6_0.gemfile' + - 'gemfiles/rails_6_1.gemfile' + - 'gemfiles/rails_7_0.gemfile' + - 'gemfiles/rails_7_1.gemfile' + - 'lib/delayed.rb' + - 'lib/delayed/active_job_adapter.rb' + - 'lib/delayed/backend/base.rb' + - 'lib/delayed/backend/job_preparer.rb' + - 'lib/delayed/engine.rb' + - 'lib/delayed/exceptions.rb' + - 'lib/delayed/job_wrapper.rb' + - 'lib/delayed/lifecycle.rb' + - 'lib/delayed/message_sending.rb' + - 'lib/delayed/monitor.rb' + - 'lib/delayed/performable_mailer.rb' + - 'lib/delayed/performable_method.rb' + - 'lib/delayed/plugin.rb' + - 'lib/delayed/plugins/connection.rb' + - 'lib/delayed/plugins/instrumentation.rb' + - 'lib/delayed/priority.rb' + - 'lib/delayed/psych_ext.rb' + - 'lib/delayed/runnable.rb' + - 'lib/delayed/serialization/active_record.rb' + - 'lib/delayed/syck_ext.rb' + - 'lib/delayed/tasks.rb' + - 'lib/delayed/worker.rb' + - 'lib/delayed/yaml_ext.rb' + - 'lib/delayed_job.rb' + - 'lib/delayed_job_active_record.rb' + - 'lib/generators/delayed/generator.rb' + - 'lib/generators/delayed/migration_generator.rb' + - 'lib/generators/delayed/next_migration_version.rb' + - 'spec/autoloaded/clazz.rb' + - 'spec/autoloaded/instance_clazz.rb' + - 'spec/autoloaded/instance_struct.rb' + - 'spec/autoloaded/struct.rb' + - 'spec/delayed/active_job_adapter_spec.rb' + - 'spec/delayed/job_spec.rb' + - 'spec/delayed/monitor_spec.rb' + - 'spec/delayed/plugins/instrumentation_spec.rb' + - 'spec/delayed/priority_spec.rb' + - 'spec/delayed/serialization/active_record_spec.rb' + - 'spec/delayed/tasks_spec.rb' + - 'spec/helper.rb' + - 'spec/lifecycle_spec.rb' + - 'spec/message_sending_spec.rb' + - 'spec/performable_mailer_spec.rb' + - 'spec/performable_method_spec.rb' + - 'spec/psych_ext_spec.rb' + - 'spec/sample_jobs.rb' + - 'spec/worker_spec.rb' + - 'spec/yaml_ext_spec.rb' + # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/MinMaxComparison: diff --git a/lib/delayed/performable_method.rb b/lib/delayed/performable_method.rb index 8b6d46d..cd39f06 100644 --- a/lib/delayed/performable_method.rb +++ b/lib/delayed/performable_method.rb @@ -24,13 +24,7 @@ def display_name end def perform - return unless object - - if kwargs.nil? || (RUBY_VERSION < '2.7' && kwargs.empty?) - object.send(method_name, *args) - else - object.send(method_name, *args, **kwargs) - end + object.send(method_name, *args, **kwargs) if object end def method(sym) From 0725c891b8d7f60bc7cd088073ac9d30c9dbbbd0 Mon Sep 17 00:00:00 2001 From: Irving Caro <112433591+betterment-coding-agent@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:30:09 -0600 Subject: [PATCH 5/8] Disable Style/FrozenStringLiteralComment cop --- .rubocop.yml | 3 ++ .rubocop_todo.yml | 72 +---------------------------------------------- 2 files changed, 4 insertions(+), 71 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a729fa2..a98714a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,3 +16,6 @@ AllCops: Rails/EnvironmentVariableAccess: Enabled: false + +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 22515be..34acfc4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 99999` -# on 2023-12-28 21:25:50 UTC using RuboCop version 1.59.0. +# on 2023-12-28 21:29:05 UTC using RuboCop version 1.59.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -58,12 +58,6 @@ Metrics/AbcSize: - 'lib/delayed/psych_ext.rb' - 'lib/delayed/worker.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Performance/StringIdentifierArgument: - Exclude: - - 'lib/delayed/monitor.rb' - # Offense count: 1 RSpec/AnyInstance: Exclude: @@ -178,70 +172,6 @@ Style/FetchEnvVar: Exclude: - 'spec/helper.rb' -# Offense count: 57 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, always_true, never -Style/FrozenStringLiteralComment: - Exclude: - - 'Appraisals' - - 'Rakefile' - - 'app/models/delayed/job.rb' - - 'delayed.gemspec' - - 'gemfiles/rails_5_2.gemfile' - - 'gemfiles/rails_6_0.gemfile' - - 'gemfiles/rails_6_1.gemfile' - - 'gemfiles/rails_7_0.gemfile' - - 'gemfiles/rails_7_1.gemfile' - - 'lib/delayed.rb' - - 'lib/delayed/active_job_adapter.rb' - - 'lib/delayed/backend/base.rb' - - 'lib/delayed/backend/job_preparer.rb' - - 'lib/delayed/engine.rb' - - 'lib/delayed/exceptions.rb' - - 'lib/delayed/job_wrapper.rb' - - 'lib/delayed/lifecycle.rb' - - 'lib/delayed/message_sending.rb' - - 'lib/delayed/monitor.rb' - - 'lib/delayed/performable_mailer.rb' - - 'lib/delayed/performable_method.rb' - - 'lib/delayed/plugin.rb' - - 'lib/delayed/plugins/connection.rb' - - 'lib/delayed/plugins/instrumentation.rb' - - 'lib/delayed/priority.rb' - - 'lib/delayed/psych_ext.rb' - - 'lib/delayed/runnable.rb' - - 'lib/delayed/serialization/active_record.rb' - - 'lib/delayed/syck_ext.rb' - - 'lib/delayed/tasks.rb' - - 'lib/delayed/worker.rb' - - 'lib/delayed/yaml_ext.rb' - - 'lib/delayed_job.rb' - - 'lib/delayed_job_active_record.rb' - - 'lib/generators/delayed/generator.rb' - - 'lib/generators/delayed/migration_generator.rb' - - 'lib/generators/delayed/next_migration_version.rb' - - 'spec/autoloaded/clazz.rb' - - 'spec/autoloaded/instance_clazz.rb' - - 'spec/autoloaded/instance_struct.rb' - - 'spec/autoloaded/struct.rb' - - 'spec/delayed/active_job_adapter_spec.rb' - - 'spec/delayed/job_spec.rb' - - 'spec/delayed/monitor_spec.rb' - - 'spec/delayed/plugins/instrumentation_spec.rb' - - 'spec/delayed/priority_spec.rb' - - 'spec/delayed/serialization/active_record_spec.rb' - - 'spec/delayed/tasks_spec.rb' - - 'spec/helper.rb' - - 'spec/lifecycle_spec.rb' - - 'spec/message_sending_spec.rb' - - 'spec/performable_mailer_spec.rb' - - 'spec/performable_method_spec.rb' - - 'spec/psych_ext_spec.rb' - - 'spec/sample_jobs.rb' - - 'spec/worker_spec.rb' - - 'spec/yaml_ext_spec.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/MinMaxComparison: From 03edca9e2b95bfe0370b5a29c0b1e6c667f99578 Mon Sep 17 00:00:00 2001 From: Irving Caro <112433591+betterment-coding-agent@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:30:25 -0600 Subject: [PATCH 6/8] rubocop --only Performance/StringIdentifierArgument -a --- lib/delayed/monitor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/delayed/monitor.rb b/lib/delayed/monitor.rb index d297969..98c1344 100644 --- a/lib/delayed/monitor.rb +++ b/lib/delayed/monitor.rb @@ -34,7 +34,7 @@ def run! attr_reader :jobs def emit_metric!(metric) - send("#{metric}_grouped").reverse_merge(default_results).each do |(priority, queue), value| + send(:"#{metric}_grouped").reverse_merge(default_results).each do |(priority, queue), value| ActiveSupport::Notifications.instrument( "delayed.job.#{metric}", default_tags.merge(priority: Priority.new(priority).to_s, queue: queue, value: value), From 37af96276e78bad34d12f554c378ff20f56830a4 Mon Sep 17 00:00:00 2001 From: Irving Caro <112433591+betterment-coding-agent@users.noreply.github.com> Date: Thu, 4 Jan 2024 15:43:12 -0600 Subject: [PATCH 7/8] Delete dropped gemfile variants --- gemfiles/rails_5_2.gemfile | 18 ------------------ gemfiles/rails_6_0.gemfile | 18 ------------------ 2 files changed, 36 deletions(-) delete mode 100644 gemfiles/rails_5_2.gemfile delete mode 100644 gemfiles/rails_6_0.gemfile diff --git a/gemfiles/rails_5_2.gemfile b/gemfiles/rails_5_2.gemfile deleted file mode 100644 index da3da84..0000000 --- a/gemfiles/rails_5_2.gemfile +++ /dev/null @@ -1,18 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "actionmailer", "~> 5.2.0" -gem "activejob", "~> 5.2.0" -gem "activerecord", "~> 5.2.0" -gem "appraisal" -gem "betterlint" -gem "mysql2" -gem "pg" -gem "rake" -gem "rspec" -gem "sqlite3" -gem "timecop" -gem "zeitwerk" - -gemspec path: "../" diff --git a/gemfiles/rails_6_0.gemfile b/gemfiles/rails_6_0.gemfile deleted file mode 100644 index bff971b..0000000 --- a/gemfiles/rails_6_0.gemfile +++ /dev/null @@ -1,18 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "actionmailer", "~> 6.0.0" -gem "activejob", "~> 6.0.0" -gem "activerecord", "~> 6.0.0" -gem "appraisal" -gem "betterlint" -gem "mysql2" -gem "pg" -gem "rake" -gem "rspec" -gem "sqlite3" -gem "timecop" -gem "zeitwerk" - -gemspec path: "../" From 83860f86cd4559d247f23181ec6a069b75f54ff0 Mon Sep 17 00:00:00 2001 From: Irving Caro <112433591+betterment-coding-agent@users.noreply.github.com> Date: Thu, 4 Jan 2024 15:44:03 -0600 Subject: [PATCH 8/8] Restore support Ruby 3 case where both positional and keyword arguments are present --- lib/delayed/performable_method.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/delayed/performable_method.rb b/lib/delayed/performable_method.rb index cd39f06..2afb47e 100644 --- a/lib/delayed/performable_method.rb +++ b/lib/delayed/performable_method.rb @@ -24,7 +24,13 @@ def display_name end def perform - object.send(method_name, *args, **kwargs) if object + return unless object + + if kwargs.nil? + object.send(method_name, *args) + else + object.send(method_name, *args, **kwargs) + end end def method(sym)