sidekiq-cron 1.12.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aaa6af217265c4e60b29018b984b43a4316b2618e52ce874db670e41ecadf85b
4
- data.tar.gz: f70a50a90508ceb32bad90b8b2b6a880fb460f308dfa81f7380152742bb939cf
3
+ metadata.gz: 1d5f570d2d2d72cdb4fc1a2458dc6cae7abfa5a0da1f27915310b5d5dc835e89
4
+ data.tar.gz: 514d74f88c65af3db1956190ca9092d4f1a95d6bce4b0a9191463e2bb0f9181a
5
5
  SHA512:
6
- metadata.gz: ef95b33d15c1867a3dc6cc096080af6f2fab50c4460d8be24948bcd887c6c278dc3ca1a8c92db8d1ce386d24e0ceb95f53f6add336c3315fec04f808b7451475
7
- data.tar.gz: e30e02e3bcc13f8604426d5d9e5f30e24c46a85bfd7679544975a3bdfcc0510631d363ef041f948c8a51e289a02a222fd27bba572cf57ac1697aabb917673a01
6
+ metadata.gz: 61f4af041526789dcf51264baa88a5e1855fa124a0fe9f2c5ed04eec36bd4b617aae1152890ab281d5938914725ba9cce812f70bc258a6e4b8d82b642882212a
7
+ data.tar.gz: 9e82488bd6459b3ce373e52c94fc3607631b5fc67fa58e578d190368a09f4edc3b4502318646d5285e9fb9d139a080d90d560b28ad31a56e9d01d81d1dc0a2f8
data/CHANGELOG.md CHANGED
@@ -2,6 +2,48 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 2.1.0
6
+
7
+ - Add `available_namespaces` configuration option (https://github.com/sidekiq-cron/sidekiq-cron/pull/524)
8
+ - I18n fixes and enhancements (https://github.com/sidekiq-cron/sidekiq-cron/pull/520, https://github.com/sidekiq-cron/sidekiq-cron/pull/522)
9
+
10
+ ## 2.0.1
11
+
12
+ - Fix usage of ActiveJob::Base.queue_name (https://github.com/sidekiq-cron/sidekiq-cron/pull/517)
13
+ - Fix: Add quotes to Japanese translations containing multi-byte symbols (https://github.com/sidekiq-cron/sidekiq-cron/pull/515)
14
+
15
+ ## 2.0.0
16
+
17
+ Sidekiq-Cron v2 is here! In this release we refactored some internals, plus:
18
+
19
+ - Review web UI translations for all available locales (https://github.com/sidekiq-cron/sidekiq-cron/pull/506)
20
+ - Fix detection of ActiveJob in Sidekiq v7.3.3+ (https://github.com/sidekiq-cron/sidekiq-cron/pull/510)
21
+ - Add retry job configuration option to set Sidekiq retry job option (https://github.com/sidekiq-cron/sidekiq-cron/pull/509)
22
+
23
+ Please take a look to the RC1 and RC2 changes too if you are coming from the v1.X series.
24
+
25
+ ## 2.0.0.rc2
26
+
27
+ - Remove support for Sidekiq < 6.5 (https://github.com/sidekiq-cron/sidekiq-cron/pull/480)
28
+ - Require at least Fugit >= 1.11.1 (https://github.com/sidekiq-cron/sidekiq-cron/pull/475)
29
+ - Update how Redis values are stored on save (https://github.com/sidekiq-cron/sidekiq-cron/pull/479)
30
+ - Web extension: Add compatibility with Sidekiq 7.3+ and remove inline styles (https://github.com/sidekiq-cron/sidekiq-cron/pull/480)
31
+ - Remove support for old Redis (< 4.2) (https://github.com/sidekiq-cron/sidekiq-cron/pull/490)
32
+ - Ensure date_as_argument option can be set from true to false in Sidekiq Cron jobs (https://github.com/sidekiq-cron/sidekiq-cron/pull/485)
33
+ - Rename `enque!` to `enqueue!` (https://github.com/sidekiq-cron/sidekiq-cron/pull/494)
34
+ - Refactor gem configuration module (https://github.com/sidekiq-cron/sidekiq-cron/pull/495)
35
+
36
+ ## 2.0.0.rc1
37
+
38
+ - Introduce `Namespacing` (https://github.com/sidekiq-cron/sidekiq-cron/pull/268)
39
+ - Human readable cron format in UI (https://github.com/sidekiq-cron/sidekiq-cron/pull/445)
40
+ - Add Bahasa Indonesia locale (https://github.com/sidekiq-cron/sidekiq-cron/pull/446)
41
+ - Fetch queue name from ActiveJob class (https://github.com/sidekiq-cron/sidekiq-cron/pull/448)
42
+ - Allows symbol keys in `.load_from_array!` (https://github.com/sidekiq-cron/sidekiq-cron/pull/458)
43
+ - Add natural language parsing mode (https://github.com/sidekiq-cron/sidekiq-cron/pull/459)
44
+ - Add ability to configure the past scheduled time threshold (https://github.com/sidekiq-cron/sidekiq-cron/pull/465)
45
+ - Docs: clarify worker vs process terminology (https://github.com/sidekiq-cron/sidekiq-cron/issues/453)
46
+
5
47
  ## 1.12.0
6
48
 
7
49
  - Remove Sidekiq.server? check from schedule loader (https://github.com/sidekiq-cron/sidekiq-cron/pull/436)
@@ -61,7 +103,7 @@ All notable changes to this project will be documented in this file.
61
103
 
62
104
  ## 1.5.1
63
105
 
64
- - Fixes an issue that prevented the gem to work in previous Sidekiq versions (https://github.com/sidekiq-cron/sidekiq-cron/pull/335)
106
+ - Fixes an issue that prevented the gem to work in previous Sidekiq versions (https://github.com/sidekiq-cron/sidekiq-cron/pull/335)
65
107
 
66
108
  ## 1.5.0
67
109
 
@@ -156,6 +198,6 @@ All notable changes to this project will be documented in this file.
156
198
 
157
199
  ## 0.3.0
158
200
 
159
- - Suport for Active Job
201
+ - Support for Active Job
160
202
  - Sidekiq cron web ui needs to be loaded by: require 'sidekiq/cron/web'
161
203
  - Add load_from_hash! and load_from_array! which cleanup jobs before adding new ones
data/Gemfile CHANGED
@@ -4,3 +4,6 @@ gemspec
4
4
 
5
5
  # To test different Sidekiq versions
6
6
  gem "sidekiq", ENV.fetch("SIDEKIQ_VERSION", ">= 6")
7
+
8
+ # To test different Active Job versions
9
+ gem "activejob", ENV.fetch("ACTIVE_JOB_VERSION", "~> 7")
data/README.md CHANGED
@@ -1,25 +1,21 @@
1
1
  ![Sidekiq-Cron](logos/cover.png)
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/sidekiq-cron.svg)](https://badge.fury.io/rb/sidekiq-cron)
4
- [![Build Status](https://github.com/sidekiq-cron/sidekiq-cron/workflows/CI/badge.svg?branch=master)](https://github.com/sidekiq-cron/sidekiq-cron/actions)
4
+ [![CI](https://github.com/sidekiq-cron/sidekiq-cron/actions/workflows/ci.yml/badge.svg)](https://github.com/sidekiq-cron/sidekiq-cron/actions/workflows/ci.yml)
5
5
  [![codecov](https://codecov.io/gh/sidekiq-cron/sidekiq-cron/branch/master/graph/badge.svg?token=VK9IVLIaY8)](https://codecov.io/gh/sidekiq-cron/sidekiq-cron)
6
6
 
7
7
  > A scheduling add-on for [Sidekiq](https://sidekiq.org/)
8
8
 
9
9
  🎬 [Introduction video about Sidekiq-Cron by Drifting Ruby](https://www.driftingruby.com/episodes/periodic-tasks-with-sidekiq-cron)
10
10
 
11
- Sidekiq-Cron runs a thread alongside Sidekiq workers to schedule jobs at specified times (using cron notation `* * * * *` parsed by [Fugit](https://github.com/floraison/fugit)).
11
+ Sidekiq-Cron runs a thread alongside Sidekiq workers to schedule jobs at specified times (using cron notation `* * * * *` or natural language, powered by [Fugit](https://github.com/floraison/fugit)).
12
12
 
13
- Checks for new jobs to schedule every 30 seconds and doesn't schedule the same job multiple times when more than one Sidekiq worker is running.
13
+ Checks for new jobs to schedule every 30 seconds and doesn't schedule the same job multiple times when more than one Sidekiq process is running.
14
14
 
15
15
  Scheduling jobs are added only when at least one Sidekiq process is running, but it is safe to use Sidekiq-Cron in environments where multiple Sidekiq processes or nodes are running.
16
16
 
17
17
  If you want to know how scheduling work, check out [under the hood](#under-the-hood).
18
18
 
19
- Works with ActiveJob (Rails 4.2+).
20
-
21
- You don't need Sidekiq PRO, you can use this gem with plain Sidekiq.
22
-
23
19
  ## Changelog
24
20
 
25
21
  Before upgrading to a new version, please read our [Changelog](CHANGELOG.md).
@@ -51,18 +47,40 @@ gem "sidekiq-cron"
51
47
  'cron' => '1 * * * *', # execute at 1 minute of every hour, ex: 12:01, 13:01, 14:01, ...
52
48
  'class' => 'MyClass',
53
49
  # OPTIONAL
50
+ 'namespace' => 'YourNamespace', # groups jobs together in a namespace (Default value is 'default'),
54
51
  'source' => 'dynamic', # source of the job, `schedule`/`dynamic` (default: `dynamic`)
55
52
  'queue' => 'name of queue',
53
+ 'retry' => '5', # Sidekiq (not supported by ActiveJob) number of retries, or false to discard on first failure
56
54
  'args' => '[Array or Hash] of arguments which will be passed to perform method',
57
55
  'date_as_argument' => true, # add the time of execution as last argument of the perform method
58
- 'active_job' => true, # enqueue job through Rails 4.2+ Active Job interface
59
- 'queue_name_prefix' => 'prefix', # Rails 4.2+ Active Job queue with prefix
60
- 'queue_name_delimiter' => '.', # Rails 4.2+ Active Job queue with custom delimiter (default: '_')
56
+ 'active_job' => true, # enqueue job through Active Job interface
57
+ 'queue_name_prefix' => 'prefix', # Active Job queue with prefix
58
+ 'queue_name_delimiter' => '.', # Active Job queue with custom delimiter (default: '_')
61
59
  'description' => 'A sentence describing what work this job performs'
62
60
  'status' => 'disabled' # default: enabled
63
61
  }
64
62
  ```
65
63
 
64
+ **NOTE** The `status` of a job does not get changed in Redis when a job gets reloaded unless the `status` property is explicitly set.
65
+
66
+ ### Configuration
67
+
68
+ All configuration options:
69
+
70
+ ```ruby
71
+ Sidekiq::Cron.configure do |config|
72
+ config.cron_poll_interval = 10 # Default is 30
73
+ config.cron_schedule_file = 'config/my_schedule.yml' # Default is 'config/schedule.yml'
74
+ config.cron_history_size = 20 # Default is 10
75
+ config.default_namespace = 'statistics' # Default is 'default'
76
+ config.natural_cron_parsing_mode = :strict # Default is :single
77
+ config.reschedule_grace_period = 300 # Default is 60
78
+ config.available_namespaces = %w[maintenance billing] # Default is `nil`
79
+ end
80
+ ```
81
+
82
+ If you are using Rails, you should add the above block inside an initializer (`config/initializers/sidekiq-cron.rb`).
83
+
66
84
  ### Time, cron and Sidekiq-Cron
67
85
 
68
86
  For testing your cron notation you can use [crontab.guru](https://crontab.guru).
@@ -76,18 +94,50 @@ like this `'0 22 * * 1-5 America/Chicago'`.
76
94
 
77
95
  #### Natural-language formats
78
96
 
79
- Since sidekiq-cron `v1.7.0`, you can use the natural-language formats supported by Fugit, such as:
97
+ Since Sidekiq-Cron `v1.7.0`, you can use the natural-language formats supported by Fugit, such as:
80
98
 
81
- ```rb
99
+ ```ruby
82
100
  "every day at five" # => '0 5 * * *'
83
101
  "every 3 hours" # => '0 */3 * * *'
84
102
  ```
85
103
 
86
104
  See [the relevant part of Fugit documentation](https://github.com/floraison/fugit#fugitnat) for details.
87
105
 
106
+ There are multiple modes that determine how natural-language cron strings will be parsed.
107
+
108
+ 1. `:single` (default)
109
+
110
+ ```ruby
111
+ Sidekiq::Cron.configure do |config|
112
+ # Note: This doesn't need to be specified since it's the default.
113
+ config.natural_cron_parsing_mode = :single
114
+ end
115
+ ```
116
+
117
+ This parses the first possible cron line from the given string and then ignores any additional cron lines.
118
+
119
+ Ex. `every day at 3:15 and 4:30`
120
+
121
+ - Equivalent to `15 3 * * *`.
122
+ - `30 4 * * *` gets ignored.
123
+
124
+ 2. `:strict`
125
+
126
+ ```ruby
127
+ Sidekiq::Cron.configure do |config|
128
+ config.natural_cron_parsing_mode = :strict
129
+ end
130
+ ```
131
+
132
+ This throws an error if the given string would be parsed into multiple cron lines.
133
+
134
+ Ex. `every day at 3:15 and 4:30`
135
+
136
+ - Would throw an error and the associated cron job would be invalid
137
+
88
138
  #### Second-precision (sub-minute) cronlines
89
139
 
90
- In addition to the standard 5-parameter cronline format, sidekiq-cron supports scheduling jobs with second-precision using a modified 6-parameter cronline format:
140
+ In addition to the standard 5-parameter cronline format, Sidekiq-Cron supports scheduling jobs with second-precision using a modified 6-parameter cronline format:
91
141
 
92
142
  `Seconds Minutes Hours Days Months DayOfWeek`
93
143
 
@@ -96,11 +146,83 @@ For example: `"*/30 * * * * *"` would schedule a job to run every 30 seconds.
96
146
  Note that if you plan to schedule jobs with second precision you may need to override the default schedule poll interval so it is lower than the interval of your jobs:
97
147
 
98
148
  ```ruby
99
- Sidekiq::Options[:cron_poll_interval] = 10
149
+ Sidekiq::Cron.configure do |config|
150
+ config.cron_poll_interval = 10
151
+ end
100
152
  ```
101
153
 
102
154
  The default value at time of writing is 30 seconds. See [under the hood](#under-the-hood) for more details.
103
155
 
156
+ ### Namespacing
157
+
158
+ #### Default namespace
159
+
160
+ When not giving a namespace, the `default` one will be used.
161
+
162
+ In the case you'd like to change this value, you can change it via the following configuration flag:
163
+
164
+ ```ruby
165
+ Sidekiq::Cron.configure do |config|
166
+ config.default_namespace = 'statics'
167
+ end
168
+ ```
169
+
170
+ #### Renaming namespace
171
+
172
+ If you rename the namespace of a job that is already running, the gem will not automatically delete the cron job associated with the old namespace. This means you could end up with two cron jobs running simultaneously.
173
+
174
+ To avoid this, it is recommended to delete all existing cron jobs associated with the old namespace before making the change. You can achieve this with the following code:
175
+
176
+ ```ruby
177
+ Sidekiq::Cron::Job.all('YOUR_OLD_NAMESPACE_NAME').each { |job| job.destroy }
178
+ ```
179
+
180
+ #### Available namespaces
181
+
182
+ By default, Sidekiq Cron retrieves all existing jobs from Redis to determine the namespaces your application uses. However, this approach may not be suitable for large Redis installations. To address this, you can explicitly specify the list of available namespaces using the `available_namespaces` configuration option.
183
+
184
+ If `available_namespaces` is set and a job is created with an unexpected namespace, a warning will be printed, and the job will be assigned to the default namespace.
185
+
186
+ For more details and discussion, see [this issue](https://github.com/sidekiq-cron/sidekiq-cron/issues/516).
187
+
188
+ #### Usage
189
+
190
+ When creating a new job, you can optionally give a `namespace` attribute, and then you can pass it too in the `find` or `destroy` methods.
191
+
192
+ ```ruby
193
+ Sidekiq::Cron::Job.create(
194
+ name: 'Hard worker - every 5min',
195
+ namespace: 'Foo',
196
+ cron: '*/5 * * * *',
197
+ class: 'HardWorker'
198
+ )
199
+ # INFO: Cron Jobs - add job with name Hard worker - every 5min in the namespace Foo
200
+
201
+ # Without specifying the namespace, Sidekiq::Cron use the `default` one, therefore `count` return 0.
202
+ Sidekiq::Cron::Job.count
203
+ #=> 0
204
+
205
+ # Searching in the job's namespace returns 1.
206
+ Sidekiq::Cron::Job.count 'Foo'
207
+ #=> 1
208
+
209
+ # Same applies to `all`. Without a namespace, no jobs found.
210
+ Sidekiq::Cron::Job.all
211
+
212
+ # But giving the job's namespace returns it.
213
+ Sidekiq::Cron::Job.all 'Foo'
214
+ #=> [#<Sidekiq::Cron::Job:0x00007f7848a326a0 ... @name="Hard worker - every 5min", @namespace="Foo", @cron="*/5 * * * *", @klass="HardWorker", @status="enabled" ... >]
215
+
216
+ # If you'd like to get all the jobs across all the namespaces then pass an asterisk:
217
+ Sidekiq::Cron::Job.all '*'
218
+ #=> [#<Sidekiq::Cron::Job ...>]
219
+
220
+ job = Sidekiq::Cron::Job.find('Hard worker - every 5min', 'Foo').first
221
+ job.destroy
222
+ # INFO: Cron Jobs - deleted job with name Hard worker - every 5min from namespace Foo
223
+ #=> true
224
+ ```
225
+
104
226
  ### What objects/classes can be scheduled
105
227
 
106
228
  #### Sidekiq Worker
@@ -117,7 +239,9 @@ class HardWorker
117
239
  end
118
240
  ```
119
241
 
120
- #### Active Job Worker
242
+ For Sidekiq workers, `symbolize_args: true` in `Sidekiq::Cron::Job.create` or in Hash configuration is gonna be ignored as Sidekiq currently only allows for [simple JSON datatypes](https://github.com/sidekiq/sidekiq/wiki/The-Basics#:~:text=These%20two%20methods,not%20serialize%20properly.).
243
+
244
+ #### Active Job
121
245
 
122
246
  You can schedule `ExampleJob` which looks like:
123
247
 
@@ -131,10 +255,10 @@ class ExampleJob < ActiveJob::Base
131
255
  end
132
256
  ```
133
257
 
134
- For Active jobs you can use `symbolize_args: true` in `Sidekiq::Cron::Job.create` or in Hash configuration,
258
+ For Active Job you can use `symbolize_args: true` in `Sidekiq::Cron::Job.create` or in Hash configuration,
135
259
  which will ensure that arguments you are passing to it will be symbolized when passed back to `perform` method in worker.
136
260
 
137
- #### Adding Cron job
261
+ ### Adding Cron jobs
138
262
 
139
263
  Refer to [Schedule vs Dynamic jobs](#schedule-vs-dynamic-jobs) to understand the difference.
140
264
 
@@ -168,9 +292,9 @@ unless job.save
168
292
  end
169
293
  ```
170
294
 
171
- Use ActiveRecord models as arguments
295
+ Use ActiveRecord models as arguments:
172
296
 
173
- ```rb
297
+ ```ruby
174
298
  class Person < ApplicationRecord
175
299
  end
176
300
 
@@ -182,7 +306,6 @@ class HardWorker < ActiveJob::Base
182
306
  end
183
307
  end
184
308
 
185
-
186
309
  person = Person.create(id: 1)
187
310
  Sidekiq::Cron::Job.create(name: 'Hard worker - every 5min', cron: '*/5 * * * *', class: 'HardWorker', args: person)
188
311
  # => true
@@ -233,7 +356,9 @@ Sidekiq::Cron::Job.load_from_hash! hash
233
356
  Sidekiq::Cron::Job.load_from_array! array
234
357
  ```
235
358
 
236
- Or from YAML (same notation as Resque-scheduler):
359
+ ### Loading jobs from schedule file
360
+
361
+ You can also load multiple jobs from a YAML file:
237
362
 
238
363
  ```yaml
239
364
  # config/schedule.yml
@@ -254,24 +379,31 @@ second_job:
254
379
  There are multiple ways to load the jobs from a YAML file
255
380
 
256
381
  1. The gem will automatically load the jobs mentioned in `config/schedule.yml` file (it supports ERB)
257
- 2. When you want to load jobs from a different filename, mention the filename in sidekiq configuration, i.e. `cron_schedule_file: "config/users_schedule.yml"`
382
+ 2. When you want to load jobs from a different filename, mention the filename in Sidekiq configuration as follows:
383
+
384
+ ```ruby
385
+ Sidekiq::Cron.configure do |config|
386
+ config.cron_schedule_file = "config/users_schedule.yml"
387
+ end
388
+ ```
389
+
258
390
  3. Load the file manually as follows:
259
391
 
260
- ```ruby
261
- # config/initializers/sidekiq.rb
392
+ ```ruby
393
+ # config/initializers/sidekiq.rb
262
394
 
263
- Sidekiq.configure_server do |config|
264
- config.on(:startup) do
265
- schedule_file = "config/users_schedule.yml"
395
+ Sidekiq.configure_server do |config|
396
+ config.on(:startup) do
397
+ schedule_file = "config/users_schedule.yml"
266
398
 
267
- if File.exist?(schedule_file)
268
- schedule = YAML.load_file(schedule_file)
399
+ if File.exist?(schedule_file)
400
+ schedule = YAML.load_file(schedule_file)
269
401
 
270
- Sidekiq::Cron::Job.load_from_hash!(schedule, source: "schedule")
402
+ Sidekiq::Cron::Job.load_from_hash!(schedule, source: "schedule")
403
+ end
404
+ end
271
405
  end
272
- end
273
- end
274
- ```
406
+ ```
275
407
 
276
408
  ### Finding jobs
277
409
 
@@ -317,7 +449,7 @@ job.status
317
449
  # => enabled/disabled
318
450
 
319
451
  # enqueue job right now!
320
- job.enque!
452
+ job.enqueue!
321
453
  ```
322
454
 
323
455
  ### Schedule vs Dynamic jobs
@@ -356,12 +488,28 @@ Sidekiq-Cron adds itself into this start procedure and starts another thread wit
356
488
  Sidekiq-Cron is checking jobs to be enqueued every 30s by default, you can change it by setting:
357
489
 
358
490
  ```ruby
359
- Sidekiq::Options[:cron_poll_interval] = 10
491
+ Sidekiq::Cron.configure do |config|
492
+ config.cron_poll_interval = 10
493
+ end
494
+ ```
495
+
496
+ When Sidekiq (and Sidekiq-Cron) is not used in zero-downtime deployments, after the deployment is done Sidekiq-Cron starts to catch up. It will consider older jobs that missed their schedules during that time. By default, only jobs that should have started less than 1 minute ago are considered. This is problematic for some jobs, e.g., jobs that run once a day. If on average Sidekiq is shut down for 10 minutes during deployments, you can configure Sidekiq-Cron to consider jobs that were about to be scheduled during that time:
497
+
498
+ ```ruby
499
+ Sidekiq::Cron.configure do |config|
500
+ config.reschedule_grace_period = 600 # 10 minutes in seconds
501
+ end
360
502
  ```
361
503
 
362
504
  Sidekiq-Cron is safe to use with multiple Sidekiq processes or nodes. It uses a Redis sorted set to determine that only the first process who asks can enqueue scheduled jobs into the queue.
363
505
 
364
- When running with many Sidekiq processes, the polling can add significant load to Redis. You can disable polling on some processes by setting `Sidekiq::Options[:cron_poll_interval] = 0` on these processes.
506
+ When running with many Sidekiq processes, the polling can add significant load to Redis. You can disable polling on some processes by setting:
507
+
508
+ ```ruby
509
+ Sidekiq::Cron.configure do |config|
510
+ config.cron_poll_interval = 0
511
+ end
512
+ ```
365
513
 
366
514
  ## Contributing
367
515
 
@@ -383,6 +531,39 @@ You can execute the test suite by running:
383
531
  $ bundle exec rake test
384
532
  ```
385
533
 
534
+ ### Using Docker
535
+
536
+ This project uses [Docker Compose](https://docs.docker.com/compose/) in order to orchestrate containers and get the test suite running on you local machine, and here you find the commands to run in order to get a complete environment to build and test this gem:
537
+
538
+ 1. Build the Docker image (only the first time):
539
+ ```
540
+ docker compose -f docker/docker-compose.yml build
541
+ ```
542
+
543
+ 2. Run the test suite:
544
+ ```
545
+ docker compose -f docker/docker-compose.yml run --rm tests
546
+ ```
547
+
548
+ _This command will download the first time the project's dependencies (Redis so far), create the containers and run the default command to run the tests._
549
+
550
+ **Running other commands**
551
+
552
+ In the case you need to run a command in the gem's container, you would do it like so:
553
+
554
+ ```
555
+ docker compose -f docker/docker-compose.yml run --rm tests <HERE IS YOUR COMMAND>
556
+ ```
557
+ _Note that `tests` is the Docker Compose service name defined in the `docker/docker-compose.yml` file._
558
+
559
+ **Running a single test file**
560
+
561
+ Given you only want to run the tests from the `test/unit/web_extension_test.rb` file, you need to pass its path with the `TEST` env variable, so here is the command:
562
+
563
+ ```
564
+ docker compose -f docker/docker-compose.yml run --rm --env TEST=test/unit/web_extension_test.rb tests
565
+ ```
566
+
386
567
  ## License
387
568
 
388
569
  Copyright (c) 2013 Ondrej Bartas. See [LICENSE](LICENSE.txt) for further details.