diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e451964d..43bf89128 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,42 +8,46 @@ on: jobs: test: - runs-on: ubuntu-latest + name: Test (Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails_version }}) + runs-on: ubuntu-${{ matrix.ubuntu }} strategy: fail-fast: false matrix: - ruby: ['2.7', '3.0', '3.1', jruby-head, ruby-head] + ruby: ['3.2', '3.3', jruby-9.4, jruby-head, ruby-head] rails_version: - - '6.0.0' - - '6.1.0' - '7.0.0' + - '7.1.0' + - '7.2.0' + - '8.0.0' - 'edge' + ubuntu: [latest] include: - # Rails 5.2 - - ruby: 2.6 - rails_version: '5.2.0' - - ruby: 2.7 - rails_version: '5.2.0' - - ruby: jruby-9.2 - rails_version: '5.2.0' - # Ruby 2.6 - ruby: 2.6 rails_version: '6.0.0' + ubuntu: '20.04' - ruby: 2.6 rails_version: '6.1.0' + ubuntu: '20.04' + + # ruby 3.1 (Dropped by Rails 8) + - ruby: 3.1 + rails_version: '7.0.0' + ubuntu: 'latest' + - ruby: 3.1 + rails_version: '7.1.0' + ubuntu: 'latest' + - ruby: 3.1 + rails_version: '7.2.0' + ubuntu: 'latest' # jruby-9.2 - ruby: jruby-9.2 rails_version: '6.0.0' + ubuntu: '20.04' - ruby: jruby-9.2 rails_version: '6.1.0' - - # jruby-9.3 - - ruby: jruby-9.3 - rails_version: '7.0.0' - - ruby: jruby-9.3 - rails_version: 'edge' + ubuntu: '20.04' # # The past @@ -51,19 +55,74 @@ jobs: # EOL Active Record - ruby: 2.2 rails_version: '3.2.0' + ubuntu: '20.04' - ruby: 2.1 rails_version: '4.1.0' + ubuntu: '20.04' - ruby: 2.4 rails_version: '4.2.0' + ubuntu: '20.04' - ruby: 2.4 rails_version: '5.0.0' + ubuntu: '20.04' - ruby: 2.5 rails_version: '5.1.0' + ubuntu: '20.04' + - ruby: 2.6 + rails_version: '5.2.0' + ubuntu: '20.04' + - ruby: 2.7 + rails_version: '5.2.0' + ubuntu: '22.04' + - ruby: jruby-9.2 + rails_version: '5.2.0' + ubuntu: '22.04' + - ruby: 2.7 + rails_version: '6.0.0' + ubuntu: '22.04' + - ruby: 3.0 + rails_version: '6.0.0' + ubuntu: '22.04' + - ruby: 3.2 + rails_version: '6.0.0' + ubuntu: '22.04' + - ruby: jruby-9.4 + rails_version: '6.0.0' + ubuntu: '22.04' + - ruby: 2.7 + rails_version: '6.1.0' + ubuntu: '22.04' + - ruby: 3.0 + rails_version: '6.1.0' + ubuntu: '22.04' + - ruby: 3.2 + rails_version: '6.1.0' + ubuntu: '22.04' + - ruby: jruby-9.4 + rails_version: '6.0.0' + ubuntu: '22.04' + - ruby: 2.7 + rails_version: '7.0.0' + ubuntu: '22.04' + - ruby: 3.0 + rails_version: '7.0.0' + ubuntu: '22.04' + - ruby: jruby-9.4 + rails_version: '6.0.0' + ubuntu: '22.04' + + # EOL Ruby + - ruby: 2.7 + rails_version: '7.1.0' + ubuntu: '22.04' + - ruby: 3.0 + rails_version: '7.1.0' + ubuntu: '22.04' continue-on-error: ${{ matrix.rails_version == 'edge' || endsWith(matrix.ruby, 'head') }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 env: RAILS_VERSION: ${{ matrix.rails_version }} @@ -75,7 +134,7 @@ jobs: RAILS_VERSION: ${{ matrix.rails_version }} run: bundle exec rspec - name: Coveralls Parallel - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@main with: github-token: ${{ secrets.github_token }} flag-name: run-${{ matrix.ruby }}-${{ matrix.rails_version }} @@ -86,7 +145,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Coveralls Finished - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@main with: github-token: ${{ secrets.github_token }} parallel-finished: true diff --git a/.github/workflows/publish_gem.yml b/.github/workflows/publish_gem.yml new file mode 100644 index 000000000..613132fdd --- /dev/null +++ b/.github/workflows/publish_gem.yml @@ -0,0 +1,28 @@ +name: Publish Gem + +on: + push: + tags: + - v* + +jobs: + push: + if: github.repository == 'collectiveidea/delayed_job' + runs-on: ubuntu-latest + environment: publishing + + permissions: + contents: write + id-token: write + + steps: + # Set up + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: ruby + + # Release + - uses: rubygems/release-gem@v1 diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 739473987..9d1e97905 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby 2.7 uses: ruby/setup-ruby@v1 with: @@ -15,7 +15,7 @@ jobs: - name: Generate lockfile for cache key run: bundle lock - name: Cache gems - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: vendor/bundle key: ${{ runner.os }}-rubocop-${{ hashFiles('**/Gemfile.lock') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d8f3c37d..ef33c0b48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +4.1.13 - 2024-11-08 +======================= +* Enable Rails 8 + +4.1.12 - 2024-08-14 +======================= +* Add missing require for extract_options +* Fix rails 7.2 ActiveSupport::ProxyObject deprecation +* Multiple contributors on current and legacy test suite improvements + +4.1.12.rc1 - 2024-08-13 +======================= +* Validating trusted publishing release +* Add missing require for extract_options +* Fix rails 7.2 ActiveSupport::ProxyObject deprecation +* Multiple contributors on current and legacy test suite improvements + +4.1.11 - 2022-09-28 +=================== +* Fix missing require for Rails 7.0.3+ + 4.1.10 - 2022-01-17 =================== * Support for Rails 7.0. NOTE: If you are using Delayed Job independent of Rails, Active Support 7 has dropped classic dependency autoloading. You will need to add and setup zeitwerk for autoloading to continue working in ActiveSupport 7. diff --git a/Gemfile b/Gemfile index c66ff6e7e..72280c43a 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,8 @@ platforms :ruby do # Rails 6 now requires sqlite 1.4 if ENV['RAILS_VERSION'] && ENV['RAILS_VERSION'] < '5.1' gem 'sqlite3', '< 1.4' + elsif ENV['RAILS_VERSION'] && ENV['RAILS_VERSION'] < '7.2' + gem 'sqlite3', '~> 1.4' else gem 'sqlite3' end @@ -36,7 +38,7 @@ platforms :jruby do elsif ENV['RAILS_VERSION'] gem 'railties', "~> #{ENV['RAILS_VERSION']}" else - gem 'railties', ['>= 3.0', '< 8.0'] + gem 'railties', ['>= 3.0', '< 9.0'] end end @@ -51,9 +53,14 @@ group :test do elsif ENV['RAILS_VERSION'] gem 'actionmailer', "~> #{ENV['RAILS_VERSION']}" gem 'activerecord', "~> #{ENV['RAILS_VERSION']}" + if ENV['RAILS_VERSION'] < '5.1' + gem 'loofah', '2.3.1' + gem 'nokogiri', '< 1.11.0' + gem 'rails-html-sanitizer', '< 1.4.0' + end else - gem 'actionmailer', ['>= 3.0', '< 8.0'] - gem 'activerecord', ['>= 3.0', '< 8.0'] + gem 'actionmailer', ['>= 3.0', '< 9.0'] + gem 'activerecord', ['>= 3.0', '< 9.0'] end gem 'net-smtp' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') gem 'rspec', '>= 3' @@ -64,6 +71,13 @@ group :test do else gem 'simplecov-lcov', :require => false end + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3.0') + # New dependencies with a deprecation notice in Ruby 3.3 and required in Ruby 3.4 + # Probably won't get released in rails 7.0 + gem 'base64' + gem 'bigdecimal' + gem 'mutex_m' + end if ENV['RAILS_VERSION'].nil? || ENV['RAILS_VERSION'] >= '6.0.0' gem 'zeitwerk', :require => false end diff --git a/README.md b/README.md index c72ed2f6f..4badb2815 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ **If you're viewing this at https://github.com/collectiveidea/delayed_job, you're reading the documentation for the master branch. [View documentation for the latest release -(4.1.10).](https://github.com/collectiveidea/delayed_job/tree/v4.1.10)** +(4.1.13).](https://github.com/collectiveidea/delayed_job/tree/v4.1.13)** Delayed::Job ============ diff --git a/delayed_job.gemspec b/delayed_job.gemspec index ee290405e..e6bc24b41 100644 --- a/delayed_job.gemspec +++ b/delayed_job.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |spec| - spec.add_dependency 'activesupport', ['>= 3.0', '< 8.0'] + spec.add_dependency 'activesupport', ['>= 3.0', '< 9.0'] spec.authors = ['Brandon Keepers', 'Brian Ryckbost', 'Chris Gaffney', 'David Genord II', 'Erik Michaels-Ober', 'Matt Griffin', 'Steve Richert', 'Tobias Lütke'] spec.description = 'Delayed_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. It is a direct extraction from Shopify where the job table is responsible for a multitude of core tasks.' spec.email = ['brian@collectiveidea.com'] @@ -13,7 +13,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.summary = 'Database-backed asynchronous priority queue system -- Extracted from Shopify' spec.test_files = Dir.glob('spec/**/*') - spec.version = '4.1.10' + spec.version = '4.1.13' spec.metadata = { 'changelog_uri' => 'https://github.com/collectiveidea/delayed_job/blob/master/CHANGELOG.md', 'bug_tracker_uri' => 'https://github.com/collectiveidea/delayed_job/issues', diff --git a/lib/delayed/backend/job_preparer.rb b/lib/delayed/backend/job_preparer.rb index f545eda0e..24c869752 100644 --- a/lib/delayed/backend/job_preparer.rb +++ b/lib/delayed/backend/job_preparer.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/array/extract_options' + module Delayed module Backend class JobPreparer diff --git a/lib/delayed/backend/shared_spec.rb b/lib/delayed/backend/shared_spec.rb index 39f497670..211187265 100644 --- a/lib/delayed/backend/shared_spec.rb +++ b/lib/delayed/backend/shared_spec.rb @@ -230,7 +230,7 @@ def create_job(opts = {}) end it 'reserves jobs scheduled for the past when time zones are involved' do - Time.zone = 'US/Eastern' + Time.zone = 'America/New_York' job = create_job :run_at => described_class.db_time_now - 1.minute expect(described_class.reserve(worker)).to eq(job) end @@ -595,7 +595,12 @@ def create_job(opts = {}) worker.work_off @job.reload expect(@job.last_error).to match(/did not work/) - expect(@job.last_error).to match(/sample_jobs.rb:\d+:in `perform'/) + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4.0') + # Ruby 3.4 produces a more verbose message + expect(@job.last_error).to match(/sample_jobs.rb:\d+:in 'ErrorJob#perform'/) + else + expect(@job.last_error).to match(/sample_jobs.rb:\d+:in `perform'/) + end expect(@job.attempts).to eq(1) expect(@job.run_at).to be > Delayed::Job.db_time_now - 10.minutes expect(@job.run_at).to be < Delayed::Job.db_time_now + 10.minutes diff --git a/lib/delayed/compatibility.rb b/lib/delayed/compatibility.rb index 72778f9cc..0ef949b7a 100644 --- a/lib/delayed/compatibility.rb +++ b/lib/delayed/compatibility.rb @@ -3,25 +3,13 @@ module Delayed module Compatibility if ActiveSupport::VERSION::MAJOR >= 4 - require 'active_support/proxy_object' - def self.executable_prefix 'bin' end - - def self.proxy_object_class - ActiveSupport::ProxyObject - end else - require 'active_support/basic_object' - def self.executable_prefix 'script' end - - def self.proxy_object_class - ActiveSupport::BasicObject - end end end end diff --git a/lib/delayed/message_sending.rb b/lib/delayed/message_sending.rb index a2808fd39..eeb7ee671 100644 --- a/lib/delayed/message_sending.rb +++ b/lib/delayed/message_sending.rb @@ -1,5 +1,15 @@ module Delayed - class DelayProxy < Delayed::Compatibility.proxy_object_class + class DelayProxy < BasicObject + # What additional methods exist on BasicObject has changed over time + (::BasicObject.instance_methods - [:__id__, :__send__, :instance_eval, :instance_exec]).each do |method| + undef_method method + end + + # Let DelayProxy raise exceptions. + def raise(*args) + ::Object.send(:raise, *args) + end + def initialize(payload_class, target, options) @payload_class = payload_class @target = target diff --git a/lib/delayed/worker.rb b/lib/delayed/worker.rb index 1a352f775..7b983a206 100644 --- a/lib/delayed/worker.rb +++ b/lib/delayed/worker.rb @@ -1,5 +1,6 @@ require 'timeout' require 'active_support/dependencies' +require 'active_support/core_ext/kernel/reporting' require 'active_support/core_ext/numeric/time' require 'active_support/core_ext/class/attribute_accessors' require 'active_support/hash_with_indifferent_access' diff --git a/spec/worker_spec.rb b/spec/worker_spec.rb index 1ce08ce99..eb525ede0 100644 --- a/spec/worker_spec.rb +++ b/spec/worker_spec.rb @@ -106,7 +106,7 @@ expect(Delayed::Job).to receive(:reserve).exactly(10).times.and_raise(Exception) worker = Delayed::Worker.new 9.times { worker.work_off } - expect(lambda { worker.work_off }).to raise_exception Delayed::FatalBackendError + expect { worker.work_off }.to raise_exception Delayed::FatalBackendError end it 'allows the backend to attempt recovery from reservation errors' do