engineyard-serverside 2.2.0.rc2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ require 'engineyard-serverside/paths'
7
7
  module EY
8
8
  module Serverside
9
9
  class Deploy::Configuration
10
- include Paths::LegacyHelpers
10
+ include Paths::LegacyHelpers # deploy hooks depend on these to be here as well. Don't remove without plenty of deprecation warnings.
11
11
 
12
12
  # Defines a fetch method for the specified key.
13
13
  # If no default and no block is specified, it means the key is required
@@ -3,21 +3,23 @@ require 'engineyard-serverside/shell/helpers'
3
3
  module EY
4
4
  module Serverside
5
5
  class DeployHook
6
+ attr_reader :config, :shell, :hook_name
7
+
6
8
  def initialize(config, shell, hook_name)
7
9
  @config, @shell, @hook_name = config, shell, hook_name
8
10
  end
9
11
 
10
12
  def hook_path
11
- @config.paths.deploy_hook(@hook_name)
13
+ config.paths.deploy_hook(hook_name)
12
14
  end
13
15
 
14
16
  def callback_context
15
- @context ||= CallbackContext.new(@config, @shell, hook_path)
17
+ @context ||= CallbackContext.new(config, shell, hook_path)
16
18
  end
17
19
 
18
20
  def call
19
21
  if hook_path.exist?
20
- Dir.chdir(@config.paths.active_release.to_s) do
22
+ Dir.chdir(config.paths.active_release.to_s) do
21
23
  if desc = syntax_error(hook_path)
22
24
  hook_name = hook_path.basename
23
25
  abort "*** [Error] Invalid Ruby syntax in hook: #{hook_name} ***\n*** #{desc.chomp} ***"
@@ -29,14 +31,24 @@ module EY
29
31
  end
30
32
 
31
33
  def eval_hook(code)
34
+ display_deprecation_warnings(code)
32
35
  callback_context.instance_eval(code)
33
36
  rescue Exception => exception
34
37
  display_hook_error(exception, code, hook_path)
35
38
  raise exception
36
39
  end
37
40
 
41
+ def display_deprecation_warnings(code)
42
+ if code =~ /@configuration/
43
+ shell.warning("Use of `@configuration` in deploy hooks is deprecated.\nPlease use `config`, which provides access to the same object.\n\tin #{hook_path}")
44
+ end
45
+ if code =~ /@node/
46
+ shell.warning("Use of `@node` in deploy hooks is deprecated.\nPlease use `config.node`, which provides access to the same object.\n\tin #{hook_path}")
47
+ end
48
+ end
49
+
38
50
  def display_hook_error(exception, code, hook_path)
39
- @shell.fatal <<-ERROR
51
+ shell.fatal <<-ERROR
40
52
  Exception raised in deploy hook #{hook_path}.
41
53
 
42
54
  #{exception.class}: #{exception.to_s}
@@ -53,13 +65,13 @@ Please fix this error before retrying.
53
65
  class CallbackContext
54
66
  include EY::Serverside::Shell::Helpers
55
67
 
56
- attr_reader :shell
68
+ attr_reader :shell, :hook_path
57
69
 
58
70
  def initialize(config, shell, hook_path)
59
71
  @configuration = config
60
72
  @configuration.set_framework_envs
61
73
  @shell = shell
62
- @node = node
74
+ @node = config.node
63
75
  @hook_path = hook_path
64
76
  end
65
77
 
@@ -73,6 +85,7 @@ Please fix this error before retrying.
73
85
 
74
86
  def method_missing(meth, *args, &blk)
75
87
  if @configuration.respond_to?(meth)
88
+ shell.warning "Use of `#{meth}` (via method_missing) is deprecated in favor of `config.#{meth}` for improved error messages and compatibility.\n\tin #{hook_path}"
76
89
  @configuration.send(meth, *args, &blk)
77
90
  else
78
91
  super
@@ -34,7 +34,7 @@ module EY
34
34
  end
35
35
 
36
36
  def reusable?
