engineyard 2.0.9 → 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,19 +16,20 @@ module EY
16
16
 
17
17
  include Thor::Actions
18
18
 
19
- def self.start(*)
19
+ def self.start(given_args=ARGV, config={})
20
+ Thor::Base.shell = EY::CLI::UI
20
21
  ui = EY::CLI::UI.new
21
- super
22
+ super(given_args, {:shell => ui}.merge(config))
22
23
  rescue EY::Error, EY::CloudClient::Error => e
23
24
  ui.print_exception(e)
24
- raise
25
+ exit 1
25
26
  rescue Interrupt => e
26
27
  puts
27
28
  ui.print_exception(e)
28
29
  ui.say("Quitting...")
29
30
  raise
30
- rescue SystemExit
31
- # don't print a message for exit
31
+ rescue SystemExit, Errno::EPIPE
32
+ # don't print a message for safe exits
32
33
  raise
33
34
  rescue Exception => e
34
35
  ui.print_exception(e)
@@ -37,6 +38,7 @@ module EY
37
38
 
38
39
  class_option :api_token, :type => :string, :desc => "Use API-TOKEN to authenticate this command"
39
40
  class_option :serverside_version, :type => :string, :desc => "Please use with care! Override deploy system version (same as ENV variable ENGINEYARD_SERVERSIDE_VERSION)"
41
+ class_option :quiet, :aliases => %w[-q], :type => :boolean, :desc => "Quieter CLI output."
40
42
 
41
43
  desc "deploy [--environment ENVIRONMENT] [--ref GIT-REF]",
42
44
  "Deploy specified branch, tag, or sha to specified environment."
@@ -91,10 +93,10 @@ module EY
91
93
 
92
94
  runner = serverside_runner(app_env, deploy_config.verbose, deployment.serverside_version, options[:ignore_bad_master])
93
95
 
94
- out = EY::CLI::UI::Tee.new(ui.out, deployment.out)
95
- err = EY::CLI::UI::Tee.new(ui.err, deployment.err)
96
+ out = EY::CLI::UI::Tee.new(ui.out, deployment.output)
97
+ err = EY::CLI::UI::Tee.new(ui.err, deployment.output)
96
98
 
97
- ui.info "Beginning deploy..."
99
+ ui.info "Beginning deploy...", :green
98
100
  begin
99
101
  deployment.start
100
102
  ui.show_deployment(deployment)
@@ -120,14 +122,14 @@ module EY
120
122
  ui.print_exception(e)
121
123
  raise
122
124
  ensure
125
+ ui.info "Saving log... ", :green
123
126
  deployment.finished
124
127
 
125
128
  if deployment.successful?
126
- ui.info "Successful deployment recorded on Engine Yard Cloud"
127
- ui.info "Deploy complete"
128
- ui.info "Now you can run `ey launch' to open the application in a browser."
129
+ ui.info "Successful deployment recorded on Engine Yard Cloud.", :green
130
+ ui.info "Run `ey launch` to open the application in a browser."
129
131
  else
130
- ui.info "Failed deployment recorded on Engine Yard Cloud"
132
+ ui.info "Failed deployment recorded on Engine Yard Cloud", :green
131
133
  raise EY::Error, "Deploy failed"
132
134
  end
133
135
  end
@@ -151,11 +153,7 @@ module EY
151
153
  app_env = fetch_app_environment(options[:app], options[:environment], options[:account])
152
154
  deployment = app_env.last_deployment
153
155
  if deployment
154
- ui.say "# Status of last deployment of #{app_env.hierarchy_name}:"
155
- ui.say "#"
156
- ui.show_deployment(deployment)
157
- ui.say "#"
158
- ui.deployment_result(deployment)
156
+ ui.deployment_status(deployment)
159
157
  else
160
158
  raise EY::Error, "Application #{app_env.app.name} has not been deployed on #{app_env.environment.name}."
161
159
  end
@@ -184,7 +182,7 @@ module EY
184
182
  if options[:all] && options[:simple]
185
183
  ui.print_simple_envs api.environments
186
184
  elsif options[:all]
187
- ui.print_envs(api.apps)
185
+ ui.print_envs api.apps
188
186
  else
189
187
  remotes = nil
190
188
  if options[:app] == ''
@@ -241,7 +239,7 @@ module EY
241
239
  :desc => "Name of the account in which the environment can be found"
242
240
  def rebuild
243
241
  environment = fetch_environment(options[:environment], options[:account])
244
- ui.debug("Rebuilding #{environment.name}")
242
+ ui.info "Updating instances on #{environment.hierarchy_name}"
245
243
  environment.rebuild
