mamiya 0.0.1.alpha21 → 0.0.1.alpha22
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/example/.gitignore +5 -0
- data/example/Procfile +1 -1
- data/example/README.md +83 -0
- data/example/config.agent.rb +40 -0
- data/example/config.rb +20 -6
- data/example/deploy.rb +27 -11
- data/example/source/README.md +1 -0
- data/lib/mamiya/agent/actions.rb +8 -3
- data/lib/mamiya/agent/task_queue.rb +9 -0
- data/lib/mamiya/agent/tasks/abstract.rb +13 -0
- data/lib/mamiya/agent/tasks/clean.rb +36 -4
- data/lib/mamiya/agent/tasks/fetch.rb +1 -0
- data/lib/mamiya/agent/tasks/notifyable.rb +0 -1
- data/lib/mamiya/agent/tasks/prepare.rb +103 -0
- data/lib/mamiya/agent.rb +46 -12
- data/lib/mamiya/cli/client.rb +35 -7
- data/lib/mamiya/cli.rb +44 -5
- data/lib/mamiya/configuration.rb +12 -0
- data/lib/mamiya/dsl.rb +6 -2
- data/lib/mamiya/helpers/git.rb +24 -0
- data/lib/mamiya/master/agent_monitor.rb +22 -2
- data/lib/mamiya/master/agent_monitor_handlers.rb +17 -0
- data/lib/mamiya/master/web.rb +42 -3
- data/lib/mamiya/master.rb +4 -0
- data/lib/mamiya/script.rb +28 -8
- data/lib/mamiya/steps/abstract.rb +1 -0
- data/lib/mamiya/steps/build.rb +107 -19
- data/lib/mamiya/steps/extract.rb +1 -0
- data/lib/mamiya/steps/prepare.rb +60 -0
- data/lib/mamiya/steps/switch.rb +76 -0
- data/lib/mamiya/storages/filesystem.rb +92 -0
- data/lib/mamiya/storages/mock.rb +1 -0
- data/lib/mamiya/util/label_matcher.rb +7 -3
- data/lib/mamiya/version.rb +1 -1
- data/mamiya.gemspec +1 -1
- data/spec/agent/actions_spec.rb +25 -0
- data/spec/agent/task_queue_spec.rb +42 -6
- data/spec/agent/tasks/abstract_spec.rb +35 -0
- data/spec/agent/tasks/clean_spec.rb +94 -45
- data/spec/agent/tasks/fetch_spec.rb +1 -0
- data/spec/agent/tasks/prepare_spec.rb +127 -0
- data/spec/agent_spec.rb +75 -27
- data/spec/dsl_spec.rb +6 -8
- data/spec/master/agent_monitor_spec.rb +142 -4
- data/spec/master/web_spec.rb +43 -1
- data/spec/steps/build_spec.rb +101 -0
- data/spec/steps/prepare_spec.rb +125 -0
- data/spec/steps/switch_spec.rb +146 -0
- data/spec/storages/filesystem_spec.rb +305 -0
- data/spec/util/label_matcher_spec.rb +32 -0
- metadata +20 -6
- data/config.example.yml +0 -11
- data/example.rb +0 -74
@@ -0,0 +1,305 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'mamiya/package'
|
3
|
+
require 'mamiya/storages/abstract'
|
4
|
+
require 'mamiya/storages/filesystem'
|
5
|
+
require 'tmpdir'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
describe Mamiya::Storages::Filesystem do
|
10
|
+
let!(:tmpdir) { Dir.mktmpdir("mamiya-storages-filesystem-spec") }
|
11
|
+
after { FileUtils.remove_entry_secure tmpdir }
|
12
|
+
|
13
|
+
let(:storage_path) { Pathname.new(tmpdir) }
|
14
|
+
|
15
|
+
let(:config) do
|
16
|
+
{
|
17
|
+
application: 'myapp',
|
18
|
+
path: storage_path.to_s,
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
subject(:storage) { described_class.new(config) }
|
23
|
+
|
24
|
+
describe "#push(package)" do
|
25
|
+
let!(:source) { Dir.mktmpdir("mamiya-storages-fs-spec-push") }
|
26
|
+
let(:tarball) { File.join(source, 'test.tar.gz') }
|
27
|
+
let(:metafile) { File.join(source, 'test.json') }
|
28
|
+
|
29
|
+
before do
|
30
|
+
File.write tarball, "aaaaa\n"
|
31
|
+
File.write File.join(tmpdir, 'test.json'), "{}\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
after { FileUtils.remove_entry_secure source }
|
35
|
+
|
36
|
+
let(:package) { double('package', :kind_of? => true, :exists? => true, path: tarball, meta_path: metafile, name: 'test') }
|
37
|
+
|
38
|
+
it "places package on :path" do
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when not built" do
|
42
|
+
before do
|
43
|
+
package.stub(:exists? => false)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "raises error" do
|
47
|
+
expect {
|
48
|
+
storage.push(package)
|
49
|
+
}.to raise_error(Mamiya::Storages::Abstract::NotBuilt)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when already uploaded" do
|
54
|
+
before do
|
55
|
+
storage_path.join('myapp').mkpath
|
56
|
+
File.write storage_path.join('myapp', 'test.tar.gz'), "aaaaa\n"
|
57
|
+
File.write storage_path.join('myapp', 'test.json'), "{}\n"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "raises error" do
|
61
|
+
expect {
|
62
|
+
storage.push(package)
|
63
|
+
}.to raise_error(Mamiya::Storages::Abstract::AlreadyExists)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#fetch(package_name, dir)" do
|
69
|
+
let!(:destination) { Pathname.new Dir.mktmpdir("mamiya-storages-fs-destination") }
|
70
|
+
after { FileUtils.remove_entry_secure destination }
|
71
|
+
|
72
|
+
let(:tarball) { destination.join 'test.tar.gz' }
|
73
|
+
let(:metafile) { destination.join 'test.json' }
|
74
|
+
|
75
|
+
let(:package_name) { 'test' }
|
76
|
+
subject(:fetch) { storage.fetch(package_name, destination) }
|
77
|
+
|
78
|
+
before do
|
79
|
+
storage_path.join('myapp').mkpath
|
80
|
+
File.write storage_path.join('myapp', 'test.tar.gz'), "aaaaa\n"
|
81
|
+
File.write storage_path.join('myapp', 'test.json'), "{}\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "copies package from :path" do
|
85
|
+
expect(tarball).not_to be_exist
|
86
|
+
expect(metafile).not_to be_exist
|
87
|
+
|
88
|
+
fetch
|
89
|
+
|
90
|
+
expect(tarball).to be_exist
|
91
|
+
expect(metafile).to be_exist
|
92
|
+
expect(tarball.read).to eq "aaaaa\n"
|
93
|
+
expect(metafile.read).to eq "{}\n"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "returns Mamiya::Package" do
|
97
|
+
expect(fetch).to be_a_kind_of(Mamiya::Package)
|
98
|
+
expect(File.realpath(fetch.path)).to eq tarball.realpath.to_s
|
99
|
+
end
|
100
|
+
|
101
|
+
context "when not found" do
|
102
|
+
before do
|
103
|
+
storage_path.join('myapp', 'test.tar.gz').delete
|
104
|
+
storage_path.join('myapp', 'test.json').delete
|
105
|
+
end
|
106
|
+
|
107
|
+
it "raises error" do
|
108
|
+
expect {
|
109
|
+
fetch
|
110
|
+
}.to raise_error(Mamiya::Storages::Abstract::NotFound)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context "when meta already exists" do
|
115
|
+
before do
|
116
|
+
File.write metafile, "\n"
|
117
|
+
end
|
118
|
+
|
119
|
+
it "raises error" do
|
120
|
+
expect {
|
121
|
+
fetch
|
122
|
+
}.to raise_error(Mamiya::Storages::Abstract::AlreadyFetched)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "doesn't remove anything" do
|
126
|
+
begin
|
127
|
+
fetch
|
128
|
+
rescue Mamiya::Storages::Abstract::AlreadyFetched; end
|
129
|
+
|
130
|
+
expect(File.exist?(metafile)).to be_true
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "when tarball already exists" do
|
135
|
+
before do
|
136
|
+
File.write tarball, "\n"
|
137
|
+
end
|
138
|
+
|
139
|
+
it "raises error" do
|
140
|
+
expect {
|
141
|
+
fetch
|
142
|
+
}.to raise_error(Mamiya::Storages::Abstract::AlreadyFetched)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "doesn't remove anything" do
|
146
|
+
begin
|
147
|
+
fetch
|
148
|
+
rescue Mamiya::Storages::Abstract::AlreadyFetched; end
|
149
|
+
|
150
|
+
expect(File.exist?(tarball)).to be_true
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context "when name has .json" do
|
155
|
+
let(:package_name) { 'test.json' }
|
156
|
+
|
157
|
+
it "retrieves package" do
|
158
|
+
fetch
|
159
|
+
|
160
|
+
expect(tarball.read).to eq "aaaaa\n"
|
161
|
+
expect(metafile.read).to eq "{}\n"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
context "when name has .tar.gz" do
|
166
|
+
let(:package_name) { 'test.tar.gz' }
|
167
|
+
|
168
|
+
it "retrieves package" do
|
169
|
+
fetch
|
170
|
+
|
171
|
+
expect(tarball.read).to eq "aaaaa\n"
|
172
|
+
expect(metafile.read).to eq "{}\n"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#meta(package_name)" do
|
178
|
+
let(:package_name) { 'test' }
|
179
|
+
subject(:meta) { storage.meta(package_name) }
|
180
|
+
|
181
|
+
before do
|
182
|
+
storage_path.join('myapp').mkpath
|
183
|
+
File.write storage_path.join('myapp', 'test.tar.gz'), "aaaaa\n"
|
184
|
+
File.write storage_path.join('myapp', 'test.json'),
|
185
|
+
"#{{"foo" => "bar"}.to_json}\n"
|
186
|
+
end
|
187
|
+
|
188
|
+
it "retrieves meta JSON from :path" do
|
189
|
+
expect(meta).to eq("foo" => "bar")
|
190
|
+
end
|
191
|
+
|
192
|
+
context "when not found" do
|
193
|
+
before do
|
194
|
+
storage_path.join('myapp', 'test.tar.gz').delete
|
195
|
+
storage_path.join('myapp', 'test.json').delete
|
196
|
+
end
|
197
|
+
|
198
|
+
it "returns nil" do
|
199
|
+
expect(meta).to be_nil
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context "when name has .json" do
|
204
|
+
let(:package_name) { 'test.json' }
|
205
|
+
|
206
|
+
it "retrieves meta JSON from :path" do
|
207
|
+
expect(meta).to eq("foo" => "bar")
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "when name has .tar.gz" do
|
212
|
+
let(:package_name) { 'test.tar.gz' }
|
213
|
+
|
214
|
+
it "retrieves meta JSON from :path" do
|
215
|
+
expect(meta).to eq("foo" => "bar")
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe "#remove(package_name)" do
|
221
|
+
let(:package_name) { 'test' }
|
222
|
+
subject(:remove) { storage.remove(package_name) }
|
223
|
+
|
224
|
+
before do
|
225
|
+
storage_path.join('myapp').mkpath
|
226
|
+
File.write storage_path.join('myapp', 'test.tar.gz'), "aaaaa\n"
|
227
|
+
File.write storage_path.join('myapp', 'test.json'), "{}\n"
|
228
|
+
end
|
229
|
+
|
230
|
+
it "removes specified package from :path" do
|
231
|
+
remove
|
232
|
+
|
233
|
+
expect(storage_path.join('myapp', 'test.tar.gz')).not_to be_exist
|
234
|
+
expect(storage_path.join('myapp', 'test.json')).not_to be_exist
|
235
|
+
end
|
236
|
+
|
237
|
+
context "with name has .tar.gz" do
|
238
|
+
let(:package_name) { 'test.tar.gz' }
|
239
|
+
|
240
|
+
it "removes specified package from :path" do
|
241
|
+
remove
|
242
|
+
|
243
|
+
expect(storage_path.join('myapp', 'test.tar.gz')).not_to be_exist
|
244
|
+
expect(storage_path.join('myapp', 'test.json')).not_to be_exist
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
context "with name has .json" do
|
249
|
+
let(:package_name) { 'test.json' }
|
250
|
+
|
251
|
+
it "removes specified package from :path" do
|
252
|
+
remove
|
253
|
+
|
254
|
+
expect(storage_path.join('myapp', 'test.tar.gz')).not_to be_exist
|
255
|
+
expect(storage_path.join('myapp', 'test.json')).not_to be_exist
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context "when not found" do
|
260
|
+
before do
|
261
|
+
storage_path.join('myapp', 'test.tar.gz').delete
|
262
|
+
storage_path.join('myapp', 'test.json').delete
|
263
|
+
end
|
264
|
+
|
265
|
+
it "raises error" do
|
266
|
+
expect { storage.remove('test') }.to raise_error(Mamiya::Storages::Abstract::NotFound)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe ".find" do
|
272
|
+
before do
|
273
|
+
storage_path.join('myapp').mkpath
|
274
|
+
storage_path.join('testapp').mkpath
|
275
|
+
end
|
276
|
+
|
277
|
+
subject(:applications) { described_class.find(config.dup.tap{|_| _.delete(:application) }) }
|
278
|
+
|
279
|
+
it "lists applications in :path" do
|
280
|
+
expect(applications).to be_a_kind_of(Hash)
|
281
|
+
expect(applications['myapp']).to be_a_kind_of(described_class)
|
282
|
+
expect(applications['myapp'].application).to eq 'myapp'
|
283
|
+
expect(applications['testapp']).to be_a_kind_of(described_class)
|
284
|
+
expect(applications['testapp'].application).to eq 'testapp'
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
describe "#packages" do
|
289
|
+
before do
|
290
|
+
storage_path.join('myapp').mkpath
|
291
|
+
File.write storage_path.join('myapp', '1.tar.gz'), "aaaaa\n"
|
292
|
+
File.write storage_path.join('myapp', '1.json'), "{}\n"
|
293
|
+
File.write storage_path.join('myapp', '2.tar.gz'), "aaaaa\n"
|
294
|
+
File.write storage_path.join('myapp', '2.json'), "{}\n"
|
295
|
+
File.write storage_path.join('myapp', '3.tar.gz'), "aaaaa\n"
|
296
|
+
File.write storage_path.join('myapp', '4.json'), "{}\n"
|
297
|
+
end
|
298
|
+
|
299
|
+
subject(:packages) { storage.packages }
|
300
|
+
|
301
|
+
it "lists packages in :path" do
|
302
|
+
expect(packages).to eq ['1', '2']
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
@@ -2,6 +2,38 @@ require 'spec_helper'
|
|
2
2
|
require 'mamiya/util/label_matcher'
|
3
3
|
|
4
4
|
describe Mamiya::Util::LabelMatcher do
|
5
|
+
describe ".parse_string_expr" do
|
6
|
+
let(:str) { '' }
|
7
|
+
subject { described_class.parse_string_expr(str) }
|
8
|
+
|
9
|
+
it { should eq [] }
|
10
|
+
|
11
|
+
describe "(simple)" do
|
12
|
+
let(:str) { 'foo' }
|
13
|
+
it { should eq [['foo']] }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "(and)" do
|
17
|
+
let(:str) { 'foo,bar' }
|
18
|
+
it { should eq [['foo','bar']] }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "(or)" do
|
22
|
+
let(:str) { 'foo|bar' }
|
23
|
+
it { should eq [['foo'],['bar']] }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "(and/or)" do
|
27
|
+
let(:str) { 'foo,bar|baz' }
|
28
|
+
it { should eq [['foo','bar'],['baz']] }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "(and/or 2)" do
|
32
|
+
let(:str) { '1,2|3,4' }
|
33
|
+
it { should eq [['1','2'],['3','4']] }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
5
37
|
describe "#match?(expression)" do
|
6
38
|
let(:klass) {
|
7
39
|
Class.new {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mamiya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.alpha22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shota Fukumori (sora_h)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.5.0
|
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
|
-
version: 0.
|
68
|
+
version: 0.5.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sinatra
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,14 +166,16 @@ files:
|
|
166
166
|
- README.md
|
167
167
|
- Rakefile
|
168
168
|
- bin/mamiya
|
169
|
-
- config.example.yml
|
170
169
|
- docs/cli.md
|
171
170
|
- docs/sequences/deploy.png
|
172
171
|
- docs/sequences/deploy.uml
|
173
|
-
- example
|
172
|
+
- example/.gitignore
|
174
173
|
- example/Procfile
|
174
|
+
- example/README.md
|
175
|
+
- example/config.agent.rb
|
175
176
|
- example/config.rb
|
176
177
|
- example/deploy.rb
|
178
|
+
- example/source/README.md
|
177
179
|
- lib/mamiya.rb
|
178
180
|
- lib/mamiya/agent.rb
|
179
181
|
- lib/mamiya/agent/actions.rb
|
@@ -184,6 +186,7 @@ files:
|
|
184
186
|
- lib/mamiya/agent/tasks/clean.rb
|
185
187
|
- lib/mamiya/agent/tasks/fetch.rb
|
186
188
|
- lib/mamiya/agent/tasks/notifyable.rb
|
189
|
+
- lib/mamiya/agent/tasks/prepare.rb
|
187
190
|
- lib/mamiya/cli.rb
|
188
191
|
- lib/mamiya/cli/client.rb
|
189
192
|
- lib/mamiya/configuration.rb
|
@@ -200,9 +203,12 @@ files:
|
|
200
203
|
- lib/mamiya/steps/build.rb
|
201
204
|
- lib/mamiya/steps/extract.rb
|
202
205
|
- lib/mamiya/steps/fetch.rb
|
206
|
+
- lib/mamiya/steps/prepare.rb
|
203
207
|
- lib/mamiya/steps/push.rb
|
208
|
+
- lib/mamiya/steps/switch.rb
|
204
209
|
- lib/mamiya/storages.rb
|
205
210
|
- lib/mamiya/storages/abstract.rb
|
211
|
+
- lib/mamiya/storages/filesystem.rb
|
206
212
|
- lib/mamiya/storages/mock.rb
|
207
213
|
- lib/mamiya/storages/s3.rb
|
208
214
|
- lib/mamiya/storages/s3_proxy.rb
|
@@ -217,6 +223,7 @@ files:
|
|
217
223
|
- spec/agent/tasks/clean_spec.rb
|
218
224
|
- spec/agent/tasks/fetch_spec.rb
|
219
225
|
- spec/agent/tasks/notifyable_spec.rb
|
226
|
+
- spec/agent/tasks/prepare_spec.rb
|
220
227
|
- spec/agent_spec.rb
|
221
228
|
- spec/configuration_spec.rb
|
222
229
|
- spec/dsl_spec.rb
|
@@ -237,8 +244,11 @@ files:
|
|
237
244
|
- spec/steps/build_spec.rb
|
238
245
|
- spec/steps/extract_spec.rb
|
239
246
|
- spec/steps/fetch_spec.rb
|
247
|
+
- spec/steps/prepare_spec.rb
|
240
248
|
- spec/steps/push_spec.rb
|
249
|
+
- spec/steps/switch_spec.rb
|
241
250
|
- spec/storages/abstract_spec.rb
|
251
|
+
- spec/storages/filesystem_spec.rb
|
242
252
|
- spec/storages/s3_proxy_spec.rb
|
243
253
|
- spec/storages/s3_spec.rb
|
244
254
|
- spec/storages_spec.rb
|
@@ -276,6 +286,7 @@ test_files:
|
|
276
286
|
- spec/agent/tasks/clean_spec.rb
|
277
287
|
- spec/agent/tasks/fetch_spec.rb
|
278
288
|
- spec/agent/tasks/notifyable_spec.rb
|
289
|
+
- spec/agent/tasks/prepare_spec.rb
|
279
290
|
- spec/agent_spec.rb
|
280
291
|
- spec/configuration_spec.rb
|
281
292
|
- spec/dsl_spec.rb
|
@@ -296,8 +307,11 @@ test_files:
|
|
296
307
|
- spec/steps/build_spec.rb
|
297
308
|
- spec/steps/extract_spec.rb
|
298
309
|
- spec/steps/fetch_spec.rb
|
310
|
+
- spec/steps/prepare_spec.rb
|
299
311
|
- spec/steps/push_spec.rb
|
312
|
+
- spec/steps/switch_spec.rb
|
300
313
|
- spec/storages/abstract_spec.rb
|
314
|
+
- spec/storages/filesystem_spec.rb
|
301
315
|
- spec/storages/s3_proxy_spec.rb
|
302
316
|
- spec/storages/s3_spec.rb
|
303
317
|
- spec/storages_spec.rb
|
data/config.example.yml
DELETED
data/example.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Setting variables
|
2
|
-
set :application, 'myapp'
|
3
|
-
set :repository, "some@where:repo.git"
|
4
|
-
set :ref, "master"
|
5
|
-
|
6
|
-
set :build_from, "/tmp/app-working-copy"
|
7
|
-
set :build_to, "/tmp/app-build"
|
8
|
-
set :package_under, 'suffix'
|
9
|
-
set :dereference_symlinks, true
|
10
|
-
|
11
|
-
set :package_to, "#{__dir__}/pkg"
|
12
|
-
set :prepare_to, "/home/app/app-prepare"
|
13
|
-
set :deploy_to, "/home/app/app"
|
14
|
-
|
15
|
-
set :discover_servers, false
|
16
|
-
set :on_client_failure, :warn
|
17
|
-
|
18
|
-
servers ec2.instances
|
19
|
-
filter_servers application, :production # to restrict where server to be used
|
20
|
-
|
21
|
-
use :git, skip_naming: true
|
22
|
-
use :rails
|
23
|
-
|
24
|
-
# chainable
|
25
|
-
package_name do
|
26
|
-
"#{full_ref}"
|
27
|
-
end
|
28
|
-
|
29
|
-
build(:prepend) do
|
30
|
-
# ...
|
31
|
-
end
|
32
|
-
|
33
|
-
prepare(only: :app) do
|
34
|
-
invoke :'bundle:install'
|
35
|
-
end
|
36
|
-
|
37
|
-
finalize(except: :web) do
|
38
|
-
run "unicorn", "graceful"
|
39
|
-
end
|
40
|
-
|
41
|
-
# finalize(:overwrite) do
|
42
|
-
# invoke :'deploy:switch_current'
|
43
|
-
# run "unicorn", "graceful"
|
44
|
-
# end
|
45
|
-
|
46
|
-
# ---- git.rb
|
47
|
-
|
48
|
-
set_default :branch, "master"
|
49
|
-
|
50
|
-
task :'git:clone' do
|
51
|
-
run 'git', 'clone', ...
|
52
|
-
end
|
53
|
-
|
54
|
-
task :'git:checkout' do
|
55
|
-
next if skip_checkout
|
56
|
-
# ...
|
57
|
-
end
|
58
|
-
|
59
|
-
unless options[:no_build_prepare]
|
60
|
-
prepare_build(:overwrite) do
|
61
|
-
invoke :'git:clone'
|
62
|
-
invoke :'git:checkout'
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# ---- rails.rb
|
67
|
-
|
68
|
-
task :'rails:assets_precompile' do
|
69
|
-
# ...
|
70
|
-
end
|
71
|
-
|
72
|
-
build do
|
73
|
-
invoke :'rails:assets_precompile'
|
74
|
-
end
|