37
- previous_assets_path.directory? && previous_assets_path.entries.any?
37
+ previous_assets_path && previous_assets_path.entries.any?
38
38
  end
39
39
 
40
40
  def reuse
@@ -47,8 +47,11 @@ module EY
47
47
  # This results in the directory structure:
48
48
  # deploy_root/current/public/last_assets/assets -> deploy_root/releases/<prev>/public/assets
49
49
  def prepare
50
- last = paths.public.join('last_assets')
51
- run "mkdir -p #{last} && ln -nfs #{previous_assets_path} #{last.join('assets')}"
50
+ if previous_assets_path
51
+ last = paths.public.join('last_assets')
52
+ run "mkdir -p #{last} && ln -nfs #{previous_assets_path} #{last.join('assets')}"
53
+ end
54
+
52
55
  yield
53
56
  end
54
57
 
@@ -58,8 +61,17 @@ module EY
58
61
  runner.run cmd
59
62
  end
60
63
 
64
+ # Just to be safe, we don't check the real path until runtime
65
+ # to make sure the relevant directories are there.
61
66
  def previous_assets_path
62
- paths.previous_release(paths.active_release).join('public','assets')
67
+ return @previous_assets_path if defined? @previous_assets_path
68
+ if prev = paths.previous_release(paths.active_release)
69
+ @previous_assets_path = prev.join('public','assets')
70
+ @previous_assets_path = nil unless @previous_assets_path.directory?
71
+ else
72
+ @previous_assets_path = nil
73
+ end
74
+ @previous_assets_path
63
75
  end
64
76
  end
65
77
 
@@ -2,7 +2,6 @@ require 'logger'
2
2
  require 'pathname'
3
3
  require 'open3'
4
4
  require 'engineyard-serverside/shell/formatter'
5
- require 'engineyard-serverside/shell/command_result'
6
5
  require 'engineyard-serverside/shell/yieldio'
7
6
 
8
7
  module EY
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module Serverside
3
- VERSION = '2.2.0.rc2'
3
+ VERSION = '2.2.0'
4
4
  end
5
5
  end
@@ -119,6 +119,13 @@ describe "deploy hooks" do
119
119
  deploy_hook.eval_hook('respond_to?(:failed_release_dir)').should be_true
120
120
  deploy_hook.eval_hook('respond_to?(:release_path) ').should be_true
121
121
  end
122
+
123
+ it "shows a deprecation warning that asks you to use config to access these variables" do
124
+ deploy_hook.eval_hook('shared_path.nil?').should be_false
125
+ out = read_output
126
+ out.should include("Use of `shared_path` (via method_missing) is deprecated in favor of `config.shared_path` for improved error messages and compatibility.")
127
+ out.should =~ %r|in /data/app_name/releases/\d+/deploy/fake_test_hook.rb|
128
+ end
122
129
  end
123
130
 
124
131
  context "access to command line options that should be handed through to the config" do
@@ -139,7 +146,7 @@ describe "deploy hooks" do
139
146
  end
140
147
  end
141
148
 
142
- context "the @node ivar" do
149
+ context "node" do
143
150
  before(:each) do
144
151
  EY::Serverside.dna_json = MultiJson.dump({
145
152
  'instance_role' => 'solo',
@@ -152,35 +159,51 @@ describe "deploy hooks" do
152
159
  })
153
160
  end
154
161
 
155
- it "is available" do
162
+ it "is deprecated through the @node ivar" do
156
163
  deploy_hook.eval_hook('@node.nil?').should be_false
164
+ out = read_output
165
+ out.should =~ %r|Use of `@node` in deploy hooks is deprecated.|
166
+ out.should =~ %r|Please use `config.node`, which provides access to the same object.|
167
+ out.should =~ %r|/data/app_name/releases/\d+/deploy/fake_test_hook.rb|
168
+ end
169
+
170
+ it "is available" do
171
+ deploy_hook.eval_hook('config.node.nil?').should be_false
157
172
  end
158
173
 
159
174
  it "has indifferent access" do