246
244
  end
247
245
  map "update" => :rebuild
@@ -270,7 +268,7 @@ module EY
270
268
  env_config = config.environment_config(app_env.environment_name)
271
269
  deploy_config = EY::DeployConfig.new(options, env_config, repo, ui)
272
270
 
273
- ui.info("Rolling back #{app_env.hierarchy_name}")
271
+ ui.info "Rolling back #{app_env.hierarchy_name}"
274
272
 
275
273
  runner = serverside_runner(app_env, deploy_config.verbose)
276
274
  runner.rollback do |args|
@@ -370,15 +368,15 @@ module EY
370
368
  def logs
371
369
  environment = fetch_environment(options[:environment], options[:account])
372
370
  environment.logs.each do |log|
373
- ui.info log.instance_name
371
+ ui.say "Instance: #{log.instance_name}"
374
372
 
375
373
  if log.main
376
- ui.info "Main logs for #{environment.name}:"
374
+ ui.say "Main logs for #{environment.name}:", :green
377
375
  ui.say log.main
378
376
  end
379
377
 
380
378
  if log.custom
381
- ui.info "Custom logs for #{environment.name}:"
379
+ ui.say "Custom logs for #{environment.name}:", :green
382
380
  ui.say log.custom
383
381
  end
384
382
  end
@@ -483,10 +481,10 @@ module EY
483
481
  def logout
484
482
  eyrc = EYRC.load
485
483
  if eyrc.delete_api_token
486
- ui.say "API token removed: #{eyrc.path}"
487
- ui.say "Run any other command to login again."
484
+ ui.info "API token removed: #{eyrc.path}"
485
+ ui.info "Run any other command to login again."
488
486
  else
489
- ui.say "Already logged out. Run any other command to login again."
487
+ ui.info "Already logged out. Run any other command to login again."
490
488
  end
491
489
  end
492
490
 
@@ -76,7 +76,7 @@ module EY
76
76
  @source = "credentials"
77
77
  @specified = false
78
78
 
79
- @ui.info("We need to fetch your API token; please log in.")
79
+ @ui.info "We need to fetch your API token; please log in."
80
80
  begin
81
81
  email = @ui.ask("Email: ")
82
82
  passwd = @ui.ask("Password: ", true)
@@ -60,17 +60,17 @@ module EY
60
60
  no_tasks do
61
61
  def apply_recipes(environment)
62
62
  environment.run_custom_recipes
63
- ui.say "Uploaded recipes started for #{environment.name}"
63
+ ui.info "Uploaded recipes started for #{environment.name}"
64
64
  end
65
65
 
66
66
  def upload_recipes(environment, filename)
67
67
  if filename && filename != ''
68
68
  environment.upload_recipes_at_path(filename)
69
- ui.say "Recipes file #{filename} uploaded successfully for #{environment.name}"
69
+ ui.info "Recipes file #{filename} uploaded successfully for #{environment.name}"
70
70
  else
71
71
  path = cookbooks_dir_archive_path
72
72
  environment.upload_recipes_at_path(path)
73
- ui.say "Recipes in cookbooks/ uploaded successfully for #{environment.name}"
73
+ ui.info "Recipes in cookbooks/ uploaded successfully for #{environment.name}"
74
74
  end
75
75
  end
76
76
 
@@ -114,7 +114,7 @@ module EY
114
114
  cmd = "tar xzf '#{recipes.path}' cookbooks"
115
115
 
116
116
  if system(cmd)
117
- ui.say "Recipes downloaded successfully for #{environment.name}"
117
+ ui.info "Recipes downloaded successfully for #{environment.name}"
118
118
  else
119
119
  raise EY::Error, "Could not unarchive recipes.\nCommand `#{cmd}` exited with an error."
120
120
  end
@@ -36,7 +36,7 @@ module EY
36
36
  end
37
37
 
38
38
  def self.interactive?
39
- @mock || ($stdin && $stdin.tty?)
39
+ @mock || ($stdout && $stdout.tty?)
40
40
  end
41
41
 
42
42
  def self.ask(question, password = false, default = nil)
@@ -77,7 +77,7 @@ module EY
77
77
  if interactive?
78
78
  block.call
79
79
  else
80
- Timeout.timeout(5, &block)
80
+ Timeout.timeout(2, &block)
81
81
  end
82
82
  end
83
83
  end
@@ -93,8 +93,9 @@ module EY
93
93
  say_with_status(name, message, :yellow)
94
94
  end
95
95
 
