Skip to content

Commit

Permalink
Merge branch 'collectiveidea:master' into ignore_active_jobs_in_check…
Browse files Browse the repository at this point in the history
…_task
  • Loading branch information
joshuapinter authored Jan 17, 2025
2 parents 4cbb738 + ea4879d commit 56133e1
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 45 deletions.
101 changes: 80 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,121 @@ 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
#
# 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 }}
Expand All @@ -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 }}
Expand All @@ -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
28 changes: 28 additions & 0 deletions .github/workflows/publish_gem.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ 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:
ruby-version: 2.7
- 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') }}
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
20 changes: 17 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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'
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
============
Expand Down
4 changes: 2 additions & 2 deletions delayed_job.gemspec
Original file line number Diff line number Diff line change
@@ -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 = ['[email protected]']
Expand All @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions lib/delayed/backend/job_preparer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'active_support/core_ext/array/extract_options'

module Delayed
module Backend
class JobPreparer
Expand Down
9 changes: 7 additions & 2 deletions lib/delayed/backend/shared_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions lib/delayed/compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 11 additions & 1 deletion lib/delayed/message_sending.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/delayed/worker.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion spec/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56133e1

Please sign in to comment.