shuttle-deploy 0.2.3 → 0.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd0e01bd7713dc75eaaef43800b74bf841743d49
4
- data.tar.gz: 7b774a999af69cab717e3b7e2fa511c0e39428bd
3
+ metadata.gz: a60eef8a58e783fe2a2ef12ca30eb520028c112e
4
+ data.tar.gz: c89dea78a0aab855018b83b841e9055da4d9a434
5
5
  SHA512:
6
- metadata.gz: b81173dc5ff5c967e431cec1bd5cd63aae104d282d44683d8ef9b6ad77460e1f1da245b53aed7dcede8e24a7da36583e66e725e0a3e30f70feee2e75c8f6c041
7
- data.tar.gz: ae52b45d7cb993b36511edc81020f00aacd76c9516969f6988ef73bffc96e5ed8009b9c84f814ee9dbf6e185920fed02a1e8f4ecefdb262b476c60c804a94db8
6
+ metadata.gz: 70760088dbcef4c8bb0b73eae39d4e93bfc5fbe3984a14df5226bbdec8211556ff28f704c7ff9c5cdc9a9dfe17b07dbedb27ddff872612d00ebe7f281bff2a4a
7
+ data.tar.gz: e53f549d4b5cc575aa7372da18b99b69ddc8168c3c37a57b2f0f9d3d7d0fc7656894325428ae1bd504628380dd007e3c384873528f007851458e14b60403020e
data/README.md CHANGED
@@ -329,7 +329,7 @@ List of all available hooks that you can use to run custom commands:
329
329
  - `before_setup` - Before base application directories are created
330
330
  - `after_setup` - After application directories are created
331
331
  - `before_checkout_code` - Before code update (git pull, etc)
332
- - `after_checkout_core` - After code has been updated
332
+ - `after_checkout_code` - After code has been updated
333
333
  - `before_link_release` - Before linking release
334
334
  - `after_link_release` - After release has been linked
335
335
  - `before_rollback` - Before rollback operation
data/lib/shuttle.rb CHANGED
@@ -22,6 +22,7 @@ module Shuttle
22
22
  autoload :PathHelpers, "shuttle/path_helpers"
23
23
  autoload :Strategy, "shuttle/strategy"
24
24
  autoload :Hook, "shuttle/hook"
25
+ autoload :Task, "shuttle/task"
25
26
  autoload :Generator, "shuttle/generator"
26
27
 
27
28
  autoload :Static, "shuttle/deployment/static"
data/lib/shuttle/hook.rb CHANGED
@@ -4,9 +4,13 @@ module Shuttle
4
4
  @deploy = deploy
5
5
  end
6
6
 
7
- def run(commands, allow_failures=false)
7
+ def run(commands, allow_failures = false)
8
8
  [commands].flatten.compact.uniq.each do |cmd|
9
- execute(cmd, allow_failures)
9
+ if cmd =~ /^task=\s?([A-Za-z\d\_]+)\s?/
10
+ Shuttle::Task.new(@deploy, $1.strip, allow_failures).run
11
+ else
12
+ execute(cmd, allow_failures)
13
+ end
10
14
  end
11
15
  end
12
16
 
@@ -1,3 +1,5 @@
1
+ require "timeout"
2
+
1
3
  module Shuttle
2
4
  class Runner
3
5
  attr_reader :options
@@ -82,8 +84,13 @@ module Shuttle
82
84
  ssh.logger = Logger.new(STDOUT)
83
85
  end
84
86
 
85
- ssh.open
86
-
87
+ begin
88
+ Timeout::timeout(10) { ssh.open }
89
+ rescue Timeout::Error
90
+ STDERR.puts "Unable to establish SSH connection to the server within 10 seconds"
91
+ exit 1
92
+ end
93
+
87
94
  klass = Shuttle.const_get(strategy.capitalize) rescue nil
88
95
  command.gsub!(/:/,'_')
89
96
  exit_code = 0
@@ -275,7 +275,7 @@ module Shuttle
275
275
  end
276
276
  end
277
277
 
278
- def execute_hook(name, allow_failures=false)
278
+ def execute_hook(name, allow_failures = false)
279
279
  if config.hooks && config.hooks[name]
280
280
  execute_commands(config.hooks[name], allow_failures)
281
281
  end
@@ -298,7 +298,7 @@ module Shuttle
298
298
  result.success? ? false : true
299
299
  end
300
300
 
301
- def execute_commands(commands=[], allow_failures=false)
301
+ def execute_commands(commands = [], allow_failures = false)
302
302
  Shuttle::Hook.new(self).run(commands, allow_failures)
303
303
  end
304
304
  end
