Skip to content

Commit

Permalink
Merge branch 'feat/DEX-2733/support-rails-8' into 'master'
Browse files Browse the repository at this point in the history
Resolve DEX-2733 "Feat//support rails 8"

Closes DEX-2733

See merge request nstmrt/rubygems/outbox!108
  • Loading branch information
Arlantir committed Dec 27, 2024
2 parents f2fd66c + 43d89f6 commit e5c1d01
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ include:
lint:
stage: test
image: ${BUILD_CONF_HARBOR_REGISTRY}/dhub/library/ruby:3.3
tags:
- paas-stage
script:
- bundle install
- bundle exec rubocop

tests:
stage: test
image: ${BUILD_CONF_HARBOR_REGISTRY}/dhub/library/ruby:$RUBY_VERSION
tags:
- paas-medium
parallel:
matrix:
- RUBY_VERSION: ['2.7', '3.0', '3.1', '3.2', '3.3']
Expand Down
7 changes: 1 addition & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inherit_mode:

AllCops:
TargetRubyVersion: 2.7
TargetRailsVersion: 5.2
TargetRailsVersion: 6.0
NewCops: enable
SuggestExtensions: false

Expand Down Expand Up @@ -56,8 +56,3 @@ RSpec/MultipleMemoizedHelpers:
RSpec/DescribeClass:
Exclude:
- spec/lib/sbmt/outbox/tasks/*

RSpec/InstanceVariable:
Exclude:
# TODO: Remove this when changing the minimum Rails version to 5.1
- spec/lib/sbmt/outbox/worker_spec.rb
8 changes: 5 additions & 3 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

versions_map = {
"6.0" => %w[2.7],
"6.1" => %w[3.0 3.1],
"7.0" => %w[3.2],
"7.1" => %w[3.3]
"6.1" => %w[3.0],
"7.0" => %w[3.1],
"7.1" => %w[3.2],
"7.2" => %w[3.3],
"8.0" => %w[3.3]
}

current_ruby_version = RUBY_VERSION.split(".").first(2).join(".")
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

## [6.11.0] - 2024-12-23

### Added

- Add support of Rails 8.0

### Changed

- Dropped support of Rails 5.2

## [6.10.5] - 2024-11-05

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/sbmt/outbox/base_delete_stale_items_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def postgres_delete_in_batches(waterline)
def mysql_delete_in_batches(waterline)
loop do
deleted_count = item_class
.where("created_at < ?", waterline)
.where(created_at: ...waterline)
.limit(BATCH_SIZE)
.delete_all

Expand Down
12 changes: 9 additions & 3 deletions app/models/sbmt/outbox/base_item.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# frozen_string_literal: true

require_relative "../../../../lib/sbmt/outbox/enum_refinement"

module Sbmt
module Outbox
class BaseItem < Outbox.active_record_base_class
# For compatibility with rails < 7
# Remove when drop support of Rails < 7
using EnumRefinement

self.abstract_class = true

class << self
Expand All @@ -26,8 +32,8 @@ def config

def calc_bucket_partitions(count)
(0...count).to_a
.each_with_object({}) do |x, m|
m[x] = (0...config.bucket_size).to_a
.index_with do |x|
(0...config.bucket_size).to_a
.select { |p| p % count == x }
end
end
Expand All @@ -46,7 +52,7 @@ def bucket_partitions
end
end

enum status: {
enum :status, {
pending: 0,
failed: 1,
delivered: 2,
Expand Down
6 changes: 4 additions & 2 deletions dip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ interaction:
subcommands:
all:
command: bundle exec appraisal rspec
rails-5.2:
command: bundle exec appraisal rails-5.2 rspec
rails-6.0:
command: bundle exec appraisal rails-6.0 rspec
rails-6.1:
Expand All @@ -45,6 +43,10 @@ interaction:
command: bundle exec appraisal rails-7.0 rspec
rails-7.1:
command: bundle exec appraisal rails-7.1 rspec
rails-7.2:
command: bundle exec appraisal rails-7.2 rspec
rails-8.0:
command: bundle exec appraisal rails-8.0 rspec

rubocop:
description: Run Ruby linter
Expand Down
17 changes: 17 additions & 0 deletions lib/sbmt/outbox/enum_refinement.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Sbmt
module Outbox
module EnumRefinement
refine ActiveRecord::Base.singleton_class do
def enum(name, values = nil)
if Rails::VERSION::MAJOR >= 7
super
else
super(name => values)
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/sbmt/outbox/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Sbmt
module Outbox
VERSION = "6.10.5"
VERSION = "6.11.0"
end
end
2 changes: 1 addition & 1 deletion sbmt-outbox.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Gem::Specification.new do |s|
s.add_dependency "dry-initializer", "~> 3.0"
s.add_dependency "dry-monads", "~> 1.3"
s.add_dependency "exponential-backoff", "~> 0.0"
s.add_dependency "rails", ">= 5.2", "< 8"
s.add_dependency "rails", ">= 6.0", "< 8.1"
s.add_dependency "yabeda", "~> 0.8"
s.add_dependency "thor", ">= 0.20", "< 2"
s.add_dependency "redlock", "> 1.0", "< 3.0"
Expand Down

0 comments on commit e5c1d01

Please sign in to comment.