deploy_pin 1.3.2 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -2
- data/app/models/deploy_pin/application_record.rb +4 -2
- data/app/models/deploy_pin/record.rb +4 -2
- data/lib/deploy_pin/collector.rb +1 -0
- data/lib/deploy_pin/database.rb +2 -0
- data/lib/deploy_pin/version.rb +1 -1
- data/lib/generators/deploy_pin/install/install_generator.rb +15 -13
- data/lib/generators/deploy_pin/task/task_generator.rb +19 -17
- metadata +45 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64b7fc8e444888aebbf7bb08e4df2b259544a07fbef796cdda49412344b2dccd
|
4
|
+
data.tar.gz: 05ced857a7699b580554dd7a2a416c7b71950da11da3857a5ce5fd5167be0f9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb7b9da496971cdb3906d9f298eb3e5587205106c28f7352d492a49d13db7ef37b5f6706d3fff7d1130573ae3ac73f9a662fbc58bf072e823ee9fe6d79873df5
|
7
|
+
data.tar.gz: 68c448505f328bcaa1a7367e14d32feb785354f7fdf993b2d97d2c4194a612aead8fd28b08a3042dbe85c89dc9838f9205317aa4abd8d682b0efaad19358c3c8
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/deploy_pin.svg)](https://badge.fury.io/rb/deploy_pin)
|
2
2
|
![](https://ruby-gem-downloads-badge.herokuapp.com/deploy_pin)
|
3
3
|
![example workflow](https://github.com/skcc321/deploy_pin/actions/workflows/verify.yml/badge.svg)
|
4
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/c0a9ca97c1f9c0478ffc/maintainability)](https://codeclimate.com/github/skcc321/deploy_pin/maintainability)
|
5
|
-
[![Test Coverage](https://api.codeclimate.com/v1/badges/c0a9ca97c1f9c0478ffc/test_coverage)](https://codeclimate.com/github/skcc321/deploy_pin/test_coverage)
|
6
4
|
|
7
5
|
# DeployPin
|
8
6
|
|
@@ -105,6 +103,45 @@ and run migration
|
|
105
103
|
rake db:migrate
|
106
104
|
```
|
107
105
|
|
106
|
+
## Database Timeout
|
107
|
+
By default, deploy_pin will run all the non-parallel tasks under a database statement timeout.
|
108
|
+
A default value must be defined in the deploy_pin initializer. Ex.:
|
109
|
+
```ruby
|
110
|
+
# config/initializers/deploy_pin.rb
|
111
|
+
DeployPin.setup do
|
112
|
+
statement_timeout 0.2.second # 200 ms
|
113
|
+
end
|
114
|
+
```
|
115
|
+
|
116
|
+
In order to not use the default value, it's required to use explicitly in the task, like:
|
117
|
+
```ruby
|
118
|
+
# Some deploy_pin task
|
119
|
+
# 20190401135040:I
|
120
|
+
# task_title: Execute some query with timeout
|
121
|
+
|
122
|
+
# === task code goes down here ===
|
123
|
+
DeployPin::Database::execute_with_timeout do
|
124
|
+
ActiveRecord::Base.connection.execute("select * from shipments;")
|
125
|
+
end
|
126
|
+
```
|
127
|
+
|
128
|
+
To know more about the params, please check the documentation [here](lib/deploy_pin/database.rb).
|
129
|
+
|
130
|
+
### Parallel
|
131
|
+
To run parallel tasks using timeout, it's required to use the parallel wrapper, which mimics parallel interface,
|
132
|
+
but adding the timeout option.
|
133
|
+
|
134
|
+
In a deploy_pin task, instead of using `Parallel.each(1..2, in_processes: 2)`, use:
|
135
|
+
```ruby
|
136
|
+
parallel_each(1..2, in_processes: 2, timeout: 0.3.seconds) do |i|
|
137
|
+
# ActiveRecord::Base.connection_pool.with_connection it's already include in the parallel wrapper.
|
138
|
+
puts "Item: #{i}, Worker: #{Parallel.worker_number}"
|
139
|
+
ActiveRecord::Base.connection.execute("<some db query>")
|
140
|
+
end
|
141
|
+
```
|
142
|
+
|
143
|
+
Check the documentation [here](lib/deploy_pin/parallel_wrapper.rb).
|
144
|
+
|
108
145
|
## Contributing
|
109
146
|
Contribution directions go here.
|
110
147
|
|
data/lib/deploy_pin/collector.rb
CHANGED
data/lib/deploy_pin/database.rb
CHANGED
data/lib/deploy_pin/version.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module DeployPin
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
desc 'Add the migration & initializer for DeployPin'
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def self.next_migration_number(path)
|
11
|
+
next_migration_number = current_migration_number(path) + 1
|
12
|
+
ActiveRecord::Migration.next_migration_number(next_migration_number)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def copy_migrations
|
16
|
+
migration_template 'create_deploy_pins.rb', 'db/migrate/create_deploy_pins.rb'
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
def copy_initializer
|
20
|
+
template 'deploy_pin.rb', 'config/initializers/deploy_pin.rb'
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
@@ -1,24 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module DeployPin
|
4
|
+
class TaskGenerator < Rails::Generators::Base
|
5
|
+
class_option :parallel, type: :boolean
|
6
|
+
argument :title, required: true
|
7
|
+
class_option :group, aliases: '-g', default: DeployPin.fallback_group
|
8
|
+
class_option :author, aliases: '-a'
|
8
9
|
|
9
|
-
|
10
|
+
source_root File.expand_path('templates', __dir__)
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
desc 'This generator creates deploy_pin task at lib/deploy_pin/'
|
13
|
+
def create_task_file
|
14
|
+
template_file = if options[:parallel]
|
15
|
+
'parallel_task.rb.erb'
|
16
|
+
else
|
17
|
+
'task.rb.erb'
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
@author = options[:author] || ENV['USER']
|
21
|
+
@group = options[:group]
|
22
|
+
@uuid = Time.now.strftime('%Y%m%d%H%M%S')
|
23
|
+
template template_file, "#{DeployPin.tasks_path}/#{@uuid}_#{title}.rb"
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deploy_pin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Viktor Sych
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -150,6 +150,48 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-minitest
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: simplecov
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: simplecov-review
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
153
195
|
description: pin some task around deployment to execute them during deployment circle
|
154
196
|
email:
|
155
197
|
- skcc321@gmail.com
|
@@ -193,7 +235,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
235
|
requirements:
|
194
236
|
- - ">="
|
195
237
|
- !ruby/object:Gem::Version
|
196
|
-
version: '0'
|
238
|
+
version: '3.0'
|
197
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
240
|
requirements:
|
199
241
|
- - ">="
|