96
- def info(name, message = nil)
97
- say_with_status(name, message, :green)
96
+ def info(message, color = nil)
97
+ return if quiet?
98
+ say_with_status(message, nil, color)
98
99
  end
99
100
 
100
101
  def debug(name, message = nil)
@@ -156,7 +157,18 @@ module EY
156
157
  end
157
158
  end
158
159
 
160
+ def deployment_status(deployment)
161
+ unless quiet?
162
+ say "# Status of last deployment of #{deployment.app_environment.hierarchy_name}:"
163
+ say "#"
164
+ show_deployment(deployment)
165
+ say "#"
166
+ end
167
+ deployment_result(deployment)
168
+ end
169
+
159
170
  def show_deployment(dep)
171
+ return if quiet?
160
172
  output = []
161
173
  output << ["Account", dep.app.account.name]
162
174
  output << ["Application", dep.app.name]
@@ -177,11 +189,11 @@ module EY
177
189
 
178
190
  def deployment_result(dep)
179
191
  if dep.successful?
180
- info 'This deployment was successful.'
192
+ say 'Deployment was successful.', :green
181
193
  elsif dep.finished_at.nil?
182
- warn 'This deployment is not finished.'
194
+ say 'Deployment is not finished.', :yellow
183
195
  else
184
- say_with_status('This deployment failed.', nil, :red)
196
+ say 'Deployment failed.', :red
185
197
  end
186
198
  end
187
199
 
@@ -78,11 +78,12 @@ module EY
78
78
  if @perfom.nil? && @command = command_from_config
79
79
  @perform = true
80
80
  env_config.migrate = @perform
81
- ui.warn "********************************************************************************"
81
+ ui.info "********************************************************************************"
82
82
  ui.info "#{env_config.path} config for #{env_config.name} has been updated to"
83
83
  ui.info "migrate by default to maintain previous expected default behavior."
84
- ui.warn "********************************************************************************"
85
- ui.say "It's a good idea to git commit #{env_config.path} with these new changes."
84
+ ui.info ""
85
+ ui.info "Please git commit #{env_config.path} with these new changes.", :yellow
86
+ ui.info ""
86
87
  true
87
88
  else
88
89
  false
@@ -90,15 +91,14 @@ module EY
90
91
  end
91
92
 
92
93
  def perform_from_interaction
93
- ui.warn "Please choose a default migration behavior for this environment."
94
94
  @perform = ui.agree("Run migrations by default on #{env_config.name}? ", true)
95
95
  env_config.migrate = @perform
96
96
  if @perform
97
97
  command_from_interaction
98
98
  end
99
- ui.say "#{env_config.path}: migrate settings saved for #{env_config.name}."
100
- ui.say "You can override this default with --migrate or --no-migrate."
101
- ui.info "Please git commit #{env_config.path} with these new changes."
99
+ ui.info "#{env_config.path}: migrate settings saved for #{env_config.name}."
100
+ ui.info "You can override this default with --migrate or --no-migrate."
101
+ ui.info "Please git commit #{env_config.path} with these new changes.", :yellow
102
102
  true
103
103
  rescue Timeout::Error
104
104
  @perform = nil
@@ -88,7 +88,7 @@ module EY
88
88
  end
89
89
 
90
90
  out << "Running command on #{@username}@#{@hostname}.\n"
91
- out << cmd << "\n" if @verbose
91
+ out << cmd << "\n" if @verbose || ENV['PRINT_CMD']
92
92
 
93
93
  if ENV["NO_SSH"]
94
94
  out << "NO_SSH is set. No output.\n"
@@ -12,13 +12,9 @@ module EY
12
12
  @config ||= EY::Config.new
13
13
  end
14
14
 
15
+ # engineyard gem uses ui everywhere, thore supplies shell
15
16
  def ui
16
- @ui ||= load_ui
17
- end
18
-
19
- def load_ui
20
- Thor::Base.shell = EY::CLI::UI
21
- EY::CLI::UI.new
17
+ shell
22
18
  end
23
19
 
24
20
  def in_repo?
@@ -45,7 +41,7 @@ module EY
45
41
 
46
42
  def use_default_environment
47
43
  if env = config.default_environment
48
- ui.say "Using default environment #{config.default_environment.inspect} from ey.yml."
44
+ ui.info "Using default environment #{config.default_environment.inspect} from ey.yml."
49
45
  env
50
46
  end
51
47
  end
@@ -1,4 +1,4 @@
1
1
  module EY
2
- VERSION = '2.0.9'
3
- ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || '2.0.3'
2
+ VERSION = '2.0.10'
3
+ ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || '2.0.4'
4
4
  end
