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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '04533880b9157ac1f1d494d73b548c3e72ee4be5ede6123a6f42fbdf4d896b44'
4
- data.tar.gz: 0f66c64807d0af17f219f5129ba1427a1307f477c9d1e005265335c64962406d
3
+ metadata.gz: 524fa7d4e78224d393bf12ce1dc483a657a3e21f6bfe3d09c041f165be385082
4
+ data.tar.gz: dde01336587e779b9056a82f7ed983ee644bcab058930b6c39218b0dcfb76ac3
5
5
  SHA512:
6
- metadata.gz: 436ed2a59bc9af20add804759c95fa5835e330a2468b5d5257941cc478dc7f714b832bb7fe289cc0fbd068cb0050aa7e00f9995b2cdc7fb5146eb479e6eae42e
7
- data.tar.gz: e3b6493cf98ec3d13548faa56005fb7807f120bba4d317eed9b3d628b7ceee70c422d1317458ac3c7811126adace3be4579acdb34463ccd0697f397b9caca5cd
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
@@ -68,7 +68,7 @@ module DeployPin
68
68
 
69
69
  # run if executable
70
70
  if executable
71
- duration = execution_duration { run_with_timeout(task) { task.run } }
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"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeployPin
4
- VERSION = '1.7.6'
4
+ VERSION = '1.7.7'
5
5
  end
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} unless val.present?
38
+ return @#{option} if val.nil?
37
39
 
38
40
  @#{option} = val
39
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deploy_pin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.6
4
+ version: 1.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Sych