Skip to content

Commit

Permalink
drop older versions in test matrix (#46)
Browse files Browse the repository at this point in the history
* drop older versions in test matrix

* get to green

* tweak gh actions

* adjust Rails mocking

* more gh action tweaks

* tighten build matrix and supported versions

* ci tweaks

* remove codeclimate

* fix hostname

* try explicitly disabling test parallelism

* minitest

* fix compabitability with sidekiq < 7

* add explicit redis-client dependency

* update readme
  • Loading branch information
mattyr authored Nov 5, 2023
1 parent fd69461 commit cf0b032
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 150 deletions.
72 changes: 13 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,30 @@
name: CI

on: [push, pull_request]
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
ci:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
ruby-version:
- "2.4"
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- jruby-9.1
- jruby-9.2
- jruby-9.3
- "3.2"
- jruby-9.4
sidekiq-version:
- "3.5"
- "4.2"
- "5.1"
- "5.2"
- "6.0"
- "6.1"
- "6.2"
- "6.3"
- "6.4"
- "6.5"
- "7.0"
- "7.1"
- main
exclude:
# sidekiq 3.5 does not work with ruby >= 3
- ruby-version: "3.0"
sidekiq-version: "3.5"
- ruby-version: "3.1"
sidekiq-version: "3.5"
# sidekiq 6+ only supports ruby >= 2.5
- ruby-version: "2.4"
sidekiq-version: "6.0"
- ruby-version: "2.4"
sidekiq-version: "6.1"
- ruby-version: "2.4"
sidekiq-version: "6.2"
- ruby-version: "2.4"
sidekiq-version: "6.3"
- ruby-version: "2.4"
sidekiq-version: "6.4"
- ruby-version: "2.4"
sidekiq-version: "6.5"
- ruby-version: "2.4"
sidekiq-version: main
- ruby-version: jruby-9.1
sidekiq-version: "6.0"
- ruby-version: jruby-9.1
sidekiq-version: "6.1"
- ruby-version: jruby-9.1
sidekiq-version: "6.2"
- ruby-version: jruby-9.1
sidekiq-version: "6.3"
- ruby-version: jruby-9.1
sidekiq-version: "6.4"
- ruby-version: jruby-9.1
sidekiq-version: "6.5"
- ruby-version: jruby-9.1
sidekiq-version: main
services:
redis:
image: redis
Expand All @@ -72,20 +33,13 @@ jobs:
- 6379:6379
env:
sidekiq: ${{ matrix.sidekiq-version }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
timeout-minutes: 5
- name: Run tests
run: bundle exec rake
continue-on-error: ${{ matrix.sidekiq-version == 'main' }}
timeout-minutes: 5
- name: Report code coverage
if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.1' && matrix.sidekiq-version == '6.0' }}
continue-on-error: true
uses: paambaati/[email protected]
20 changes: 8 additions & 12 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
appraise "sidekiq-3.5" do
gem "sidekiq", "3.5.4"
appraise "sidekiq-6.4" do
gem "sidekiq", "~> 6.4.0"
end

appraise "sidekiq-4.2" do
gem "sidekiq", "4.2.10"
appraise "sidekiq-6.5" do
gem "sidekiq", "~> 6.5.0"
end

appraise "sidekiq-5.1" do
gem "sidekiq", "5.1.3"
appraise "sidekiq-7.0" do
gem "sidekiq", "~> 7.0.0"
end

appraise "sidekiq-5.2" do
gem "sidekiq", "5.2.7"
end

appraise "sidekiq-6.0" do
gem "sidekiq", "6.0.1"
appraise "sidekiq-7.1" do
gem "sidekiq", "~> 7.1.0"
end
7 changes: 0 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ sidekiq_dep =

gem 'sidekiq', sidekiq_dep

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2.2")
# rack >= 2.0 requires ruby >= 2.2.2
gem 'rack', '< 2.0'
# activejob >= 5 requires ruby >= 2.2.2
gem 'activejob', '< 5'
end

group :test do
gem "simplecov"
end
19 changes: 1 addition & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

[![CI](https://github.com/mattyr/sidecloq/actions/workflows/ci.yml/badge.svg)](https://github.com/mattyr/sidecloq/actions/workflows/ci.yml)
[![Gem Version](https://badge.fury.io/rb/sidecloq.svg)](https://badge.fury.io/rb/sidecloq)
[![Code Climate](https://codeclimate.com/github/mattyr/sidecloq/badges/gpa.svg)](https://codeclimate.com/github/mattyr/sidecloq)
[![Test Coverage](https://codeclimate.com/github/mattyr/sidecloq/badges/coverage.svg)](https://codeclimate.com/github/mattyr/sidecloq/coverage)

Recurring / Periodic / Scheduled / Cron job extension for
Expand All @@ -24,8 +23,6 @@ you.

Sidecloq is:

- **Lightweight:** Celluloid is not required. This coincides well with
Sidekiq 4/5, which no longer use Celluloid.
- **Clean:** Sidecloq leverages only the public API of Sidekiq, and does
not pollute the Sidekiq namespace.
- **Easy to deploy:** Sidecloq boots with all Sidekiq processes,
Expand All @@ -43,9 +40,7 @@ Add this line to your application's Gemfile:
gem 'sidecloq'
```

Tested on MRI > 2 and JRuby 9k. Basically, if you can run
Sidekiq, you can run Sidecloq. Note that Sidekiq >= 5 does not support
MRI ruby < 2.2.2.
Requires sidekiq version >= 6.4. MRI < 2.7 and jruby < 9.4 are not supported.

## Configuration

Expand Down Expand Up @@ -126,18 +121,6 @@ it's corresponding "Enqueue now" button.

![Sidecloq web ui extension screenshot](assets/screenshot.png)

## Notes

If you are running MRI < 2.2.2, you will need to make sure you are using
rack < 2.0. You can do this by adding:

```ruby
gem 'rack', '< 2.0'
```

To your app's Gemfile. (This will also keep you from using the 5.x
series of Sidekiq, as it requires MRI > 2.2.2).

## Contributing

Bug reports and pull requests are welcome.
Expand Down
12 changes: 9 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ task :web do
Sidekiq.configure_client do |config|
config.redis = {
url: 'redis://localhost:6379/0',
size: 1,
namespace: 'sidecloq'
size: 1
}
end

Expand All @@ -39,10 +38,17 @@ task :web do
include Sidekiq::Worker
end

require 'rack/server'
require 'rack/session/cookie'
require 'sidekiq/web'
require 'sidecloq/web'

Rack::Server.start(
app: Sidekiq::Web
app: Rack::Session::Cookie.new(
Sidekiq::Web,
secret: SecureRandom.hex(32),
same_site: true,
max_age: 86400
)
)
end
16 changes: 0 additions & 16 deletions gemfiles/sidekiq_6.0.gemfile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "sidekiq", "3.5.4"
gem "sidekiq", "~> 6.4.0"

group :test do
gem "simplecov"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "sidekiq", "4.2.10"
gem "sidekiq", "~> 6.5.0"

group :test do
gem "simplecov"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "sidekiq", "5.1.3"
gem "sidekiq", "~> 7.0.0"

group :test do
gem "simplecov"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "sidekiq", "5.2.7"
gem "sidekiq", "~> 7.1.0"

group :test do
gem "simplecov"
Expand Down
2 changes: 1 addition & 1 deletion lib/sidecloq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def self.extract_schedule

if File.exist?(options[:schedule_file])
return Schedule.from_yaml(options[:schedule_file])
elsif defined?(Rails)
elsif defined?(Rails::Engine)
# try rails-root-relative
full_path = File.join(Rails.root, options[:schedule_file])
if File.exist?(full_path)
Expand Down
7 changes: 7 additions & 0 deletions lib/sidecloq/locker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'redis-client'

module Sidecloq
# Locker obtains or waits for an exclusive lock on a key in redis
class Locker
Expand All @@ -8,6 +10,11 @@ class Locker
def initialize(options = {})
# we keep a connection from the pool by default
@redis = options[:redis] || Sidekiq.redis_pool.checkout
# for compatibility with sidekiq < 7, we need to convert the Redis
# instance to a RedisClient instance, which redlock requires
if defined?(Redis) && @redis.instance_of?(Redis)
@redis = RedisClient.new(@redis.connection.except(:location))
end
@key = options[:lock_key] || DEFAULT_LOCK_KEY
@ttl = options[:ttl] || 60
@check_interval = options[:check_interval] || 15
Expand Down
2 changes: 1 addition & 1 deletion lib/sidecloq/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def self.env
end

def self.rails_env
Rails.env if defined?(Rails)
Rails.env if defined?(Rails::Engine)
end

def self.rack_env
Expand Down
11 changes: 7 additions & 4 deletions sidecloq.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'sidekiq', '>= 3.5.4', '< 7'
spec.add_dependency 'redlock', '>= 0.2.0', '< 2'
spec.add_dependency 'sidekiq', '>= 6.0.0', '< 8'
spec.add_dependency 'redlock', '>= 2.0.0', '< 3'
# redlock needs redis-client
spec.add_dependency 'redis-client', '>= 0.14.0'
# mimics some dev dependencies of sidekiq:
spec.add_dependency 'concurrent-ruby'
spec.add_dependency 'rufus-scheduler', '~> 3.1', '>= 3.1.10'
spec.add_dependency 'rufus-scheduler', '~> 3.9'

spec.add_development_dependency 'rake', '>= 10.0'
spec.add_development_dependency 'minitest'
spec.add_development_dependency "appraisal"
spec.add_development_dependency 'redis-namespace', '~> 1.5', '>= 1.5.3'
spec.add_development_dependency 'activejob'
spec.add_development_dependency 'rack', '< 3'
spec.add_development_dependency 'webrick'
end
Loading

0 comments on commit cf0b032

Please sign in to comment.