@@ -29,7 +29,9 @@ describe EY::CLI::API do
29
29
  EY::CLI::UI::Prompter.add_answer "my@email.example.com"
30
30
  EY::CLI::UI::Prompter.add_answer "secret"
31
31
 
32
- @api = EY::CLI::API.new('http://fake.local', EY::CLI::UI.new)
32
+ capture_stdout do
33
+ @api = EY::CLI::API.new('http://fake.local', EY::CLI::UI.new)
34
+ end
33
35
  end
34
36
 
35
37
  it "asks you for your credentials" do
@@ -26,8 +26,13 @@ describe EY::DeployConfig::Migrate do
26
26
  @parent.should_receive(:set_environment_option).with('envname', 'migrate', true)
27
27
  @parent.should_receive(:set_environment_option).with('envname', 'migration_command', 'rake db:migrate')
28
28
  dc = deploy_config({})
29
- dc.migrate.should be_true
30
- dc.migrate_command.should == 'rake db:migrate'
29
+ out = capture_stdout do
30
+ dc.migrate.should be_true
31
+ dc.migrate_command.should == 'rake db:migrate'
32
+ end
33
+ out.should =~ /path: migrate settings saved for envname/
34
+ out.should =~ /You can override this default with --migrate or --no-migrate/
35
+ out.should =~ /Please git commit path with these new changes./
31
36
  end
32
37
 
33
38
  it "prompts migration_command if first answer is yes" do
@@ -36,16 +41,20 @@ describe EY::DeployConfig::Migrate do
36
41
  @parent.should_receive(:set_environment_option).with('envname', 'migrate', true)
37
42
  @parent.should_receive(:set_environment_option).with('envname', 'migration_command', 'ruby script/migrate')
38
43
  dc = deploy_config({})
39
- dc.migrate.should be_true
40
- dc.migrate_command.should == 'ruby script/migrate'
44
+ capture_stdout do
45
+ dc.migrate.should be_true
46
+ dc.migrate_command.should == 'ruby script/migrate'
47
+ end
41
48
  end
42
49
 
43
50
  it "doesn't prompt migration_command if first answer is no" do
44
51
  EY::CLI::UI::Prompter.add_answer "no" # default
45
52
  @parent.should_receive(:set_environment_option).with('envname', 'migrate', false)
46
53
  dc = deploy_config({})
47
- dc.migrate.should be_false
48
- dc.migrate_command.should be_nil
54
+ capture_stdout do
55
+ dc.migrate.should be_false
56
+ dc.migrate_command.should be_nil
57
+ end
49
58
  end
50
59
  end
51
60
 
@@ -120,7 +129,10 @@ describe EY::DeployConfig::Migrate do
120
129
  before { env_config('branch' => 'default') }
121
130
 
122
131
  it "uses the configured default if ref is not passed" do
123
- deploy_config({}).ref.should == 'default'
132
+ out = capture_stdout do
133
+ deploy_config({}).ref.should == 'default'
134
+ end
135
+ out.should =~ /Using default branch "default" from ey.yml/
124
136
  end
125
137
 
126
138
  it "raises if a default is set and --ref is passed on the cli (and they don't match)" do
@@ -132,18 +144,27 @@ describe EY::DeployConfig::Migrate do
132
144
  end
133
145
 
134
146
  it "returns the ref if force_ref is set" do
135
- deploy_config({'ref' => 'master', 'force_ref' => true}).ref.should == 'master'
147
+ out = capture_stdout do
148
+ deploy_config({'ref' => 'master', 'force_ref' => true}).ref.should == 'master'
149
+ end
150
+ out.should =~ /Default ref overridden with "master"/
136
151
  end
137
152
 
138
153
  it "returns the ref if force_ref is a branch" do
139
- deploy_config({'force_ref' => 'master'}).ref.should == 'master'
154
+ out = capture_stdout do
155
+ deploy_config({'force_ref' => 'master'}).ref.should == 'master'
156
+ end
157
+ out.should =~ /Default ref overridden with "master"/
140
158
  end
141
159
  end
142
160
 
143
161
  context "no options, no default" do
144
162
  it "uses the repo's current branch" do
145
163
  @repo.should_receive(:current_branch).and_return('current')
146
- deploy_config({}).ref.should == 'current'
164
+ out = capture_stdout do
165
+ deploy_config({}).ref.should == 'current'
166
+ end
167
+ out.should =~ /Using current HEAD branch "current"/
147
168
  end
148
169
  end
149
170
  end
@@ -69,9 +69,9 @@ describe "ey deploy" do
69
69
  ENV['NO_SSH'] = 'true'
70
70
  end
