opsworks-deploy 0.0.2 → 0.0.3
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/lib/opsworks/deploy/version.rb +1 -1
- data/lib/opsworks/tasks/opsworks.rake +5 -4
- data/spec/opsworks_deploy_spec.rb +44 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61313915a53e4d09653d4a85f855aa0b64fe1b49
|
4
|
+
data.tar.gz: 164c655fc62e206aed029f6f90dfca95852e272a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e478814436ec0f4da0c9e916a1de527192e269d03d461bb26ae60fba938727ee553347b0062a251993d17e0f0d7252560c44f40b629993c97b97239eed8cd9a
|
7
|
+
data.tar.gz: 207e8744ccd98c836165ba51a16b1333dbbe1a3b7066e3a67221d110d8b595f27d538564087be98534f01d2c798cb54dbd838d696419db493ec9d8b22dab1957
|
@@ -2,14 +2,15 @@
|
|
2
2
|
namespace :opsworks do
|
3
3
|
|
4
4
|
desc 'Deploy to Opsworks'
|
5
|
-
task :deploy, [:rails_env] => :environment do |t, args|
|
5
|
+
task :deploy, [:rails_env,:migrate] => :environment do |t, args|
|
6
6
|
rails_env = args[:rails_env] || ENV['RAILS_ENV']
|
7
|
-
|
7
|
+
migrate = args[:migrate] == "true" || args[:migrate] == "t"
|
8
|
+
|
8
9
|
raise ArgumentError, "Please pass rails_env as argument or set RAILS_ENV environment var" if rails_env.nil? || rails_env == ""
|
9
10
|
|
10
|
-
puts "Deploying #{rails_env}..."
|
11
|
+
puts "Deploying #{rails_env}#{migrate ? " and running migrations" : ""}..."
|
11
12
|
|
12
|
-
Opsworks::Deploy.deploy(rails_env: rails_env)
|
13
|
+
Opsworks::Deploy.deploy(rails_env: rails_env, migrate: migrate)
|
13
14
|
|
14
15
|
puts "Finished successfully"
|
15
16
|
end
|
@@ -15,14 +15,14 @@ describe 'opsworks:deploy rake task' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should call invoke with argument when given arg" do
|
18
|
-
expect(Opsworks::Deploy).to receive(:deploy).with(rails_env: 'test-1')
|
18
|
+
expect(Opsworks::Deploy).to receive(:deploy).with(rails_env: 'test-1', migrate: false)
|
19
19
|
Rake::Task["opsworks:deploy"].invoke('test-1')
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should call invoke with argument when given env" do
|
23
23
|
begin
|
24
24
|
ENV['RAILS_ENV'] = "test-2"
|
25
|
-
expect(Opsworks::Deploy).to receive(:deploy).with(rails_env: 'test-2')
|
25
|
+
expect(Opsworks::Deploy).to receive(:deploy).with(rails_env: 'test-2', migrate: false)
|
26
26
|
Rake::Task["opsworks:deploy"].invoke
|
27
27
|
ensure
|
28
28
|
ENV['RAILS_ENV'] = nil
|
@@ -33,7 +33,7 @@ describe 'opsworks:deploy rake task' do
|
|
33
33
|
expect { Rake::Task["opsworks:deploy"].invoke() }.to raise_error(ArgumentError)
|
34
34
|
end
|
35
35
|
|
36
|
-
it "should run opsworks deploy" do
|
36
|
+
it "should run opsworks deploy with migrate" do
|
37
37
|
begin
|
38
38
|
config = {
|
39
39
|
'test-3' => {
|
@@ -52,13 +52,16 @@ describe 'opsworks:deploy rake task' do
|
|
52
52
|
expect(File).to receive(:exists?).and_return(true)
|
53
53
|
expect(File).to receive(:read).and_return(config.to_json)
|
54
54
|
|
55
|
+
expected_params = { stack_id: "sid", app_id: "aid", command: {name: 'deploy', args: {"migrate" => [ "false" ] } } }
|
56
|
+
|
55
57
|
# Mock the AWS features
|
56
58
|
client = double("client")
|
57
|
-
expect(client).to receive(:create_deployment)
|
59
|
+
expect(client).to receive(:create_deployment).with(expected_params)
|
58
60
|
|
59
61
|
ops_works = double("ops_works")
|
60
62
|
expect(ops_works).to receive(:client).and_return(client)
|
61
63
|
|
64
|
+
|
62
65
|
expect(AWS).to receive(:ops_works).and_return(ops_works)
|
63
66
|
|
64
67
|
# Call rake task
|
@@ -68,4 +71,41 @@ describe 'opsworks:deploy rake task' do
|
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
74
|
+
it "should run opsworks deploy without migrate" do
|
75
|
+
begin
|
76
|
+
config = {
|
77
|
+
'test-4' => {
|
78
|
+
stack_id: 'sid',
|
79
|
+
app_id: 'aid'
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
# Mock ENV vars
|
84
|
+
ENV['IAM_KEY'] = ENV['IAM_SECRET'] = "a"
|
85
|
+
|
86
|
+
# Allow rails-generated config
|
87
|
+
Rails = double("rails")
|
88
|
+
expect(Rails).to receive(:root).and_return(".").twice
|
89
|
+
expect(File).to receive(:exists?).and_return(true)
|
90
|
+
expect(File).to receive(:read).and_return(config.to_json)
|
91
|
+
|
92
|
+
expected_params = { stack_id: "sid", app_id: "aid", command: {name: 'deploy', args: {"migrate" => [ "true" ] } } }
|
93
|
+
|
94
|
+
# Mock the AWS features
|
95
|
+
client = double("client")
|
96
|
+
expect(client).to receive(:create_deployment).with(expected_params)
|
97
|
+
|
98
|
+
ops_works = double("ops_works")
|
99
|
+
expect(ops_works).to receive(:client).and_return(client)
|
100
|
+
|
101
|
+
|
102
|
+
expect(AWS).to receive(:ops_works).and_return(ops_works)
|
103
|
+
|
104
|
+
# Call rake task
|
105
|
+
Rake::Task["opsworks:deploy"].invoke("test-4","true")
|
106
|
+
ensure # clear ENV vars
|
107
|
+
ENV['RAILS_ENV'] = ENV['IAM_KEY'] = ENV['IAM_SECRET'] = nil
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
71
111
|
end
|