paratrooper 3.0.0.beta1 → 3.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -71
- data/lib/paratrooper/configuration.rb +2 -1
- data/lib/paratrooper/deploy.rb +12 -4
- data/lib/paratrooper/source_control.rb +35 -2
- data/lib/paratrooper/version.rb +1 -1
- data/spec/paratrooper/source_control_spec.rb +57 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1fb94737f8ced52c1df089c4c9cb3c835c13955
|
4
|
+
data.tar.gz: b5e02afaefe802bbf6b55a4142f6bd4f6a5bbcf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9123dc496f3675b12eaa400be60bbfe9ada36bc591a842055e904fd2f84119a0296125e6e582e7e5a59e15b85c6e8218dba9d0cddeec5736231b2e9e8de02ca6
|
7
|
+
data.tar.gz: 7c68f45526ab6002f81a5a2378ba47a6fb5a80105e408b4215f97d316b2fdd80570f781d9fc6e68e85bcef2e213f00a69390fd8911d1ac073df737bcdbee924b
|
data/README.md
CHANGED
@@ -11,13 +11,13 @@ Simplify your [Heroku][] deploy with quick and concise deployment rake tasks.
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
13
13
|
```shell
|
14
|
-
|
14
|
+
gem 'paratrooper'
|
15
15
|
```
|
16
16
|
|
17
17
|
and then execute
|
18
18
|
|
19
19
|
```shell
|
20
|
-
|
20
|
+
bundle
|
21
21
|
```
|
22
22
|
|
23
23
|
or
|
@@ -25,7 +25,7 @@ or
|
|
25
25
|
install it yourself with
|
26
26
|
|
27
27
|
```shell
|
28
|
-
|
28
|
+
gem install paratrooper
|
29
29
|
```
|
30
30
|
|
31
31
|
## Usage
|
@@ -33,19 +33,13 @@ install it yourself with
|
|
33
33
|
Instantiate Paratrooper with the name of your heroku application.
|
34
34
|
|
35
35
|
```ruby
|
36
|
-
Paratrooper
|
36
|
+
Paratrooper.deploy('amazing-app')
|
37
37
|
```
|
38
38
|
|
39
39
|
You can also provide a tag:
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
Paratrooper
|
43
|
-
```
|
44
|
-
|
45
|
-
or alternatively:
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
Paratrooper::Deploy.new('amazing-app') do |deploy|
|
42
|
+
Paratrooper.deploy('amazing-app') do |deploy|
|
49
43
|
deploy.tag = 'staging'
|
50
44
|
end
|
51
45
|
```
|
@@ -57,20 +51,22 @@ You can authenticate your Heroku account in a few ways:
|
|
57
51
|
* Provide an API Key
|
58
52
|
|
59
53
|
```ruby
|
60
|
-
Paratrooper
|
54
|
+
Paratrooper.deploy('app') do |deploy|
|
55
|
+
deploy.api_key = 'API_KEY'
|
56
|
+
end
|
61
57
|
```
|
62
58
|
|
63
59
|
* Set an environment variable
|
64
60
|
|
65
61
|
```ruby
|
66
62
|
ENV['HEROKU_API_KEY'] = 'API_KEY'
|
67
|
-
Paratrooper
|
63
|
+
Paratrooper.deploy('app')
|
68
64
|
```
|
69
65
|
|
70
66
|
* Local Netrc file
|
71
67
|
|
72
68
|
```ruby
|
73
|
-
Paratrooper
|
69
|
+
Paratrooper.deploy('app')
|
74
70
|
```
|
75
71
|
|
76
72
|
This method works via a local Netrc file handled via the [Heroku Toolbelt][] and is the default and preferred method for providing authentication keys.
|
@@ -80,13 +76,7 @@ This method works via a local Netrc file handled via the [Heroku Toolbelt][] and
|
|
80
76
|
If you use multiple SSH keys for managing multiple accounts, for example in your `.ssh/config`, you can set the `deployment_host` option:
|
81
77
|
|
82
78
|
```ruby
|
83
|
-
Paratrooper
|
84
|
-
```
|
85
|
-
|
86
|
-
or alternatively:
|
87
|
-
|
88
|
-
```ruby
|
89
|
-
Paratrooper::Deploy.new('amazing-app') do |deploy|
|
79
|
+
Paratrooper.deploy('amazing-app') do |deploy|
|
90
80
|
deploy.deployment_host = 'HOST'
|
91
81
|
end
|
92
82
|
```
|
@@ -94,70 +84,37 @@ end
|
|
94
84
|
This also works if you're using the [heroku-accounts](https://github.com/ddollar/heroku-accounts) plugin:
|
95
85
|
|
96
86
|
```ruby
|
97
|
-
Paratrooper
|
87
|
+
Paratrooper.deploy('app') do |deploy|
|
88
|
+
deploy.deployment_host: 'heroku.ACCOUNT_NAME'
|
89
|
+
end
|
98
90
|
```
|
99
91
|
|
100
92
|
## Tag Management
|
101
93
|
|
102
|
-
|
103
|
-
|
104
|
-
### Staging example
|
105
|
-
```ruby
|
106
|
-
Paratrooper::Deploy.new("staging-app", tag: 'staging')
|
107
|
-
```
|
108
|
-
This will create/update a `staging` git tag at `HEAD`.
|
109
|
-
|
110
|
-
### Production example
|
111
|
-
```ruby
|
112
|
-
Paratrooper::Deploy.new("amazing-production-app",
|
113
|
-
tag: 'production',
|
114
|
-
match_tag: 'staging'
|
115
|
-
)
|
116
|
-
```
|
117
|
-
|
118
|
-
or alternatively:
|
119
|
-
|
120
|
-
```ruby
|
121
|
-
Paratrooper::Deploy.new('amazing-production-app') do |deploy|
|
122
|
-
deploy.tag = 'production'
|
123
|
-
deploy.match_tag = 'staging'
|
124
|
-
end
|
125
|
-
```
|
126
|
-
This will create/update a `production` git tag at `staging` and deploy the `production` tag.
|
94
|
+
Please note: Tag management has been removed from Paratrooper 3. It added unneccesary complexity around an individual's deployment process.
|
127
95
|
|
128
96
|
## Sensible Default Deployment
|
129
97
|
|
130
|
-
You can use the object's methods any way you'd like, but we've provided a sensible default at `Paratrooper
|
98
|
+
You can use the object's methods any way you'd like, but we've provided a sensible default at `Paratrooper.deploy`.
|
131
99
|
|
132
100
|
This will perform the following tasks:
|
133
101
|
|
134
|
-
* Create or update a git tag (if provided)
|
135
102
|
* Push changes to Heroku
|
136
103
|
* Run database migrations if any have been added to db/migrate
|
137
|
-
* Restart the application
|
138
|
-
* Warm application instance
|
104
|
+
* Restart the application if migrations needed to be run
|
139
105
|
|
140
106
|
### Example Usage
|
141
107
|
|
142
108
|
```ruby
|
143
|
-
require 'paratrooper'
|
144
|
-
|
145
109
|
namespace :deploy do
|
146
110
|
desc 'Deploy app in staging environment'
|
147
111
|
task :staging do
|
148
|
-
|
149
|
-
|
150
|
-
deployment.deploy
|
112
|
+
Paratrooper.deploy("amazing-staging-app")
|
151
113
|
end
|
152
114
|
|
153
115
|
desc 'Deploy app in production environment'
|
154
116
|
task :production do
|
155
|
-
|
156
|
-
deploy.tag = 'production'
|
157
|
-
deploy.match_tag = 'staging'
|
158
|
-
end
|
159
|
-
|
160
|
-
deployment.deploy
|
117
|
+
Paratrooper.deploy("amazing-production-app")
|
161
118
|
end
|
162
119
|
end
|
163
120
|
```
|
@@ -174,7 +131,6 @@ There are 'before' and 'after' hooks for each of the following:
|
|
174
131
|
|
175
132
|
* setup
|
176
133
|
* activate_maintenance_mode
|
177
|
-
* update_repo_tag
|
178
134
|
* push_repo
|
179
135
|
* run_migrations
|
180
136
|
* app_restart
|
@@ -193,20 +149,17 @@ to disable your application monitoring.
|
|
193
149
|
namespace :deploy do
|
194
150
|
desc 'Deploy app in production environment'
|
195
151
|
task :production do
|
196
|
-
|
197
|
-
deploy.tag = 'production'
|
198
|
-
deploy.match_tag = 'staging'
|
152
|
+
Paratrooper.deploy("amazing-production-app") do |deploy|
|
199
153
|
deploy.add_callback(:before_setup) do |output|
|
200
154
|
output.display("Totally going to turn off newrelic")
|
201
155
|
system %Q[curl https://rpm.newrelic.com/accounts/ACCOUNT_ID/applications/APPLICATION_ID/ping_targets/disable -X POST -H "X-Api-Key: API_KEY"]
|
202
156
|
end
|
157
|
+
|
203
158
|
deploy.add_callback(:after_teardown) do |output|
|
204
159
|
system %Q[curl https://rpm.newrelic.com/accounts/ACCOUNT_ID/applications/APPLICATION_ID/ping_targets/enable -X POST -H "X-Api-Key: API_KEY"]
|
205
160
|
output.display("Aaaannnd we're back")
|
206
161
|
end
|
207
162
|
end
|
208
|
-
|
209
|
-
deployment.deploy
|
210
163
|
end
|
211
164
|
end
|
212
165
|
```
|
@@ -219,15 +172,13 @@ Or maybe you just want to run a rake task on your application. Since this task m
|
|
219
172
|
namespace :deploy do
|
220
173
|
desc 'Deploy app in production environment'
|
221
174
|
task :production do
|
222
|
-
|
175
|
+
Paratrooper.deploy("amazing-production-app") do |deploy|
|
223
176
|
deploy.maintenance = true
|
224
177
|
deploy.add_callback(:after_teardown) do |output|
|
225
178
|
output.display("Running some task that needs to run")
|
226
179
|
deploy.add_remote_task("rake some:task:to:run")
|
227
180
|
end
|
228
181
|
end
|
229
|
-
|
230
|
-
deployment.deploy
|
231
182
|
end
|
232
183
|
end
|
233
184
|
```
|
@@ -10,12 +10,13 @@ module Paratrooper
|
|
10
10
|
class Configuration
|
11
11
|
include Callbacks
|
12
12
|
|
13
|
-
attr_accessor :branch_name, :app_name, :api_key
|
13
|
+
attr_accessor :branch_name, :tag_name, :match_tag_name, :app_name, :api_key
|
14
14
|
attr_writer :protocol, :heroku, :migration_check,
|
15
15
|
:system_caller, :deployment_host, :http_client, :screen_notifier,
|
16
16
|
:source_control
|
17
17
|
|
18
18
|
alias :branch= :branch_name=
|
19
|
+
alias :tag= :tag_name=
|
19
20
|
|
20
21
|
def attributes=(attrs)
|
21
22
|
attrs.each do |method, value|
|
data/lib/paratrooper/deploy.rb
CHANGED
@@ -3,11 +3,9 @@ require 'paratrooper/configuration'
|
|
3
3
|
require 'paratrooper/error'
|
4
4
|
|
5
5
|
module Paratrooper
|
6
|
-
|
7
|
-
# Public: Entry point into the library.
|
8
|
-
#
|
9
6
|
class Deploy
|
10
7
|
extend Forwardable
|
8
|
+
|
11
9
|
delegate [:system_caller, :migration_check, :notifiers,
|
12
10
|
:deloyment_host, :heroku, :source_control, :screen_notifier
|
13
11
|
] => :config
|
@@ -76,6 +74,15 @@ module Paratrooper
|
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
77
|
+
def update_repo_tag
|
78
|
+
if source_control.taggable?
|
79
|
+
callback(:update_repo_tag) do
|
80
|
+
notify(:update_repo_tag)
|
81
|
+
source_control.update_repo_tag
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
79
86
|
# Public: Activates Heroku maintenance mode.
|
80
87
|
#
|
81
88
|
def activate_maintenance_mode
|
@@ -140,6 +147,7 @@ module Paratrooper
|
|
140
147
|
# Alias: #deploy
|
141
148
|
def default_deploy
|
142
149
|
setup
|
150
|
+
update_repo_tag
|
143
151
|
push_repo
|
144
152
|
maintenance_mode do
|
145
153
|
run_migrations
|
@@ -179,7 +187,7 @@ module Paratrooper
|
|
179
187
|
def default_payload
|
180
188
|
{
|
181
189
|
app_name: config.app_name,
|
182
|
-
deployment_remote:
|
190
|
+
deployment_remote: deployment_remote,
|
183
191
|
force_push: config.force_push,
|
184
192
|
reference_point: source_control.reference_point,
|
185
193
|
}
|
@@ -38,9 +38,42 @@ module Paratrooper
|
|
38
38
|
"-f " if config.force_push
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
def tag_name
|
42
|
+
config.tag_name
|
43
|
+
end
|
44
|
+
|
45
|
+
def taggable?
|
46
|
+
!untaggable?
|
47
|
+
end
|
48
|
+
|
49
|
+
def untaggable?
|
50
|
+
tag_name.nil? || tag_name.empty?
|
51
|
+
end
|
52
|
+
|
53
|
+
def match_tag_name
|
54
|
+
config.match_tag_name
|
55
|
+
end
|
56
|
+
|
57
|
+
def scm_tag_reference
|
58
|
+
"refs/tags/#{tag_name}" if tag_name
|
59
|
+
end
|
60
|
+
|
61
|
+
def scm_match_reference
|
62
|
+
if match_tag_name
|
63
|
+
"refs/tags/#{match_tag_name}"
|
64
|
+
else
|
65
|
+
"HEAD"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def update_repo_tag
|
70
|
+
system_call("git tag #{tag_name} #{match_tag_name} -f")
|
71
|
+
system_call("git push -f origin #{scm_tag_reference}")
|
72
|
+
end
|
73
|
+
|
74
|
+
# Internal: Calls commands meant to go to system.
|
42
75
|
#
|
43
|
-
# cmd - String version of system command
|
76
|
+
# cmd - String version of system command.
|
44
77
|
#
|
45
78
|
def system_call(cmd, exit_code = false)
|
46
79
|
system_caller.execute(cmd, exit_code)
|
data/lib/paratrooper/version.rb
CHANGED
@@ -125,6 +125,27 @@ describe Paratrooper::SourceControl do
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
describe "update_repo_tag" do
|
129
|
+
let(:system_caller) { double(:system_caller) }
|
130
|
+
|
131
|
+
before do
|
132
|
+
allow(system_caller).to receive(:execute)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "issues command to create/update & push tag based on tag name" do
|
136
|
+
config = instance_double(Paratrooper::Configuration,
|
137
|
+
system_caller: system_caller,
|
138
|
+
tag_name: 'TAG',
|
139
|
+
match_tag_name: 'MATCH_TAG'
|
140
|
+
)
|
141
|
+
source_control = described_class.new(config)
|
142
|
+
source_control.update_repo_tag
|
143
|
+
|
144
|
+
expected_cmd = ["git tag TAG MATCH_TAG -f", false]
|
145
|
+
expect(system_caller).to have_received(:execute).with(*expected_cmd)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
128
149
|
describe "push_to_deploy" do
|
129
150
|
let(:system_caller) { double(:system_caller) }
|
130
151
|
|
@@ -230,4 +251,40 @@ describe Paratrooper::SourceControl do
|
|
230
251
|
end
|
231
252
|
end
|
232
253
|
end
|
254
|
+
|
255
|
+
describe "#scm_tag_reference" do
|
256
|
+
context "when tag_name is available" do
|
257
|
+
it "returns fully qualified tag name" do
|
258
|
+
config = instance_double(Paratrooper::Configuration, tag_name: "TAG")
|
259
|
+
source_control = described_class.new(config)
|
260
|
+
expect(source_control.scm_tag_reference).to eq("refs/tags/TAG")
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
context "when tag_name is unavailable" do
|
265
|
+
it "returns nil" do
|
266
|
+
config = instance_double(Paratrooper::Configuration, tag_name: nil)
|
267
|
+
source_control = described_class.new(config)
|
268
|
+
expect(source_control.scm_tag_reference).to be_nil
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
describe "#scm_match_reference" do
|
274
|
+
context "when match_tag_name is available" do
|
275
|
+
it "returns fully qualified tag name" do
|
276
|
+
config = instance_double(Paratrooper::Configuration, match_tag_name: "MATCH_TAG")
|
277
|
+
source_control = described_class.new(config)
|
278
|
+
expect(source_control.scm_match_reference).to eq("refs/tags/MATCH_TAG")
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
context "when match_tag_name is unavailable" do
|
283
|
+
it "returns HEAD" do
|
284
|
+
config = instance_double(Paratrooper::Configuration, match_tag_name: nil)
|
285
|
+
source_control = described_class.new(config)
|
286
|
+
expect(source_control.scm_match_reference).to eq("HEAD")
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
233
290
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paratrooper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Polito
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
version: 1.3.1
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.4.5
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: Library to create task for deployment to Heroku
|