71
71
 
72
- it "tells you that you need to add an appropriate ssh key" do
72
+ it "tells you that you need to add an appropriate ssh key (even with --quiet)" do
73
73
  login_scenario "one app, one environment"
74
- fast_failing_ey %w[deploy --no-migrate]
74
+ fast_failing_ey %w[deploy --no-migrate --quiet]
75
75
  @err.should include("Authentication Failed")
76
76
  end
77
77
  end
@@ -249,19 +249,6 @@ describe "ey deploy" do
249
249
  end
250
250
 
251
251
  context "choosing something to deploy" do
252
- define_git_repo('deploy test') do
253
- # we'll have one commit on master
254
- system("echo 'source :gemcutter' > Gemfile")
255
- system("git add Gemfile")
256
- system("git commit -m 'initial commit' >/dev/null 2>&1")
257
-
258
- # and a tag
259
- system("git tag -a -m 'version one' v1")
260
-
261
- # and we need a non-master branch
262
- system("git checkout -b current-branch >/dev/null 2>&1")
263
- end
264
-
265
252
  use_git_repo('deploy test')
266
253
 
267
254
  before(:all) do
@@ -363,7 +350,7 @@ describe "ey deploy" do
363
350
  if @ssh_commands.last =~ /--config (.*?)(?: -|$)/
364
351
  # the echo strips off the layer of shell escaping, leaving us
365
352
  # with pristine JSON
366
- JSON.parse `echo #{$1}`
353
+ MultiJson.load `echo #{$1}`
367
354
  end
368
355
  end
369
356
 
@@ -11,7 +11,7 @@ describe "ey rebuild" do
11
11
  end
12
12
 
13
13
  def verify_ran(scenario)
14
- @out.should =~ /Rebuilding #{scenario[:environment]}/
14
+ @out.should =~ /Updating instances on \w+\/#{scenario[:environment]}/
15
15
  end
16
16
 
17
17
  include_examples "it takes an environment name and an account name"
@@ -3,10 +3,6 @@ require 'spec_helper'
3
3
  describe "ey recipes upload" do
4
4
  given "integration"
5
5
 
6
- define_git_repo('+cookbooks') do |git_dir|
7
- git_dir.join("cookbooks").mkdir
8
- git_dir.join("cookbooks/file").open("w") {|f| f << "boo" }
9
- end
10
6
  use_git_repo('+cookbooks')
11
7
 
12
8
  def command_to_run(opts)
@@ -26,9 +22,6 @@ end
26
22
  describe "ey recipes upload -f recipes.tgz" do
27
23
  given "integration"
28
24
 
29
- define_git_repo('+recipes') do |git_dir|
30
- link_recipes_tgz(git_dir)
31
- end
32
25
  use_git_repo('+recipes')
33
26
 
34
27
  def command_to_run(opts)
@@ -73,15 +66,6 @@ describe "ey recipes upload from a separate cookbooks directory" do
73
66
  given "integration"
74
67
 
75
68
  context "without any git remotes" do
76
- define_git_repo "only cookbooks, no remotes" do |git_dir|
77
- `git --git-dir "#{git_dir}/.git" remote`.split("\n").each do |remote|
78
- `git --git-dir "#{git_dir}/.git" remote rm #{remote}`
79
- end
80
-
81
- git_dir.join("cookbooks").mkdir
82
- File.open(git_dir.join("cookbooks/file"), "w"){|f| f << "stuff" }
83
- end
84
-
85
69
  use_git_repo "only cookbooks, no remotes"
86
70
 
87
71
  it "takes the environment specified by -e" do
@@ -102,17 +86,6 @@ describe "ey recipes upload from a separate cookbooks directory" do
102
86
  end
103
87
 
104
88
  context "with a git remote unrelated to any application" do
105
- define_git_repo "only cookbooks, unrelated remotes" do |git_dir|
106
- `git --git-dir "#{git_dir}/.git" remote`.split("\n").each do |remote|
107
- `git --git-dir "#{git_dir}/.git" remote rm #{remote}`
108
- end
109
-
110
- `git remote add origin polly@pirate.example.com:wanna/cracker.git`
111
-
112
- git_dir.join("cookbooks").mkdir
113
- File.open(git_dir.join("cookbooks/file"), "w"){|f| f << "rawk" }
114
- end
115
-
116
89
  use_git_repo "only cookbooks, unrelated remotes"
117
90
 
118
91
  it "takes the environment specified by -e" do
@@ -36,7 +36,7 @@ describe "ey rollback" do
36
36
  if @ssh_commands.last =~ /--config (.*?)(?: -|$)/