160
- deploy_hook.eval_hook('@node[:instance_role] ').should == 'solo'
161
- deploy_hook.eval_hook('@node["instance_role"]').should == 'solo'
175
+ deploy_hook.eval_hook('config.node[:instance_role] ').should == 'solo'
176
+ deploy_hook.eval_hook('config.node["instance_role"]').should == 'solo'
162
177
  end
163
178
 
164
179
  it "has deep indifferent access" do
165
- deploy_hook.eval_hook('@node["applications"]["myapp"]["type"]').should == 'rails'
166
- deploy_hook.eval_hook('@node[:applications]["myapp"][:type] ').should == 'rails'
167
- deploy_hook.eval_hook('@node[:applications][:myapp][:type] ').should == 'rails'
180
+ deploy_hook.eval_hook('config.node["applications"]["myapp"]["type"]').should == 'rails'
181
+ deploy_hook.eval_hook('config.node[:applications]["myapp"][:type] ').should == 'rails'
182
+ deploy_hook.eval_hook('config.node[:applications][:myapp][:type] ').should == 'rails'
168
183
  end
169
184
  end
170
185
 
171
- context "the @configuration ivar" do
186
+ context "config" do
172
187
  it "is available" do
188
+ deploy_hook.eval_hook('config.nil?').should be_false
189
+ end
190
+
191
+ it "is deprecated through the @configuration ivar" do
173
192
  deploy_hook.eval_hook('@configuration.nil?').should be_false
193
+ out = read_output
194
+ out.should =~ %r|Use of `@configuration` in deploy hooks is deprecated.|
195
+ out.should =~ %r|Please use `config`, which provides access to the same object.|
196
+ out.should =~ %r|/data/app_name/releases/\d+/deploy/fake_test_hook.rb|
174
197
  end
175
198
 
176
199
  it "has the configuration in it" do
177
- deploy_hook('bert' => 'ernie').eval_hook('@configuration.bert').should == 'ernie'
200
+ deploy_hook('bert' => 'ernie').eval_hook('config.bert').should == 'ernie'
178
201
  end
179
202
 
180
203
  it "can be accessed with method calls, with [:symbols], or ['strings']" do
181
- deploy_hook('bert' => 'ernie').eval_hook('@configuration.bert ').should == 'ernie'
182
- deploy_hook('bert' => 'ernie').eval_hook('@configuration[:bert] ').should == 'ernie'
183
- deploy_hook('bert' => 'ernie').eval_hook('@configuration["bert"]').should == 'ernie'
204
+ deploy_hook('bert' => 'ernie').eval_hook('config.bert ').should == 'ernie'
205
+ deploy_hook('bert' => 'ernie').eval_hook('config[:bert] ').should == 'ernie'
206
+ deploy_hook('bert' => 'ernie').eval_hook('config["bert"]').should == 'ernie'
184
207
  end
185
208
 
186
209
  [:repository_cache,
@@ -192,7 +215,7 @@ describe "deploy hooks" do
192
215
  :revision,
193
216
  :environment].each do |attribute|
194
217
  it "has the #{attribute.inspect} attribute for compatibility with chef-deploy" do
195
- deploy_hook.eval_hook("@configuration.has_key?(#{attribute.inspect})").should be_true
218
+ deploy_hook.eval_hook("config.has_key?(#{attribute.inspect})").should be_true
196
219
  end
197
220
  end
198
221
  end
@@ -1,5 +1,6 @@
1
1
  desc 'Precompile yar assetz'
2
2
  task 'assets:precompile' do
3
+ sh "mkdir -p #{File.expand_path('../public/assets', __FILE__)}"
3
4
  sh "touch #{File.expand_path('../public/assets/compiled_asset', __FILE__)}"
4
5
  sh 'touch precompiled'
5
6
  end
@@ -58,6 +58,21 @@ describe "Deploying a Rails 3.1 application" do
58
58
  deploy_dir.join('current', 'public', 'assets', 'compiled_asset').should exist
59
59
  read_output.should_not =~ %r#Reusing existing assets#
60
60
  end