@@ -0,0 +1,52 @@
1
+ module Shuttle
2
+ class Task
3
+ def initialize(deploy, task_name, allow_failures = false)
4
+ @deploy = deploy
5
+ @task_name = task_name
6
+ @allow_failures = allow_failures
7
+ end
8
+
9
+ def run
10
+ commands = find_task_commands(@task_name)
11
+
12
+ if commands.nil?
13
+ @deploy.error("Unable to find task: #{@task_name}")
14
+ end
15
+
16
+ commands.each do |cmd|
17
+ execute(@task_name, cmd, @allow_failures)
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def find_task_commands(name)
24
+ return unless @deploy.config.tasks.kind_of?(Hash)
25
+
26
+ if @deploy.config.tasks[name]
27
+ commands = [@deploy.config.tasks[name]]
28
+ commands.flatten.compact
29
+ end
30
+ end
31
+
32
+ def execute(task, cmd, allow_failures)
33
+ @deploy.log %{Executing [task=#{task}] "#{cmd.strip}"}
34
+
35
+ command = cmd
36
+
37
+ if @deploy.ssh.directory_exists?(@deploy.release_path)
38
+ command = "cd #{@deploy.release_path} && #{command}"
39
+ end
40
+
41
+ result = @deploy.ssh.run(command)
42
+
43
+ if result.failure? && allow_failures == false
44
+ @deploy.error("Failed: #{result.output}")
45
+ else
46
+ if !result.output.empty?
47
+ @deploy.stream_output(result.output)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module Shuttle
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0.beta1"
3
3
  end
data/spec/task_spec.rb ADDED
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ describe Shuttle::Task do
4
+ let(:config) { double(tasks: tasks) }
5
+ let(:deploy) { double(config: config) }
6
+ let(:task) { described_class.new(deploy, "foo") }
7
+
8
+ before do
9
+ allow(task).to receive(:execute)
10
+ end
11
+
12
+ describe "#run" do
13
+ context "when task does not exist" do
14
+ let(:tasks) { Hashr.new }
15
+
16
+ before do
17
+ allow(deploy).to receive(:error) { raise Shuttle::DeployError }
18
+ end
19
+
20
+ it "triggers deployment error" do
21
+ expect { task.run }.to raise_error Shuttle::DeployError
22
+ end
23
+ end
24
+
25
+ context "when task does not have commands" do
26
+ let(:tasks) { Hashr.new(foo: []) }
27
+
28
+ before do
29
+ task.run
30
+ end
31
+
32
+ it "does not execute any commands" do
33
+ expect(task).to have_received(:execute).exactly(0).times
34
+ end
35
+ end
36
+
37
+ context "when task has commands" do
38
+ let(:tasks) { Hashr.new(foo: ["cmd1", "cmd2"]) }
39
+
40
+ before do
41
+ task.run
42
+ end
43
+
44
+ it "executes all commands" do
45
+ expect(task).to have_received(:execute).with("foo", "cmd1", false)
46
+ expect(task).to have_received(:execute).with("foo", "cmd2", false)
47
+ end
48
+ end
49
+ end
50
+ end
metadata CHANGED
@@ -1,153 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shuttle-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Sosedoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-04 00:00:00.000000000 Z
11
+ date: 2014-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.13'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.13'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: simplecov
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: net-ssh
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.6'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.6'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: net-ssh-session
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: terminal_helpers
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.1'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: chronic_duration
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0.9'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.9'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: hashr
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 0.0.22
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.0.22
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: safe_yaml
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '1.0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: toml
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0.0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.0'
153
153
  description: Minimalistic deployment tool for small and one-server applications
@@ -158,8 +158,8 @@ executables:
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
- - .gitignore
162
- - .rspec
161
+ - ".gitignore"
162
+ - ".rspec"
163
163
  - Gemfile
164
164
  - LICENSE
165
165
  - README.md
@@ -193,6 +193,7 @@ files:
193
193
  - lib/shuttle/support/bundler.rb
194
194
  - lib/shuttle/support/thin.rb
195
195
  - lib/shuttle/target.rb
196
+ - lib/shuttle/task.rb
196
197
  - lib/shuttle/version.rb
197
198
  - shuttle-deploy.gemspec
198
199
  - spec/cli_spec.rb
@@ -203,6 +204,7 @@ files:
203
204
  - spec/path_helpers_spec.rb
204
205
  - spec/spec_helper.rb
205
206
  - spec/target_spec.rb
207
+ - spec/task_spec.rb
206
208
  homepage: https://github.com/sosedoff/shuttle
207
209
  licenses:
208
210
  - MIT
@@ -213,17 +215,17 @@ require_paths:
213
215
  - lib
214
216
  required_ruby_version: !ruby/object:Gem::Requirement
215
217
  requirements:
216
- - - '>='
218
+ - - ">="
217
219
  - !ruby/object:Gem::Version
218
220
  version: '0'
219
221
  required_rubygems_version: !ruby/object:Gem::Requirement
220
222
  requirements:
221
- - - '>='
223
+ - - ">"
222
224
  - !ruby/object:Gem::Version
223
- version: '0'
225
+ version: 1.3.1
224
226
  requirements: []
225
227
  rubyforge_project:
226
- rubygems_version: 2.1.11
228
+ rubygems_version: 2.2.2
227
229
  signing_key:
228
230
  specification_version: 4
229
231
  summary: Minimalistic deployment tool
@@ -236,3 +238,4 @@ test_files:
236
238
  - spec/path_helpers_spec.rb
237
239
  - spec/spec_helper.rb
238
240
  - spec/target_spec.rb
241
+ - spec/task_spec.rb