37
37
  # the echo strips off the layer of shell escaping, leaving us
38
38
  # with pristine JSON
39
- JSON.parse `echo #{$1}`
39
+ MultiJson.load `echo #{$1}`
40
40
  end
41
41
  end
42
42
 
@@ -26,6 +26,7 @@ shared_examples_for "running ey ssh for select role" do
26
26
  def command_to_run(opts)
27
27
  cmd = ["ssh", opts[:ssh_command]].compact + (@ssh_flag || [])
28
28
  cmd << "--environment" << opts[:environment] if opts[:environment]
29
+ cmd << "--quiet" if opts[:quiet]
29
30
  cmd
30
31
  end
31
32
 
@@ -42,6 +43,13 @@ shared_examples_for "running ey ssh for select role" do
42
43
  end.count.should == @hosts.count
43
44
  end
44
45
 
46
+ it "is quiet" do
47
+ login_scenario "one app, one environment"
48
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets', :quiet => true)
49
+ @out.should =~ /ssh.*ls/
50
+ @out.should_not =~ /Loading application data/
51
+ end
52
+
45
53
  it "raises an error when there are no matching hosts" do
46
54
  login_scenario "one app, one environment, no instances"
47
55
  ey command_to_run({:ssh_command => "ls", :environment => 'giblets', :verbose => true}), :expect_failure => true
@@ -25,6 +25,21 @@ describe "ey environments" do
25
25
  @out.should =~ /Deployed by:\s+One App Many Envs/
26
26
  @out.should =~ /Started at:/
27
27
  @out.should =~ /Finished at:/
28
- @out.should =~ /This deployment was successful/
28
+ @out.should =~ /Deployment was successful/
29
+ end
30
+
31
+ it "quiets almost all of the output with --quiet" do
32
+ fast_ey %w[deploy -e giblets --ref HEAD --no-migrate]
33
+ fast_ey %w[status -e giblets -q]
34
+ @out.should_not =~ /Application:\s+rails232app/
35
+ @out.should_not =~ /Environment:\s+giblets/
36
+ @out.should_not =~ /Ref:\s+HEAD/
37
+ @out.should_not =~ /Resolved Ref:\s+resolved-HEAD/
38
+ @out.should_not =~ /Commit:\s+[a-f0-9]{40}/
39
+ @out.should_not =~ /Migrate:\s+false/
40
+ @out.should_not =~ /Deployed by:\s+One App Many Envs/
41
+ @out.should_not =~ /Started at:/
42
+ @out.should_not =~ /Finished at:/
43
+ @out.should =~ /Deployment was successful/
29
44
  end
30
45
  end
@@ -17,7 +17,7 @@ require 'net/ssh'
17
17
  require 'fakeweb'
18
18
  require 'fakeweb_matcher'
19
19
 
20
- require 'json'
20
+ require 'multi_json'
21
21
 
22
22
  # Engineyard gem
23
23
  $LOAD_PATH.unshift(File.join(EY_ROOT, "lib"))
@@ -47,7 +47,6 @@ RSpec.configure do |config|
47
47
 
48
48
  config.extend SpecHelpers::GitRepoHelpers
49
49
  config.extend SpecHelpers::Given
50
- config.extend SpecHelpers::Fixtures
51
50
 
52
51
  def clean_tmpdir
53
52
  TMPDIR.rmtree if TMPDIR.exist?
@@ -78,12 +77,6 @@ RSpec.configure do |config|
78
77
 
79
78
  end
80
79
 
81
- EY.define_git_repo("default") do |git_dir|
82
- system("echo 'source :gemcutter' > Gemfile")
83
- system("git add Gemfile")
84
- system("git commit -m 'initial commit' >/dev/null 2>&1")
85
- end
86
-
87
80
  shared_examples_for "integration" do
88
81
  use_git_repo('default')
89
82
 
@@ -24,6 +24,24 @@ module EY
24
24
  git_repo_dir_cache[name] = git_dir
25
25
  end
26
26
 
27
+ def chdir_to_repo(repo_name)
28
+ @_original_wd ||= []
29
+ @_original_wd << Dir.getwd
30
+ Dir.chdir(git_repo_dir(repo_name))
31
+ end
32
+
33
+ def chdir_return
34
+ Dir.chdir(@_original_wd.pop) if @_original_wd && @_original_wd.any?
35
+ end
36
+
37
+ def fixture_recipes_tgz
38
+ File.expand_path('../fixture_recipes.tgz', __FILE__)
39
+ end
40
+
41
+ def link_recipes_tgz(git_dir)
42
+ system("ln -s #{fixture_recipes_tgz} #{git_dir.join('recipes.tgz')}")
43
+ end
44
+
27
45
  protected