61
+
62
+ %w[cleaning shared private].each do |strategy|
63
+ it "precompiles assets with asset_strategy '#{strategy}', then reuses them on the next deploy if nothing has changed" do
64
+ deploy_test_application('assets_enabled_in_ey_yml', 'config' => {'asset_strategy' => strategy})
65
+ deploy_dir.join('current', 'precompiled').should exist
66
+ deploy_dir.join('current', 'public', 'assets').should exist
67
+ deploy_dir.join('current', 'public', 'assets', 'compiled_asset').should exist
68
+
69
+ redeploy_test_application
70
+ deploy_dir.join('current', 'precompiled').should_not exist # doesn't run the task
71
+ deploy_dir.join('current', 'public', 'assets').should exist # but the assets are there
72
+ deploy_dir.join('current', 'public', 'assets', 'compiled_asset').should exist
73
+ read_output.should =~ %r#Reusing existing assets\. \(configured asset_dependencies unchanged from \w{7}..\w{7}\)#
74
+ end
75
+ end
61
76
  end
62
77
 
63
78
  context "with asset compilation enabled in ey.yml, despite not otherwise being enabled" do
@@ -102,7 +117,7 @@ describe "Deploying a Rails 3.1 application" do
102
117
 
103
118
  it "deploys successfully when application.rb has utf-8 encoding" do
104
119
  deploy_test_application('assets_disabled_utf8')
105
- deploy_dir.join('current', 'precompiled').should exist
120
+ deploy_dir.join('current', 'precompiled').should_not exist
106
121
  read_output.should include("Skipping asset precompilation. ('config/application.rb' disables assets.)")
107
122
  end
108
123
  end
metadata CHANGED
@@ -1,151 +1,151 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: engineyard-serverside
3
- version: !ruby/object:Gem::Version
4
- version: 2.2.0.rc2
5
- prerelease: 6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
+ prerelease:
6
+ segments:
7
+ - 2
8
+ - 2
9
+ - 0
10
+ version: 2.2.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - EY Cloud Team
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-07-11 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-07-25 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: rspec
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 2.12.0
22
- type: :development
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
- requirements:
25
+ requirements:
27
26
  - - ~>
28
- - !ruby/object:Gem::Version
27
+ - !ruby/object:Gem::Version
28
+ hash: 63
29
+ segments:
30
+ - 2
31
+ - 12
32
+ - 0
29
33
  version: 2.12.0
30
- - !ruby/object:Gem::Dependency
31
- name: rake
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
34
  type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
39
38
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
39
+ requirement: &id002 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: rdoc
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
54
48
  type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rdoc
55
52
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: timecop
64
- requirement: !ruby/object:Gem::Requirement
53
+ requirement: &id003 !ruby/object:Gem::Requirement
65
54
  none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
70
62
  type: :development
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: timecop
71
66
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: simplecov
80
- requirement: !ruby/object:Gem::Requirement
67
+ requirement: &id004 !ruby/object:Gem::Requirement
81
68
  none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
69
+ requirements:
70
+ - - "="
71
+ - !ruby/object:Gem::Version
72
+ hash: 5
73
+ segments:
74
+ - 0
75
+ - 6
76
+ - 1
77
+ version: 0.6.1
86
78
  type: :development
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: simplecov
87
82
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: engineyard-cloud-client
96
- requirement: !ruby/object:Gem::Requirement
83
+ requirement: &id005 !ruby/object:Gem::Requirement
97
84
  none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- version: 1.0.11
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
102
92
  type: :development
93
+ version_requirements: *id005
94
+ - !ruby/object:Gem::Dependency
95
+ name: engineyard-cloud-client
103
96
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
97
+ requirement: &id006 !ruby/object:Gem::Requirement
105
98
  none: false
106
- requirements:
99
+ requirements:
107
100
  - - ~>
108
- - !ruby/object:Gem::Version
101
+ - !ruby/object:Gem::Version
102
+ hash: 1
103
+ segments:
104
+ - 1
105
+ - 0
106
+ - 11
109
107
  version: 1.0.11
