deploy_pin 1.7.5 → 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 +29 -1
- data/lib/deploy_pin/collector.rb +20 -3
- data/lib/deploy_pin/runner.rb +4 -0
- data/lib/deploy_pin/task.rb +6 -2
- data/lib/deploy_pin/version.rb +1 -1
- data/lib/deploy_pin.rb +3 -1
- data/lib/tasks/deploy_pin_tasks.rake +7 -0
- metadata +2 -2
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
|
@@ -226,6 +226,13 @@ rails g deploy_pin:task some_task_title --recurring --identifier 5
|
|
|
226
226
|
rails g deploy_pin:task some_task_title --parallel --recurring --identifier 5
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
+
## Mark Tasks as Done
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
rake deploy_pin:mark_done['identifier_1, identifier_2'] # marks specific tasks as done
|
|
233
|
+
rake deploy_pin:mark_done # marks all tasks as done. useful in seed file
|
|
234
|
+
```
|
|
235
|
+
|
|
229
236
|
## DeploymentStateTrack
|
|
230
237
|
In the initializer
|
|
231
238
|
```ruby
|
|
@@ -250,6 +257,27 @@ Around the deployment
|
|
|
250
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
|
|
251
258
|
bundle exec rake deploy_pin:run[rollback] - # enters "pending state"
|
|
252
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
|
+
|
|
253
281
|
## Similar Gems
|
|
254
282
|
- https://github.com/ilyakatz/data-migrate
|
|
255
283
|
- https://github.com/Shopify/maintenance_tasks
|
|
@@ -275,7 +303,7 @@ To ensure your changes meet the required standards and pass all tests before sub
|
|
|
275
303
|
Use the following command to simulate the workflow locally:
|
|
276
304
|
|
|
277
305
|
```bash
|
|
278
|
-
act pull_request --secret-file .env --container-architecture linux/amd64 -W .github/workflows -j
|
|
306
|
+
act pull_request --secret-file .env --container-architecture linux/amd64 -W .github/workflows -j test
|
|
279
307
|
```
|
|
280
308
|
|
|
281
309
|
This command does the following:
|
data/lib/deploy_pin/collector.rb
CHANGED
|
@@ -11,7 +11,6 @@ module DeployPin
|
|
|
11
11
|
|
|
12
12
|
# :reek:TooManyStatements
|
|
13
13
|
def run
|
|
14
|
-
# cache tasks
|
|
15
14
|
tasks = init_tasks
|
|
16
15
|
tasks.each_with_index do |task, index|
|
|
17
16
|
DeployPin.task_wrapper.call(task, -> { process(tasks, task, index) })
|
|
@@ -34,8 +33,17 @@ module DeployPin
|
|
|
34
33
|
end
|
|
35
34
|
end
|
|
36
35
|
|
|
36
|
+
# :reek:FeatureEnvy
|
|
37
|
+
def mark_done
|
|
38
|
+
tasks = init_tasks
|
|
39
|
+
tasks.each do |task|
|
|
40
|
+
task.prepare
|
|
41
|
+
task.mark
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
# :reek:FeatureEnvy
|
|
45
|
+
|
|
37
46
|
def executable
|
|
38
|
-
# cache tasks
|
|
39
47
|
tasks = init_tasks
|
|
40
48
|
tasks.map.with_index do |task, index|
|
|
41
49
|
task if tasks[0..index].none? { |other_task| task.eql?(other_task) }
|
|
@@ -60,7 +68,7 @@ module DeployPin
|
|
|
60
68
|
|
|
61
69
|
# run if executable
|
|
62
70
|
if executable
|
|
63
|
-
duration = execution_duration {
|
|
71
|
+
duration = execution_duration { run_task_safely(task) }
|
|
64
72
|
DeployPin.run_formatter.call(index, tasks.count, task, executable, false, duration)
|
|
65
73
|
end
|
|
66
74
|
|
|
@@ -69,6 +77,15 @@ module DeployPin
|
|
|
69
77
|
# :reek:TooManyStatements
|
|
70
78
|
# :reek:FeatureEnvy
|
|
71
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
|
+
|
|
72
89
|
# :reek:UtilityFunction
|
|
73
90
|
def files
|
|
74
91
|
Dir["#{DeployPin.tasks_path}/*.rb"]
|
data/lib/deploy_pin/runner.rb
CHANGED
|
@@ -15,6 +15,10 @@ module DeployPin
|
|
|
15
15
|
DeployPin::Collector.new(identifiers:).short_list
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
def self.mark_done(identifiers:)
|
|
19
|
+
DeployPin::Collector.new(identifiers:).mark_done
|
|
20
|
+
end
|
|
21
|
+
|
|
18
22
|
def self.summary(identifiers:)
|
|
19
23
|
# print summary
|
|
20
24
|
self.print('======= Summary ========')
|
data/lib/deploy_pin/task.rb
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# Task wrapper
|
|
4
4
|
module DeployPin
|
|
5
|
-
|
|
5
|
+
# :reek:TooManyMethods
|
|
6
|
+
class Task # rubocop:disable Metrics/ClassLength
|
|
6
7
|
extend ::DeployPin::ParallelWrapper
|
|
7
8
|
include ::DeployPin::ParallelWrapper
|
|
8
9
|
|
|
@@ -73,7 +74,8 @@ module DeployPin
|
|
|
73
74
|
!explicit_timeout? && !parallel?
|
|
74
75
|
end
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
# :reek:TooManyStatements
|
|
78
|
+
def parse # rubocop:disable Metrics/MethodLength
|
|
77
79
|
each_line do |line|
|
|
78
80
|
case line.strip
|
|
79
81
|
when /\A# (-?\d+):(\w+):?(recurring)?/
|
|
@@ -92,6 +94,7 @@ module DeployPin
|
|
|
92
94
|
end
|
|
93
95
|
end
|
|
94
96
|
end
|
|
97
|
+
# :reek:TooManyStatements
|
|
95
98
|
|
|
96
99
|
def each_line(&block)
|
|
97
100
|
if file.starts_with?('# no_file_task')
|
|
@@ -146,4 +149,5 @@ module DeployPin
|
|
|
146
149
|
@parallel
|
|
147
150
|
end
|
|
148
151
|
end
|
|
152
|
+
# :reek:TooManyMethods
|
|
149
153
|
end
|
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
|
|
@@ -22,4 +22,11 @@ namespace :deploy_pin do
|
|
|
22
22
|
DeployPin::Runner.short_list(**args)
|
|
23
23
|
DeployPin::Runner.summary(**args)
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
task :mark_done, [:identifiers] => :environment do |_t, args|
|
|
27
|
+
args.with_defaults(identifiers: DeployPin.groups)
|
|
28
|
+
|
|
29
|
+
DeployPin::Runner.mark_done(**args)
|
|
30
|
+
DeployPin::Runner.summary(**args)
|
|
31
|
+
end
|
|
25
32
|
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.
|
|
4
|
+
version: 1.7.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Viktor Sych
|
|
@@ -279,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
279
279
|
- !ruby/object:Gem::Version
|
|
280
280
|
version: '0'
|
|
281
281
|
requirements: []
|
|
282
|
-
rubygems_version: 3.6.
|
|
282
|
+
rubygems_version: 3.6.9
|
|
283
283
|
specification_version: 4
|
|
284
284
|
summary: pin some task around deployment
|
|
285
285
|
test_files: []
|