28
46
 
29
47
  def git_repo_setup
@@ -34,4 +52,64 @@ module EY
34
52
  @git_repo_dir_cache ||= {}
35
53
  end
36
54
  end
55
+
56
+ define_git_repo("default") do |git_dir|
57
+ system("echo 'source :gemcutter' > Gemfile")
58
+ system("git add Gemfile")
59
+ system("git commit -m 'initial commit' >/dev/null 2>&1")
60
+ end
61
+
62
+ define_git_repo('deploy test') do
63
+ # we'll have one commit on master
64
+ system("echo 'source :gemcutter' > Gemfile")
65
+ system("git add Gemfile")
66
+ system("git commit -m 'initial commit' >/dev/null 2>&1")
67
+
68
+ # and a tag
69
+ system("git tag -a -m 'version one' v1")
70
+
71
+ # and we need a non-master branch
72
+ system("git checkout -b current-branch >/dev/null 2>&1")
73
+ end
74
+
75
+ define_git_repo('+cookbooks') do |git_dir|
76
+ git_dir.join("cookbooks").mkdir
77
+ git_dir.join("cookbooks/file").open("w") {|f| f << "boo" }
78
+ end
79
+
80
+ define_git_repo('+recipes') do |git_dir|
81
+ link_recipes_tgz(git_dir)
82
+ end
83
+
84
+ define_git_repo "only cookbooks, no remotes" do |git_dir|
85
+ `git --git-dir "#{git_dir}/.git" remote`.split("\n").each do |remote|
86
+ `git --git-dir "#{git_dir}/.git" remote rm #{remote}`
87
+ end
88
+
89
+ git_dir.join("cookbooks").mkdir
90
+ File.open(git_dir.join("cookbooks/file"), "w"){|f| f << "stuff" }
91
+ end
92
+
93
+ define_git_repo "only cookbooks, unrelated remotes" do |git_dir|
94
+ `git --git-dir "#{git_dir}/.git" remote`.split("\n").each do |remote|
95
+ `git --git-dir "#{git_dir}/.git" remote rm #{remote}`
96
+ end
97
+
98
+ `git remote add origin polly@pirate.example.com:wanna/cracker.git`
99
+
100
+ git_dir.join("cookbooks").mkdir
101
+ File.open(git_dir.join("cookbooks/file"), "w"){|f| f << "rawk" }
102
+ end
103
+
104
+ define_git_repo('dup test') do
105
+ system("git remote add dup git://github.com/engineyard/dup.git")
106
+ end
107
+
108
+ define_git_repo("not actually a git repo") do |git_dir|
109
+ # in case we screw up and are not in a freshly-generated test
110
+ # git repository, don't blow away the thing we're developing
111
+ system("rm -rf .git") if `git remote -v`.include?("path/to/repo.git")
112
+ git_dir.join("cookbooks").mkdir
113
+ link_recipes_tgz(git_dir)
114
+ end
37
115
  end
@@ -12,16 +12,6 @@ module SpecHelpers
12
12
  end
13
13
  end
14
14
 
15
- module Fixtures
16
- def fixture_recipes_tgz
17
- File.expand_path('../fixture_recipes.tgz', __FILE__)
18
- end
19
-
20
- def link_recipes_tgz(git_dir)
21
- system("ln -s #{fixture_recipes_tgz} #{git_dir.join('recipes.tgz')}")
22
- end
23
- end
24
-
25
15
  module IntegrationHelpers
26
16
  def run_ey(command_options, ey_options={})
27
17
 
@@ -55,13 +45,11 @@ module SpecHelpers
55
45
 
56
46
  def use_git_repo(repo_name)
57
47
  before(:all) do
58
- @_original_wd ||= []
59
- @_original_wd << Dir.getwd
60
- Dir.chdir(EY.git_repo_dir(repo_name))
48
+ EY.chdir_to_repo(repo_name)
61
49
  end
62
50
 
63
51
  after(:all) do
64
- Dir.chdir(@_original_wd.pop)
52
+ EY.chdir_return
65
53
  end
66
54
  end
67
55
  end
@@ -93,11 +81,11 @@ module SpecHelpers
93
81
  ensure_eyrc
94
82
 
95
83
  begin
84
+ debug = options[:debug] ? 'true' : nil
96
85
  err, out = StringIO.new, StringIO.new
97
- debug = options[:debug] == false ? nil : 'true'
98
86
  capture_stderr_into(err) do
99
87
  capture_stdout_into(out) do