110
- - !ruby/object:Gem::Dependency
111
- name: engineyard-serverside-adapter
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- version: 2.0.6
118
108
  type: :development
109
+ version_requirements: *id006
110
+ - !ruby/object:Gem::Dependency
111
+ name: engineyard-serverside-adapter
119
112
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
113
+ requirement: &id007 !ruby/object:Gem::Requirement
121
114
  none: false
122
- requirements:
115
+ requirements:
123
116
  - - ~>
124
- - !ruby/object:Gem::Version
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 2
121
+ - 0
122
+ - 6
125
123
  version: 2.0.6
126
- - !ruby/object:Gem::Dependency
127
- name: sqlite3
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
124
  type: :development
125
+ version_requirements: *id007
126
+ - !ruby/object:Gem::Dependency
127
+ name: sqlite3
135
128
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
129
+ requirement: &id008 !ruby/object:Gem::Requirement
137
130
  none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ type: :development
139
+ version_requirements: *id008
142
140
  description:
143
141
  email: cloud@engineyard.com
144
- executables:
142
+ executables:
145
143
  - engineyard-serverside
146
144
  extensions: []
145
+
147
146
  extra_rdoc_files: []
148
- files:
147
+
148
+ files:
149
149
  - bin/engineyard-serverside
150
150
  - lib/engineyard-serverside/about.rb
151
151
  - lib/engineyard-serverside/cli.rb
@@ -167,7 +167,6 @@ files:
167
167
  - lib/engineyard-serverside/rails_assets.rb
168
168
  - lib/engineyard-serverside/server.rb
169
169
  - lib/engineyard-serverside/servers.rb
170
- - lib/engineyard-serverside/shell/command_result.rb
171
170
  - lib/engineyard-serverside/shell/formatter.rb
172
171
  - lib/engineyard-serverside/shell/helpers.rb
173
172
  - lib/engineyard-serverside/shell/yieldio.rb
@@ -390,29 +389,40 @@ files:
390
389
  - spec/support/integration.rb
391
390
  homepage: http://github.com/engineyard/engineyard-serverside
392
391
  licenses: []
392
+
393
393
  post_install_message:
394
394
  rdoc_options: []
395
- require_paths:
395
+
396
+ require_paths:
396
397
  - lib
397
- required_ruby_version: !ruby/object:Gem::Requirement
398
+ required_ruby_version: !ruby/object:Gem::Requirement
398
399
  none: false
399
- requirements:
400
- - - ! '>='
401
- - !ruby/object:Gem::Version
402
- version: '0'
403
- required_rubygems_version: !ruby/object:Gem::Requirement
400
+ requirements:
401
+ - - ">="
402
+ - !ruby/object:Gem::Version
403
+ hash: 3
404
+ segments:
405
+ - 0
406
+ version: "0"
407
+ required_rubygems_version: !ruby/object:Gem::Requirement
404
408
  none: false
405
- requirements:
406
- - - ! '>='
407
- - !ruby/object:Gem::Version
409
+ requirements:
410
+ - - ">="
411
+ - !ruby/object:Gem::Version
412
+ hash: 23
413
+ segments:
414
+ - 1
415
+ - 3
416
+ - 6
408
417
  version: 1.3.6
409
418
  requirements: []
419
+
410
420
  rubyforge_project:
411
421
  rubygems_version: 1.8.25
412
422
  signing_key:
413
423
  specification_version: 3
414
424
  summary: A gem that deploys ruby applications on EY Cloud instances
415
- test_files:
425
+ test_files:
416
426
  - spec/basic_deploy_spec.rb
417
427
  - spec/bundler_deploy_spec.rb
418
428
  - spec/configuration_spec.rb
@@ -1,16 +0,0 @@
1
- module EY
2
- module Serverside
3
- class Shell
4
- class CommandResult < Struct.new(:command, :success, :output, :server)
5
- alias success? success
6
-
7
- def inspect
8
- <<-EOM
9
- $ #{success? ? "(success)" : "(failed)"} #{command}
10
- #{output}
11
- EOM
12
- end
13
- end
14
- end
15
- end
16
- end