Skip to content

Commit

Permalink
Add ruby 3 to test matrix and drop ruby < 2.6 support (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
will89 authored Feb 22, 2021
1 parent a24713c commit 36c63db
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 117 deletions.
31 changes: 20 additions & 11 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: salsify/ruby_ci:2.5.8
- image: salsify/ruby_ci:2.6.6
working_directory: ~/delayed_job_groups
steps:
- checkout
- restore_cache:
keys:
- v1-gems-ruby-2.5.8-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
- v1-gems-ruby-2.5.8-
- v1-gems-ruby-2.6.6-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
- v1-gems-ruby-2.6.6-
- run:
name: Install Gems
command: |
Expand All @@ -18,7 +18,7 @@ jobs:
bundle clean
fi
- save_cache:
key: v1-gems-ruby-2.5.8-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
key: v1-gems-ruby-2.6.6-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
paths:
- "vendor/bundle"
- "gemfiles/vendor/bundle"
Expand All @@ -29,8 +29,10 @@ jobs:
parameters:
gemfile:
type: string
ruby_version:
type: string
docker:
- image: salsify/ruby_ci:2.5.8
- image: salsify/ruby_ci:<< parameters.ruby_version >>
environment:
CIRCLE_TEST_REPORTS: "test-results"
BUNDLE_GEMFILE: << parameters.gemfile >>
Expand All @@ -39,8 +41,8 @@ jobs:
- checkout
- restore_cache:
keys:
- v1-gems-ruby-2.5.8-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
- v1-gems-ruby-2.5.8-
- v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
- v1-gems-ruby-<< parameters.ruby_version >>-
- run:
name: Install Gems
command: |
Expand All @@ -49,7 +51,7 @@ jobs:
bundle clean
fi
- save_cache:
key: v1-gems-ruby-2.5.8-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
key: v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
paths:
- "vendor/bundle"
- "gemfiles/vendor/bundle"
Expand All @@ -67,6 +69,13 @@ workflows:
matrix:
parameters:
gemfile:
- "gemfiles/rails_5.2.gemfile"
- "gemfiles/rails_6.0.gemfile"
- "gemfiles/rails_6.1.gemfile"
- "gemfiles/rails_5.2.gemfile"
- "gemfiles/rails_6.0.gemfile"
- "gemfiles/rails_6.1.gemfile"
ruby_version:
- "2.6.6"
- "2.7.2"
- "3.0.0"
exclude:
- gemfile: "gemfiles/rails_5.2.gemfile"
ruby_version: "3.0.0"
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ inherit_gem:
salsify_rubocop: conf/rubocop.yml

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.6
Exclude:
- 'vendor/**/*'
- 'gemfiles/vendor/**/*'
- 'gemfiles/**/*'

Style/FrozenStringLiteralComment:
Enabled: true
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
### 0.7.0
* Add support for ruby 3
* Drop support for ruby < 2.6

### 0.6.2
* Defer including extension until delayed_job_active_record is loaded
Expand Down
10 changes: 5 additions & 5 deletions delayed_job_groups.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

# frozen_string_literal: true

lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'delayed/job_groups/version'

Expand All @@ -19,12 +18,13 @@ Gem::Specification.new do |spec|
spec.test_files = Dir.glob('spec/**/*')
spec.require_paths = ['lib']

spec.required_ruby_version = '>= 2.5'
spec.required_ruby_version = '>= 2.6'

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

spec.post_install_message = 'See https://github.com/salsify/delayed_job_groups_plugin#installation for upgrade/installation notes.'
spec.post_install_message = 'See https://github.com/salsify/delayed_job_groups_plugin#installation '\
'for upgrade/installation notes.'

spec.add_development_dependency 'appraisal'
spec.add_dependency 'activerecord', '>= 5.2', '< 7'
Expand All @@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rspec', '~> 3'
spec.add_development_dependency 'rspec-its'
spec.add_development_dependency 'rspec_junit_formatter'
spec.add_development_dependency 'salsify_rubocop', '0.52.1.1'
spec.add_development_dependency 'salsify_rubocop', '~> 1.0.1'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'sqlite3'
spec.add_development_dependency 'timecop'
Expand Down
4 changes: 0 additions & 4 deletions lib/delayed/job_groups/compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ module Delayed
module JobGroups
module Compatibility

def self.mass_assignment_security_enabled?
defined?(::ActiveRecord::MassAssignmentSecurity)
end

end
end
end
4 changes: 0 additions & 4 deletions lib/delayed/job_groups/job_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ def ready_to_run(worker_name, max_run_time)
end

included do
if Delayed::JobGroups::Compatibility.mass_assignment_security_enabled?
attr_accessible :job_group_id, :blocked
end

belongs_to :job_group, class_name: 'Delayed::JobGroups::JobGroup', required: false

class << self
Expand Down
9 changes: 3 additions & 6 deletions lib/delayed/job_groups/job_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ class JobGroup < ActiveRecord::Base

self.table_name = "#{ActiveRecord::Base.table_name_prefix}delayed_job_groups"

if Delayed::JobGroups::Compatibility.mass_assignment_security_enabled?
attr_accessible :on_completion_job, :on_completion_job_options, :blocked, :on_cancellation_job,
:on_cancellation_job_options, :failure_cancels_group
end

serialize :on_completion_job, Delayed::JobGroups::YamlLoader
serialize :on_completion_job_options, Hash
serialize :on_cancellation_job, Delayed::JobGroups::YamlLoader
Expand All @@ -30,6 +25,7 @@ class JobGroup < ActiveRecord::Base
def mark_queueing_complete
with_lock do
raise 'JobGroup has already completed queueing' if queueing_complete?

update_column(:queueing_complete, true)
complete if ready_for_completion?
end
Expand Down Expand Up @@ -66,13 +62,14 @@ def self.check_for_completion(job_group_id)
# zero will queue the job group's completion job and destroy the job group so
# other jobs need to handle the job group having been destroyed already.
job_group = where(id: job_group_id).lock(true).first
job_group.send(:complete) if job_group && job_group.send(:ready_for_completion?)
job_group.send(:complete) if job_group&.send(:ready_for_completion?)
end
end

def self.has_pending_jobs?(job_group_ids) # rubocop:disable Naming/PredicateName
job_group_ids = Array(job_group_ids)
return false if job_group_ids.empty?

Delayed::Job.where(job_group_id: job_group_ids, failed_at: nil).exists?
end

Expand Down
4 changes: 1 addition & 3 deletions lib/delayed/job_groups/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def job.max_attempts
# If a job in the job group fails, then cancel the whole job group.
# Need to check that the job group is present since another
# job may have concurrently cancelled it.
if job.in_job_group? && job.job_group && job.job_group.failure_cancels_group?
job.job_group.cancel
end
job.job_group.cancel if job.in_job_group? && job.job_group&.failure_cancels_group?
end

lifecycle.after(:perform) do |_worker, job|
Expand Down
2 changes: 1 addition & 1 deletion lib/delayed/job_groups/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Delayed
module JobGroups
VERSION = '0.6.2'
VERSION = '0.7.0'
end
end
2 changes: 2 additions & 0 deletions lib/delayed/job_groups/yaml_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ module JobGroups
module YamlLoader
def self.load(yaml)
return yaml unless yaml.is_a?(String) && /^---/.match(yaml)

YAML.load_dj(yaml)
end

def self.dump(object)
return if object.nil?

YAML.dump(object)
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/delayed/job_groups/job_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
before { job_group.mark_queueing_complete }

it { is_expected.to be_queueing_complete }

it_behaves_like "the job group was completed"
end

Expand All @@ -59,6 +60,7 @@
before { job_group.mark_queueing_complete }

it { is_expected.to be_queueing_complete }

it_behaves_like "the job group was not completed"
end

Expand All @@ -69,6 +71,7 @@
end

it { is_expected.to be_queueing_complete }

it_behaves_like "the job group was not completed"
end
end
Expand Down Expand Up @@ -199,6 +202,7 @@
end

its(:blocked?) { is_expected.to be(false) }

it_behaves_like "the job group was completed"
end
end
Expand Down
Loading

0 comments on commit 36c63db

Please sign in to comment.