Skip to content

Commit 1579b42

Browse files
authored
update tests (#3)
* update tests * matrix cleanup * add integration tests * test our branch * debug * move integration test out * update readme, gem name
1 parent 79942cb commit 1579b42

8 files changed

+69
-38
lines changed

.github/workflows/ci.yml

+19-11
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,34 @@ jobs:
1818
--health-retries 5
1919
ports:
2020
# Maps port 6379 on service container to the host
21-
- '6379:6379'
21+
- "6379:6379"
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
ruby-version: ['2.7', '3.0', '3.1', '3.2']
26-
gemfile: ['Gemfile', 'Gemfile.redis3', 'Gemfile.redis4']
25+
ruby-version:
26+
- "3.0"
27+
- "3.1"
28+
- "3.2"
29+
- "3.3"
30+
resque-version:
31+
- "~> 1.23"
32+
redis-version:
33+
- "~> 3.3"
34+
- "~> 4.8"
2735
env:
28-
# $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
29-
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
36+
REDIS_VERSION: "${{ matrix.redis-version }}"
37+
RESQUE: "${{ matrix.resque-version }}"
38+
# The hostname used to communicate with the Redis service container
39+
REDIS_TEST_HOST: localhost
40+
# The default Redis port
41+
REDIS_TEST_PORT: 6379
3042
steps:
31-
- uses: actions/checkout@v3
43+
- uses: actions/checkout@v4
3244
- name: Set up Ruby ${{ matrix.ruby-version }}
3345
uses: ruby/setup-ruby@v1
3446
with:
3547
ruby-version: ${{ matrix.ruby-version }}
3648
bundler-cache: true
3749
- name: Run tests
38-
env:
39-
# The hostname used to communicate with the Redis service container
40-
REDIS_TEST_HOST: localhost
41-
# The default Redis port
42-
REDIS_TEST_PORT: 6379
4350
run: bundle exec rake
51+

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ coverage/
77
.bundle/
88
dump.rdb
99
stdout
10+
.vscode

Gemfile

+25
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
11
source 'https://rubygems.org'
2+
3+
case resque_version = ENV.fetch('RESQUE', 'latest')
4+
when 'master'
5+
gem 'resque', git: 'https://github.com/resque/resque'
6+
when /^git:/, /^https:/
7+
gem 'resque', git: resque_version
8+
when 'latest'
9+
gem 'resque'
10+
else
11+
versions = resque_version.split(',')
12+
gem 'resque', *versions
13+
end
14+
15+
case redis_version = ENV.fetch('REDIS_VERSION', 'latest')
16+
when 'master'
17+
gem 'redis', git: 'https://github.com/redis/redis-rb'
18+
when /^git:/, /^https:/
19+
gem 'redis', git: redis_version
20+
when 'latest'
21+
gem 'redis'
22+
else
23+
versions = redis_version.split(',')
24+
gem 'redis', *versions
25+
end
26+
227
gemspec

Gemfile.redis3

-5
This file was deleted.

Gemfile.redis4

-5
This file was deleted.

README.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Resque Lock Timeout
22

3-
A [Resque][rq] plugin. Requires Resque ~> 1.23.
3+
A [Resque][rq] plugin. Requires Resque ~> 1.23, redis-rb >= 3.3, < 5.
4+
5+
This is a fork of [resque-lock-timeout][resque-lock-timeout] with testing and other fixes applied.
6+
7+
----------
48

59
resque-lock-timeout adds locking, with optional timeout/deadlock handling to resque jobs.
610

@@ -56,7 +60,7 @@ end
5660

5761
The locking algorithm used can be found in the [Redis SETNX][redis-setnx] documentation.
5862

59-
Simply set the lock timeout in seconds, e.g.
63+
Set the lock timeout in seconds, e.g.
6064

6165
```ruby
6266
class UpdateNetworkGraph
@@ -76,9 +80,9 @@ end
7680

7781
### Job Identifier/Lock Key
7882

79-
By default the key uses this format: `lock:<job class name>:<identifier>`.
83+
By default, the key uses this format: `lock:<job class name>:<identifier>`.
8084

81-
The default identifier is just your job arguments joined with a dash `-`.
85+
The default identifier is your job arguments joined with a dash `-`.
8286

8387
If you have a lot of arguments or really long ones, you should consider overriding `identifier` to define a more precise or loose custom identifier:
8488

@@ -123,7 +127,7 @@ That would use the key `lock:updates`.
123127

124128
### Redis Connection Used for Locking
125129

126-
By default all locks are stored via Resque's redis connection. If you wish to change this you may override `lock_redis`.
130+
By default, all locks are stored via Resque's redis connection. If you wish to change this you may override `lock_redis`.
127131

128132
```ruby
129133
class UpdateNetworkGraph
@@ -165,7 +169,7 @@ end
165169
- `enqueued?` - checks if the loner lock is currently held.
166170
- `loner_locked?` - checks if the job is either enqueued (if a loner) or locked (any job).
167171
- `refresh_lock!` - Refresh the lock, useful for jobs that are taking longer
168-
then usual but your okay with them holding on to the lock a little longer.
172+
then usual but you're okay with them holding on to the lock a little longer.
169173

170174
### Callbacks
171175

@@ -221,3 +225,4 @@ Forked from [a little tinkering from Luke Antins](https://github.com/lantins/res
221225
[redis-setnx]: http://redis.io/commands/setnx
222226
[resque-lock]: http://github.com/defunkt/resque-lock
223227
[resque-lock-retry]: http://github.com/rcarver/resque-lock-retry
228+
[resque-lock-timeout]: https://github.com/lantins/resque-lock-timeout

resque-lock-timeout.gemspec

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
2-
s.name = "resque-lock-timeout"
3-
s.version = "0.5.0"
2+
s.name = "ibotta-resque-lock-timeout"
3+
s.version = "0.5.1"
44
s.date = Time.now.strftime("%Y-%m-%d")
55
s.summary = "A Resque plugin adding locking, with optional timeout/deadlock handling to resque jobs."
66
s.license = "MIT"
@@ -14,19 +14,21 @@ Gem::Specification.new do |s|
1414

1515
s.add_dependency("resque", "~> 1.23")
1616
s.add_dependency("redis", ">= 3.3", "< 5")
17+
1718
s.add_development_dependency("rake")
1819
s.add_development_dependency("minitest")
1920
s.add_development_dependency("yard")
2021
s.add_development_dependency("simplecov")
22+
s.add_development_dependency("debug")
2123

22-
s.description = <<DESC
23-
A Resque plugin. Adds locking, with optional timeout/deadlock handling to
24-
resque jobs.
24+
s.description = <<-DESC
25+
A Resque plugin. Adds locking, with optional timeout/deadlock handling to
26+
resque jobs.
2527
26-
Using a `lock_timeout` allows you to re-acquire the lock should your worker
27-
fail, crash, or is otherwise unable to relase the lock.
28+
Using a `lock_timeout` allows you to re-acquire the lock should your worker
29+
fail, crash, or is otherwise unable to relase the lock.
2830
29-
i.e. Your server unexpectedly loses power. Very handy for jobs that are
30-
recurring or may be retried.
31-
DESC
31+
i.e. Your server unexpectedly loses power. Very handy for jobs that are
32+
recurring or may be retried.
33+
DESC
3234
end

test/lock_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_resque_plugin_lint
1313
end
1414

1515
def test_version
16-
major, minor, _patch = Resque::Version.split(".")
16+
major, minor, _patch = Resque::VERSION.split(".")
1717
assert_equal 1, major.to_i
1818
assert minor.to_i >= 7
1919
end

0 commit comments

Comments
 (0)