Skip to content

Commit

Permalink
Add Rails 7.2 support & drop Ruby 2.7 and 3.0 support (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkessler1 authored Aug 29, 2024
1 parent 2879d32 commit 236c1fd
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 27 deletions.
19 changes: 9 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: 2.1
jobs:
lint:
docker:
- image: cimg/ruby:2.7.7
- image: cimg/ruby:3.1.6
working_directory: ~/delayed_job_heartbeat_plugin
steps:
- checkout
- restore_cache:
keys:
- v1-gems-ruby-2.7.7-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
- v1-gems-ruby-2.7.7-
- v1-gems-ruby-3.1.6-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
- v1-gems-ruby-3.1.6-
- run:
name: Install Gems
command: |
Expand All @@ -18,7 +18,7 @@ jobs:
bundle clean
fi
- save_cache:
key: v1-gems-ruby-2.7.7-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
key: v1-gems-ruby-3.1.6-{{ checksum "delayed_job_heartbeat_plugin.gemspec" }}-{{ checksum "Gemfile" }}
paths:
- "vendor/bundle"
- "gemfiles/vendor/bundle"
Expand Down Expand Up @@ -86,12 +86,11 @@ workflows:
matrix:
parameters:
gemfile:
- gemfiles/rails_6.0.gemfile
- gemfiles/rails_6.1.gemfile
- gemfiles/rails_7.0.gemfile
- gemfiles/rails_7.1.gemfile
- gemfiles/rails_7.2.gemfile
ruby_version:
- 2.7.7
- 3.0.5
- 3.1.3
- 3.2.0
- 3.3.0
- 3.1.6
- 3.2.5
- 3.3.4
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ inherit_gem:
salsify_rubocop: conf/rubocop.yml

AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 3.1
Exclude:
- 'vendor/**/*'
- 'gemfiles/**/*'
15 changes: 10 additions & 5 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# frozen_string_literal: true

appraise 'rails-6.0' do
gem 'activerecord', '~> 6.0.4'
gem 'activesupport', '~> 6.0.4'
end

appraise 'rails-6.1' do
gem 'activerecord', '~> 6.1.5'
gem 'activesupport', '~> 6.1.5'
Expand All @@ -14,3 +9,13 @@ appraise 'rails-7.0' do
gem 'activerecord', '~> 7.0.2'
gem 'activesupport', '~> 7.0.2'
end

appraise 'rails-7.1' do
gem 'activerecord', '~> 7.1.3'
gem 'activesupport', '~> 7.1.3'
end

appraise 'rails-7.2' do
gem 'activerecord', '~> 7.2.0'
gem 'activesupport', '~> 7.2.0'
end
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.6.0

- Drop support for Ruby < 3.1
- Drop Rails 6.0
- Add Rails 7.2
**Thanks [@DRSisco](https://github.com/DRSisco)**

## 0.5.0

- Drop support for ruby < 2.7
Expand Down
6 changes: 3 additions & 3 deletions delayed_job_heartbeat_plugin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Gem::Specification.new do |spec|
spec.test_files = Dir.glob('spec/**/*')
spec.require_paths = ['lib']

spec.required_ruby_version = '>= 2.7'
spec.required_ruby_version = '>= 3.1'

spec.add_dependency 'delayed_job', '>= 4.1.0'
spec.add_dependency 'delayed_job_active_record', '>= 4.1.0'

spec.add_development_dependency 'activerecord', ['>= 5.2', '< 7.1']
spec.add_development_dependency 'activerecord', ['>= 6.1', '< 7.3']
spec.add_development_dependency 'appraisal'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'coveralls_reborn', '>= 0.18.0'
Expand All @@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3'
spec.add_development_dependency 'rspec_junit_formatter'
spec.add_development_dependency 'salsify_rubocop', '~> 1.0.2'
spec.add_development_dependency 'salsify_rubocop', '~> 1.59.1'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'timecop'
end
4 changes: 2 additions & 2 deletions gemfiles/rails_6.0.gemfile → gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "activerecord", "~> 6.0.4"
gem "activesupport", "~> 6.0.4"
gem "activerecord", "~> 7.1.3"
gem "activesupport", "~> 7.1.3"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activerecord", "~> 7.2.0"
gem "activesupport", "~> 7.2.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion lib/delayed/heartbeat/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def print_results(results)
puts "Deleted #{results.workers.size} and unlocked #{results.unlocked_jobs.size} orphaned jobs"
puts results.to_s if verbose? && results.present?
puts results if verbose? && results.present?
end

def verbose?
Expand Down
2 changes: 1 addition & 1 deletion lib/delayed/heartbeat/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Delayed
module Heartbeat
VERSION = '0.5.0'
VERSION = '0.6.0'
end
end
6 changes: 3 additions & 3 deletions lib/delayed/heartbeat/worker_heartbeat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def run_heartbeat_loop
update_heartbeat
# Return the connection back to the pool since we won't be needing
# it again for a while.
Delayed::Backend::ActiveRecord::Job.clear_active_connections!
Delayed::Backend::ActiveRecord::Job.connection_handler.clear_active_connections!
end
rescue StandardError => e
# We don't want the worker to continue running if the heartbeat can't be written.
Expand All @@ -58,8 +58,8 @@ def run_heartbeat_loop
ensure
@stop_reader.close
@worker_model.delete
# Note: The built-in Delayed::Plugins::ClearLocks will unlock the jobs for us
Delayed::Backend::ActiveRecord::Job.clear_active_connections!
# NOTE: The built-in Delayed::Plugins::ClearLocks will unlock the jobs for us
Delayed::Backend::ActiveRecord::Job.connection_handler.clear_active_connections!
end

def update_heartbeat
Expand Down
2 changes: 1 addition & 1 deletion spec/delayed/heartbeat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

let!(:failed_orphaned_job) do
Delayed::Job.create!(locked_by: dead_worker.name, locked_at: dead_worker.last_heartbeat_at,
payload_object: TestJobWithCallbacks.new) do |job|
payload_object: TestJobWithCallbacks.new) do |job|
job.attempts = max_attempts - 1
end
end
Expand Down

0 comments on commit 236c1fd

Please sign in to comment.