100
- with_env('DEBUG' => debug) do
88
+ with_env('DEBUG' => debug, 'PRINT_CMD' => 'true') do
101
89
  EY::CLI.start(args)
102
90
  end
103
91
  end
@@ -145,7 +133,8 @@ module SpecHelpers
145
133
  path_prepends = options[:prepend_to_path]
146
134
 
147
135
  ey_env = {
148
- 'DEBUG' => 'true',
136
+ 'DEBUG' => ENV['DEBUG'],
137
+ 'PRINT_CMD' => 'true',
149
138
  'EYRC' => ENV['EYRC'],
150
139
  'CLOUD_URL' => ENV['CLOUD_URL'],
151
140
  }
@@ -282,7 +271,7 @@ module SpecHelpers
282
271
  if ENV.has_key?(k)
283
272
  old_env_vars[k] = ENV[k]
284
273
  end
285
- ENV[k] = v
274
+ ENV[k] = v if v
286
275
  end
287
276
 
288
277
  retval = yield
@@ -1,11 +1,6 @@
1
1
  require 'ostruct'
2
2
 
3
3
  shared_examples_for "it has an ambiguous git repo" do
4
-
5
- define_git_repo('dup test') do
6
- system("git remote add dup git://github.com/engineyard/dup.git")
7
- end
8
-
9
4
  use_git_repo('dup test')
10
5
 
11
6
  before(:all) do
@@ -141,15 +136,6 @@ shared_examples_for "it takes an environment name" do
141
136
  end
142
137
 
143
138
  context "outside a git repo" do
144
-
145
- define_git_repo("not actually a git repo") do |git_dir|
146
- # in case we screw up and are not in a freshly-generated test
147
- # git repository, don't blow away the thing we're developing
148
- system("rm -rf .git") if `git remote -v`.include?("path/to/repo.git")
149
- git_dir.join("cookbooks").mkdir
150
- link_recipes_tgz(git_dir)
151
- end
152
-
153
139
  use_git_repo("not actually a git repo")
154
140
 
155
141
  before :all do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.9
4
+ version: 2.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-29 00:00:00.000000000 Z
12
+ date: 2012-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -43,22 +43,6 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: 1.6.1
46
- - !ruby/object:Gem::Dependency
47
- name: json_pure
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
46
  - !ruby/object:Gem::Dependency
63
47
  name: escape
64
48
  requirement: !ruby/object:Gem::Requirement
@@ -242,7 +226,7 @@ dependencies:
242
226
  requirements:
243
227
  - - ~>
244
228
  - !ruby/object:Gem::Version
245
- version: 0.2.2
229
+ version: 1.0.0
246
230
  type: :development
247
231
  prerelease: false
248
232
  version_requirements: !ruby/object:Gem::Requirement
@@ -250,7 +234,7 @@ dependencies:
250
234
  requirements:
251
235
  - - ~>
252
236
  - !ruby/object:Gem::Version
253
- version: 0.2.2
237
+ version: 1.0.0
254
238
  - !ruby/object:Gem::Dependency
255
239
  name: open4
256
240
  requirement: !ruby/object:Gem::Requirement
@@ -299,6 +283,22 @@ dependencies:
299
283
  - - ! '>='
300
284
  - !ruby/object:Gem::Version
301
285
  version: '0'
286
+ - !ruby/object:Gem::Dependency
287
+ name: multi_json
288
+ requirement: !ruby/object:Gem::Requirement
289
+ none: false
290
+ requirements:
291
+ - - ! '>='
292
+ - !ruby/object:Gem::Version
293
+ version: '0'
294
+ type: :development
295
+ prerelease: false
296
+ version_requirements: !ruby/object:Gem::Requirement
297
+ none: false
298
+ requirements:
299
+ - - ! '>='
300
+ - !ruby/object:Gem::Version
301
+ version: '0'
302
302
  description: This gem allows you to deploy your rails application to the Engine Yard
303
303
  cloud directly from the command line.
304
304
  email: cloud@engineyard.com
@@ -425,7 +425,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
425
425
  version: '0'
426
426
  segments:
427
427
  - 0
428
- hash: 961483598276783294
428
+ hash: 4323358539070812213
429
429
  required_rubygems_version: !ruby/object:Gem::Requirement
430
430
  none: false
431
431
  requirements:
@@ -434,7 +434,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
434
434
  version: '0'
435
435
  segments:
436
436
  - 0
437
- hash: 961483598276783294
437
+ hash: 4323358539070812213
438
438
  requirements: []
439
439
  rubyforge_project:
440
440
  rubygems_version: 1.8.24