deploy_pin 1.7.6 → 1.7.7
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 +4 -4
- data/README.md +21 -0
- data/lib/deploy_pin/collector.rb +10 -1
- data/lib/deploy_pin/version.rb +1 -1
- data/lib/deploy_pin.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 524fa7d4e78224d393bf12ce1dc483a657a3e21f6bfe3d09c041f165be385082
|
|
4
|
+
data.tar.gz: dde01336587e779b9056a82f7ed983ee644bcab058930b6c39218b0dcfb76ac3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69d65171dfd4ba1fcdee65769b0bdc181a9375a2b3a76f900fbc4faea36056f1164364143917e75ba7569bbbd528a2036bb525f9979cc2af17ae0c7d0bf60680
|
|
7
|
+
data.tar.gz: 1912162855e042a1177fe0cfb40446eefbc569f8615ae9dc303fd91267452a158c18cd43706d1ddf7291bdcd647ae1e13b5d83b43f18d44e7b8e102537f4b872
|
data/README.md
CHANGED
|
@@ -257,6 +257,27 @@ Around the deployment
|
|
|
257
257
|
bundle exec rake deploy_pin:run[I, II, III] - # enters to ongoing state before "I" and leaves it after "III" so all tasks in I, II, III have DeployPin.ongoing_deployment? == true
|
|
258
258
|
bundle exec rake deploy_pin:run[rollback] - # enters "pending state"
|
|
259
259
|
```
|
|
260
|
+
## Continue on Error
|
|
261
|
+
|
|
262
|
+
By default, if a task raises an error, the entire deploy pin run is aborted. You can configure `continue_on_error` to rescue failures, log them, and still mark the task as done. This is useful in CI environments where external services may be unavailable.
|
|
263
|
+
|
|
264
|
+
```ruby
|
|
265
|
+
# config/initializers/deploy_pin.rb
|
|
266
|
+
DeployPin.setup do
|
|
267
|
+
continue_on_error true
|
|
268
|
+
end
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Or conditionally via environment variable:
|
|
272
|
+
|
|
273
|
+
```ruby
|
|
274
|
+
DeployPin.setup do
|
|
275
|
+
continue_on_error ENV.fetch("DEPLOY_PIN_CONTINUE_ON_ERROR", "false") == "true"
|
|
276
|
+
end
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
When enabled, failed tasks will log the error and continue to the next task without halting execution.
|
|
280
|
+
|
|
260
281
|
## Similar Gems
|
|
261
282
|
- https://github.com/ilyakatz/data-migrate
|
|
262
283
|
- https://github.com/Shopify/maintenance_tasks
|
data/lib/deploy_pin/collector.rb
CHANGED
|
@@ -68,7 +68,7 @@ module DeployPin
|
|
|
68
68
|
|
|
69
69
|
# run if executable
|
|
70
70
|
if executable
|
|
71
|
-
duration = execution_duration {
|
|
71
|
+
duration = execution_duration { run_task_safely(task) }
|
|
72
72
|
DeployPin.run_formatter.call(index, tasks.count, task, executable, false, duration)
|
|
73
73
|
end
|
|
74
74
|
|
|
@@ -77,6 +77,15 @@ module DeployPin
|
|
|
77
77
|
# :reek:TooManyStatements
|
|
78
78
|
# :reek:FeatureEnvy
|
|
79
79
|
|
|
80
|
+
def run_task_safely(task)
|
|
81
|
+
run_with_timeout(task) { task.run }
|
|
82
|
+
rescue StandardError => e
|
|
83
|
+
raise unless DeployPin.continue_on_error
|
|
84
|
+
|
|
85
|
+
DeployPin::Runner.print("[DeployPin] Task #{task.identifier} failed: #{e.message}".red)
|
|
86
|
+
DeployPin::Runner.print('[DeployPin] Continuing due to continue_on_error configuration'.yellow)
|
|
87
|
+
end
|
|
88
|
+
|
|
80
89
|
# :reek:UtilityFunction
|
|
81
90
|
def files
|
|
82
91
|
Dir["#{DeployPin.tasks_path}/*.rb"]
|
data/lib/deploy_pin/version.rb
CHANGED
data/lib/deploy_pin.rb
CHANGED
|
@@ -15,6 +15,7 @@ require 'colorize'
|
|
|
15
15
|
|
|
16
16
|
module DeployPin
|
|
17
17
|
OPTIONS = %i[
|
|
18
|
+
continue_on_error
|
|
18
19
|
deployment_state_transition
|
|
19
20
|
fallback_group
|
|
20
21
|
groups
|
|
@@ -27,13 +28,14 @@ module DeployPin
|
|
|
27
28
|
].freeze
|
|
28
29
|
|
|
29
30
|
DEFAULTS = {
|
|
31
|
+
continue_on_error: false,
|
|
30
32
|
task_wrapper: ->(_task, task_runner) { task_runner.call }
|
|
31
33
|
}.freeze
|
|
32
34
|
|
|
33
35
|
OPTIONS.each do |option|
|
|
34
36
|
instance_eval %{
|
|
35
37
|
def #{option}(val = nil)
|
|
36
|
-
return @#{option}
|
|
38
|
+
return @#{option} if val.nil?
|
|
37
39
|
|
|
38
40
|
@#{option} = val
|
|
39
41
|
end
|