Skip to content

Commit

Permalink
Merge pull request #420 from Shopify/blaze-it
Browse files Browse the repository at this point in the history
Restore Ruby 2.6 & Rails 5.2 support
  • Loading branch information
Mangara authored Aug 23, 2023
2 parents 3556330 + 7d7cc47 commit d26f741
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 15 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ jobs:
- 6379:6379
strategy:
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
gemfile: [rails_6_0, rails_6_1, rails_7_0, rails_edge]
ruby: ["2.6", "2.7", "3.0", "3.1", "3.2"]
gemfile: [rails_5_2, rails_6_0, rails_6_1, rails_7_0, rails_edge]
exclude:
- ruby: "2.6"
gemfile: rails_7_0
- ruby: "2.6"
gemfile: rails_edge
- ruby: "3.0"
gemfile: rails_5_2
- ruby: "3.1"
gemfile: rails_5_2
- ruby: "3.2"
gemfile: rails_5_2
- ruby: "3.1"
gemfile: rails_6_0
- ruby: "3.2"
Expand Down
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:
rubocop-shopify: rubocop.yml

AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 2.6
Exclude:
- "vendor/bundle/**/*"
Lint/SuppressedException:
Expand Down
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
### Main (unreleased)

- [365](https://github.com/Shopify/job-iteration/pull/365) - Support composite primary key as a cursor
- [241](https://github.com/Shopify/job-iteration/pull/241) - Require Ruby 2.7+, dropping 2.6 support
- [241](https://github.com/Shopify/job-iteration/pull/241) - Require Rails 6.0+, dropping 5.2 support
- [240](https://github.com/Shopify/job-iteration/pull/240) - Allow setting inheritable per-job `job_iteration_max_job_runtime`
- [289](https://github.com/Shopify/job-iteration/pull/289) - Fix uninitialized constant error when raising `ConditionNotSupportedError` from `ActiveRecordBatchEnumerator`
- [310](https://github.com/Shopify/job-iteration/pull/310) - Support nested iteration
- [338](https://github.com/Shopify/job-iteration/pull/338) - All logs are now `ActiveSupport::Notifications` events and logged using `ActiveSupport::LogSubscriber` to allow customization. Events now always include the `cursor_position` tag.
- [341](https://github.com/Shopify/job-iteration/pull/341) - Add `JobIteration.default_retry_backoff`, which sets a default delay when jobs are re-enqueued after being interrupted. Defaults to `nil`, meaning no delay, which matches the current behaviour.
- [417](https://github.com/Shopify/job-iteration/pull/417) - Ensure that numerical values are deserialized as such and not as strings.
- [418](https://github.com/Shopify/job-iteration/pull/418) - Return `nil` from `Iteration#perform`, to signal not to rely on return value.

## v1.3.6 (Mar 9, 2022)

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PATH
remote: .
specs:
job-iteration (1.3.6)
activejob (>= 6.0)
activejob (>= 5.2)

GEM
remote: https://rubygems.org/
Expand Down
6 changes: 6 additions & 0 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

eval_gemfile "../Gemfile"

gem "activejob", "~> 5.2.0"
gem "activerecord", "~> 5.2.0"
4 changes: 2 additions & 2 deletions job-iteration.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "job-iteration/version"

Gem::Specification.new do |spec|
spec.required_ruby_version = ">= 2.7"
spec.required_ruby_version = ">= 2.6"
spec.name = "job-iteration"
spec.version = JobIteration::VERSION
spec.authors = ["Shopify"]
Expand All @@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
spec.metadata["allowed_push_host"] = "https://rubygems.org"

spec.add_development_dependency("activerecord")
spec.add_dependency("activejob", ">= 6.0")
spec.add_dependency("activejob", ">= 5.2")
end
9 changes: 8 additions & 1 deletion lib/job-iteration/csv_enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ def batches(batch_size:, cursor:)
private

def count_of_rows_in_file
filepath = @csv.path
# TODO: Remove rescue for NoMethodError when Ruby 2.6 is no longer supported.
begin
filepath = @csv.path
rescue NoMethodError
return
end

# Behaviour of CSV#path changed in Ruby 2.6.3 (returns nil instead of raising NoMethodError)
return unless filepath

count = %x(wc -l < #{filepath}).strip.to_i
Expand Down
11 changes: 5 additions & 6 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,14 @@ class IterationUnitTest < ActiveSupport::TestCase

def insert_fixtures
now = Time.now
products = 10.times.map { |n| { name: "lipstick #{n}", created_at: now - n, updated_at: now - n } }
Product.insert_all!(products)
10.times { |n| Product.create!(name: "lipstick #{n}", created_at: now - n, updated_at: now - n) }

comments = Product.order(:id).limit(3).map.with_index do |product, index|
Product.order(:id).limit(3).map.with_index do |product, index|
comments_count = index + 1
comments_count.times.map { |n| { content: "#{product.name} comment ##{n}", product_id: product.id } }
end.flatten

Comment.insert_all!(comments)
end.flatten.each do |comment|
Comment.create!(**comment)
end
end

def truncate_fixtures
Expand Down

0 comments on commit d26f741

Please sign in to comment.