engineyard-serverside 1.6.5 → 1.7.0.pre2
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.
- data/lib/engineyard-serverside.rb +2 -0
- data/lib/engineyard-serverside/cli.rb +83 -48
- data/lib/engineyard-serverside/configuration.rb +85 -18
- data/lib/engineyard-serverside/deploy.rb +105 -91
- data/lib/engineyard-serverside/deploy_hook.rb +22 -20
- data/lib/engineyard-serverside/deprecation.rb +9 -17
- data/lib/engineyard-serverside/future.rb +10 -4
- data/lib/engineyard-serverside/futures/celluloid.rb +3 -13
- data/lib/engineyard-serverside/futures/dataflow.rb +8 -13
- data/lib/engineyard-serverside/lockfile_parser.rb +1 -1
- data/lib/engineyard-serverside/rails_asset_support.rb +26 -10
- data/lib/engineyard-serverside/server.rb +17 -12
- data/lib/engineyard-serverside/shell.rb +98 -0
- data/lib/engineyard-serverside/shell/formatter.rb +71 -0
- data/lib/engineyard-serverside/shell/helpers.rb +29 -0
- data/lib/engineyard-serverside/strategies/git.rb +33 -63
- data/lib/engineyard-serverside/task.rb +34 -13
- data/lib/engineyard-serverside/version.rb +1 -1
- data/spec/basic_deploy_spec.rb +15 -50
- data/spec/bundler_deploy_spec.rb +3 -44
- data/spec/configuration_spec.rb +72 -0
- data/spec/custom_deploy_spec.rb +3 -4
- data/spec/deploy_hook_spec.rb +210 -162
- data/spec/deprecation_spec.rb +4 -26
- data/spec/ey_yml_customized_deploy_spec.rb +68 -0
- data/spec/fixtures/repos/assets_disabled/Gemfile +6 -0
- data/spec/fixtures/repos/assets_disabled/Gemfile.lock +90 -0
- data/spec/fixtures/repos/assets_disabled/README +1 -0
- data/spec/fixtures/repos/assets_disabled/Rakefile +5 -0
- data/spec/fixtures/repos/assets_disabled/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +6 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +90 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +1 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +5 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +4 -0
- data/spec/fixtures/repos/assets_enabled/Gemfile +6 -0
- data/spec/fixtures/repos/assets_enabled/Gemfile.lock +90 -0
- data/spec/fixtures/repos/assets_enabled/README +1 -0
- data/spec/fixtures/repos/assets_enabled/Rakefile +5 -0
- data/spec/fixtures/repos/assets_enabled/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +1 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +5 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +4 -0
- data/spec/fixtures/repos/assets_in_hook/Gemfile +6 -0
- data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +90 -0
- data/spec/fixtures/repos/assets_in_hook/README +2 -0
- data/spec/fixtures/repos/assets_in_hook/Rakefile +5 -0
- data/spec/fixtures/repos/assets_in_hook/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_in_hook/deploy/before_migrate.rb +1 -0
- data/spec/fixtures/repos/default/Gemfile +5 -0
- data/spec/fixtures/repos/default/Gemfile.lock +14 -0
- data/spec/fixtures/repos/default/README +5 -0
- data/spec/fixtures/repos/ey_yml/Gemfile +4 -0
- data/spec/fixtures/repos/ey_yml/Gemfile.lock +12 -0
- data/spec/fixtures/repos/ey_yml/README +1 -0
- data/spec/fixtures/repos/ey_yml/config/ey.yml +12 -0
- data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +6 -0
- data/spec/fixtures/repos/ey_yml_alt/Gemfile +4 -0
- data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +12 -0
- data/spec/fixtures/repos/ey_yml_alt/README +1 -0
- data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +6 -0
- data/spec/fixtures/repos/ey_yml_alt/ey.yml +12 -0
- data/spec/fixtures/repos/hook_fails/README +1 -0
- data/spec/fixtures/repos/hook_fails/deploy/before_migrate.rb +1 -0
- data/spec/fixtures/repos/hooks/README +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_restart.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_restart.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +1 -0
- data/spec/fixtures/repos/no_ey_config/Gemfile +4 -0
- data/spec/fixtures/repos/no_ey_config/Gemfile.lock +12 -0
- data/spec/fixtures/repos/no_ey_config/README +1 -0
- data/spec/fixtures/repos/no_gemfile_lock/Gemfile +5 -0
- data/spec/fixtures/repos/no_gemfile_lock/README +1 -0
- data/spec/fixtures/repos/nodejs/README +1 -0
- data/spec/fixtures/repos/nodejs/package.json +7 -0
- data/spec/fixtures/repos/not_bundled/README +1 -0
- data/spec/fixtures/{gemfiles/1.0.21-rails-31-with-sqlite → repos/sqlite3/Gemfile} +0 -0
- data/spec/fixtures/{lockfiles/1.0.21-rails-31-with-sqlite → repos/sqlite3/Gemfile.lock} +0 -0
- data/spec/fixtures/repos/sqlite3/README +1 -0
- data/spec/git_strategy_spec.rb +11 -2
- data/spec/lockfile_parser_spec.rb +8 -3
- data/spec/nodejs_deploy_spec.rb +1 -26
- data/spec/rails31_deploy_spec.rb +23 -31
- data/spec/services_deploy_spec.rb +41 -100
- data/spec/shell_spec.rb +50 -0
- data/spec/spec_helper.rb +80 -66
- data/spec/sqlite3_deploy_spec.rb +10 -16
- data/spec/support/integration.rb +45 -139
- metadata +233 -78
- data/lib/engineyard-serverside/logged_output.rb +0 -91
- data/spec/logged_output_spec.rb +0 -55
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module EY
|
|
2
|
+
module Serverside
|
|
3
|
+
class Shell
|
|
4
|
+
class Formatter
|
|
5
|
+
def initialize(stdout, stderr, start_time, verbose)
|
|
6
|
+
@stdout, @stderr = stdout, stderr
|
|
7
|
+
@start = start_time.to_i
|
|
8
|
+
@verbose = verbose
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call(severity, time, _, message)
|
|
12
|
+
msg = build_message(severity, timestamp(time), message)
|
|
13
|
+
put_to_io(severity, msg)
|
|
14
|
+
msg
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def build_message(severity, stamp, message)
|
|
18
|
+
if %w[WARN ERROR FATAL].include?(severity)
|
|
19
|
+
prepend("#{stamp}!> ", "#{message}")
|
|
20
|
+
elsif severity == "INFO"
|
|
21
|
+
prepend(stamp, message)
|
|
22
|
+
else
|
|
23
|
+
prepend(' ' * stamp.size, message)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def prepend(pre, str)
|
|
28
|
+
str.gsub(/^/, pre).sub(/\n?\z/m,"\n")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def put_to_io(severity, msg)
|
|
32
|
+
case severity
|
|
33
|
+
when "DEBUG"
|
|
34
|
+
if @verbose
|
|
35
|
+
@stdout << msg
|
|
36
|
+
end
|
|
37
|
+
when "INFO"
|
|
38
|
+
# Need to differentiate info messages more when we're running in verbose mode
|
|
39
|
+
@stdout << (@verbose && msg.index('~>') ? "\n#{thor_shell.set_color(msg, :white, true)}" : msg)
|
|
40
|
+
@stdout.flush
|
|
41
|
+
when "WARN"
|
|
42
|
+
@stderr << "\n" << thor_shell.set_color(msg, :yellow, true)
|
|
43
|
+
@stderr.flush
|
|
44
|
+
when "ERROR"
|
|
45
|
+
@stderr << "\n" << thor_shell.set_color(msg, :red, true)
|
|
46
|
+
@stderr.flush
|
|
47
|
+
else
|
|
48
|
+
@stderr << msg
|
|
49
|
+
@stderr.flush
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def timestamp(datetime)
|
|
54
|
+
diff = datetime.to_i - @start
|
|
55
|
+
diff = 0 if diff < 0
|
|
56
|
+
div, mod = diff.divmod(60)
|
|
57
|
+
if div.zero?
|
|
58
|
+
"+ %02ds " % mod
|
|
59
|
+
else
|
|
60
|
+
"+%2dm %02ds " % [div,mod]
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def thor_shell
|
|
65
|
+
thor_shell ||= Thor::Shell::Color.new
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module EY
|
|
2
|
+
module Serverside
|
|
3
|
+
class Shell
|
|
4
|
+
# Compatibility with old LoggedOutput where the module was included into the class.
|
|
5
|
+
module Helpers
|
|
6
|
+
def verbose?
|
|
7
|
+
shell.verbose?
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def warning(*a)
|
|
11
|
+
shell.warning(*a)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def info(*a)
|
|
15
|
+
shell.info(*a)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def debug(*a)
|
|
19
|
+
shell.debug(*a)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def logged_system(*a)
|
|
23
|
+
shell.logged_system(*a)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
@@ -1,82 +1,48 @@
|
|
|
1
|
-
require 'engineyard-serverside/logged_output'
|
|
2
|
-
|
|
3
1
|
module EY
|
|
4
2
|
module Serverside
|
|
5
3
|
module Strategies
|
|
6
4
|
class Git
|
|
7
|
-
|
|
8
|
-
def update_repository_cache
|
|
9
|
-
unless strategy.fetch && strategy.checkout
|
|
10
|
-
abort "*** [Error] Git could not checkout (#{strategy.to_checkout}) ***"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def create_revision_file_command
|
|
15
|
-
strategy.create_revision_file_command(c.release_path)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def short_log_message(revision)
|
|
19
|
-
strategy.short_log_message(revision)
|
|
20
|
-
end
|
|
5
|
+
attr_reader :shell, :opts
|
|
21
6
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
klass = Module.nesting[1]
|
|
26
|
-
# Use [] to access attributes instead of calling methods so
|
|
27
|
-
# that we get nils instead of NoMethodError.
|
|
28
|
-
#
|
|
29
|
-
# Rollback doesn't know about the repository location (nor
|
|
30
|
-
# should it need to), but it would like to use #short_log_message.
|
|
31
|
-
klass.new(
|
|
32
|
-
:repository_cache => c[:repository_cache],
|
|
33
|
-
:app => c[:app],
|
|
34
|
-
:repo => c[:repo],
|
|
35
|
-
:ref => c[:branch]
|
|
36
|
-
)
|
|
37
|
-
end
|
|
7
|
+
def initialize(shell, opts)
|
|
8
|
+
@shell = shell
|
|
9
|
+
@opts = opts
|
|
38
10
|
end
|
|
39
11
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def initialize(opts)
|
|
45
|
-
@opts = opts
|
|
12
|
+
def update_repository_cache
|
|
13
|
+
unless fetch && checkout
|
|
14
|
+
abort "*** [Error] Git could not checkout (#{to_checkout}) ***"
|
|
15
|
+
end
|
|
46
16
|
end
|
|
47
17
|
|
|
48
18
|
def usable_repository?
|
|
49
|
-
File.directory?(
|
|
19
|
+
File.directory?(repository_cache) && `#{git} remote -v | grep origin`[remote_uri]
|
|
50
20
|
end
|
|
51
21
|
|
|
52
22
|
def fetch
|
|
53
23
|
if usable_repository?
|
|
54
|
-
|
|
24
|
+
run("#{git} fetch -q origin 2>&1")
|
|
55
25
|
else
|
|
56
|
-
FileUtils.rm_rf(
|
|
57
|
-
|
|
26
|
+
FileUtils.rm_rf(repository_cache)
|
|
27
|
+
run("git clone -q #{remote_uri} #{repository_cache} 2>&1")
|
|
58
28
|
end
|
|
59
29
|
end
|
|
60
30
|
|
|
61
31
|
def checkout
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
32
|
+
shell.status "Deploying revision #{short_log_message(to_checkout)}"
|
|
33
|
+
in_repository_cache do
|
|
34
|
+
(run("git checkout -q '#{to_checkout}'") ||
|
|
35
|
+
run("git reset -q --hard '#{to_checkout}'")) &&
|
|
36
|
+
run("git submodule sync") &&
|
|
37
|
+
run("git submodule update --init") &&
|
|
38
|
+
run("git clean -dfq")
|
|
69
39
|
end
|
|
70
40
|
end
|
|
71
41
|
|
|
72
42
|
def to_checkout
|
|
73
43
|
return @to_checkout if @opts_ref == opts[:ref]
|
|
74
44
|
@opts_ref = opts[:ref]
|
|
75
|
-
@to_checkout =
|
|
76
|
-
"origin/#{opts[:ref]}"
|
|
77
|
-
else
|
|
78
|
-
opts[:ref]
|
|
79
|
-
end
|
|
45
|
+
@to_checkout = branch?(@opts_ref) ? "origin/#{@opts_ref}" : @opts_ref
|
|
80
46
|
end
|
|
81
47
|
|
|
82
48
|
def create_revision_file_command(dir)
|
|
@@ -88,24 +54,28 @@ module EY
|
|
|
88
54
|
end
|
|
89
55
|
|
|
90
56
|
private
|
|
91
|
-
def
|
|
92
|
-
|
|
57
|
+
def run(cmd)
|
|
58
|
+
shell.logged_system(cmd).success?
|
|
93
59
|
end
|
|
94
60
|
|
|
95
|
-
def
|
|
61
|
+
def in_repository_cache
|
|
62
|
+
Dir.chdir(repository_cache) { yield }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def remote_uri
|
|
66
|
+
opts[:repo]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def repository_cache
|
|
96
70
|
opts[:repository_cache]
|
|
97
71
|
end
|
|
98
72
|
|
|
99
73
|
def git
|
|
100
|
-
"git --git-dir #{
|
|
74
|
+
"git --git-dir #{repository_cache}/.git --work-tree #{repository_cache}"
|
|
101
75
|
end
|
|
102
76
|
|
|
103
77
|
def branch?(ref)
|
|
104
|
-
|
|
105
|
-
remote_branches.each_line do |line|
|
|
106
|
-
return true if line.include?("origin/#{ref}")
|
|
107
|
-
end
|
|
108
|
-
false
|
|
78
|
+
system("#{git} show-branch origin/#{ref} > /dev/null 2>&1")
|
|
109
79
|
end
|
|
110
80
|
end
|
|
111
81
|
end
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
require 'engineyard-serverside/shell/helpers'
|
|
2
|
+
|
|
1
3
|
module EY
|
|
2
4
|
module Serverside
|
|
3
5
|
class Task
|
|
4
|
-
|
|
5
|
-
attr_reader :config
|
|
6
|
+
attr_reader :config, :shell
|
|
6
7
|
alias :c :config
|
|
7
8
|
|
|
8
|
-
def initialize(conf)
|
|
9
|
+
def initialize(conf, shell = nil)
|
|
9
10
|
@config = conf
|
|
11
|
+
@shell = shell
|
|
10
12
|
@roles = :all
|
|
11
13
|
end
|
|
12
14
|
|
|
@@ -18,7 +20,7 @@ module EY
|
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
if deploy_file
|
|
21
|
-
|
|
23
|
+
shell.status "Loading deployment task overrides from #{deploy_file}"
|
|
22
24
|
instance_eval(File.read(deploy_file))
|
|
23
25
|
true
|
|
24
26
|
else
|
|
@@ -26,6 +28,25 @@ module EY
|
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
|
|
31
|
+
def load_ey_yml
|
|
32
|
+
ey_yml = ["config/ey.yml", "ey.yml"].map do |short_file|
|
|
33
|
+
File.join(c.repository_cache, short_file)
|
|
34
|
+
end.detect do |file|
|
|
35
|
+
File.exist?(file)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if ey_yml
|
|
39
|
+
shell.status "Loading deploy configuration in #{ey_yml}"
|
|
40
|
+
data = YAML.load_file(ey_yml)
|
|
41
|
+
config.load_ey_yml_data(data, shell)
|
|
42
|
+
else
|
|
43
|
+
false
|
|
44
|
+
end
|
|
45
|
+
rescue Exception
|
|
46
|
+
shell.error "Error loading YAML in #{ey_yml}"
|
|
47
|
+
raise
|
|
48
|
+
end
|
|
49
|
+
|
|
29
50
|
def roles(*task_roles)
|
|
30
51
|
raise "Roles must be passed a block" unless block_given?
|
|
31
52
|
|
|
@@ -37,26 +58,26 @@ module EY
|
|
|
37
58
|
end
|
|
38
59
|
end
|
|
39
60
|
|
|
40
|
-
# Returns +true+ if the command is successful,
|
|
41
|
-
# raises EY::Serverside::RemoteFailure with a list of failures
|
|
42
|
-
# otherwise.
|
|
43
61
|
def run(cmd, &blk)
|
|
44
|
-
run_on_roles(cmd, &blk)
|
|
62
|
+
run_on_roles('sh -l -c', cmd, &blk)
|
|
45
63
|
end
|
|
46
64
|
|
|
47
65
|
def sudo(cmd, &blk)
|
|
48
|
-
run_on_roles(
|
|
66
|
+
run_on_roles('sudo sh -l -c', cmd, &blk)
|
|
49
67
|
end
|
|
50
68
|
|
|
51
69
|
private
|
|
52
70
|
|
|
53
|
-
def run_on_roles(
|
|
71
|
+
def run_on_roles(prefix, cmd, &block)
|
|
54
72
|
servers = EY::Serverside::Server.from_roles(@roles)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
server.
|
|
73
|
+
|
|
74
|
+
commands = servers.map do |server|
|
|
75
|
+
exec_cmd = server.command_on_server(prefix, cmd, &block)
|
|
76
|
+
proc { shell.logged_system(exec_cmd) }
|
|
58
77
|
end
|
|
59
78
|
|
|
79
|
+
futures = EY::Serverside::Future.call(commands)
|
|
80
|
+
|
|
60
81
|
unless EY::Serverside::Future.success?(futures)
|
|
61
82
|
failures = futures.select {|f| f.error? }.map {|f| f.inspect}.join("\n")
|
|
62
83
|
raise EY::Serverside::RemoteFailure.new(failures)
|
data/spec/basic_deploy_spec.rb
CHANGED
|
@@ -1,54 +1,19 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe "Deploying
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"stack" => 'nginx_passenger',
|
|
19
|
-
"migrate" => nil,
|
|
20
|
-
'app' => 'foo',
|
|
21
|
-
'framework_env' => 'staging'
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
@binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
|
|
25
|
-
@deployer = FullTestDeploy.new(config)
|
|
26
|
-
@deployer.deploy
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def exist
|
|
30
|
-
be_exist
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "creates a REVISION file" do
|
|
34
|
-
@deploy_dir.join('current', 'REVISION').should exist
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "restarts the app servers" do
|
|
38
|
-
@deploy_dir.join('current', 'restart').should exist
|
|
3
|
+
describe "Deploying a simple application" do
|
|
4
|
+
context "without Bundler" do
|
|
5
|
+
before(:all) do
|
|
6
|
+
deploy_test_application('not_bundled')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "creates a REVISION file" do
|
|
10
|
+
@deploy_dir.join('current', 'REVISION').should exist
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "restarts the app servers" do
|
|
14
|
+
restart = @deploy_dir.join('current', 'restart')
|
|
15
|
+
restart.should exist
|
|
16
|
+
restart.read.chomp.should == %|LANG="en_US.UTF-8" /engineyard/bin/app_rails31 deploy|
|
|
17
|
+
end
|
|
39
18
|
end
|
|
40
|
-
|
|
41
|
-
it "runs all the hooks" do
|
|
42
|
-
@deploy_dir.join('current', 'before_bundle.ran' ).should exist
|
|
43
|
-
@deploy_dir.join('current', 'after_bundle.ran' ).should exist
|
|
44
|
-
@deploy_dir.join('current', 'before_migrate.ran').should exist
|
|
45
|
-
@deploy_dir.join('current', 'after_migrate.ran' ).should exist
|
|
46
|
-
@deploy_dir.join('current', 'before_compile_assets.ran').should exist
|
|
47
|
-
@deploy_dir.join('current', 'after_compile_assets.ran' ).should exist
|
|
48
|
-
@deploy_dir.join('current', 'before_symlink.ran').should exist
|
|
49
|
-
@deploy_dir.join('current', 'after_symlink.ran' ).should exist
|
|
50
|
-
@deploy_dir.join('current', 'before_restart.ran').should exist
|
|
51
|
-
@deploy_dir.join('current', 'after_restart.ran' ).should exist
|
|
52
|
-
end
|
|
53
|
-
|
|
54
19
|
end
|
data/spec/bundler_deploy_spec.rb
CHANGED
|
@@ -6,41 +6,9 @@ describe "Deploying an application that uses Bundler" do
|
|
|
6
6
|
@version_pattern = Regexp.quote(@bundler_version)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def deploy_test_application
|
|
10
|
-
@deploy_dir = File.join(Dir.tmpdir, "serverside-deploy-#{Time.now.to_i}-#{$$}")
|
|
11
|
-
|
|
12
|
-
# set up EY::Serverside::Server like we're on a solo
|
|
13
|
-
EY::Serverside::Server.reset
|
|
14
|
-
EY::Serverside::Server.add(:hostname => 'localhost', :roles => %w[solo])
|
|
15
|
-
|
|
16
|
-
# run a deploy
|
|
17
|
-
config = EY::Serverside::Deploy::Configuration.new({
|
|
18
|
-
"strategy" => "IntegrationSpec",
|
|
19
|
-
"deploy_to" => @deploy_dir,
|
|
20
|
-
"group" => `id -gn`.strip,
|
|
21
|
-
"stack" => 'nginx_passenger',
|
|
22
|
-
"migrate" => "ruby -e 'puts ENV[\"PATH\"]' > #{@deploy_dir}/path-when-migrating",
|
|
23
|
-
'app' => 'foo',
|
|
24
|
-
'framework_env' => 'staging',
|
|
25
|
-
'bundle_without' => 'release test',
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
# pretend there is a shared bundled_gems directory
|
|
29
|
-
FileUtils.mkdir_p(File.join(@deploy_dir, 'shared', 'bundled_gems'))
|
|
30
|
-
%w(RUBY_VERSION SYSTEM_VERSION).each do |name|
|
|
31
|
-
File.open(File.join(@deploy_dir, 'shared', 'bundled_gems', name), "w") { |f| f.write("old\n") }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
@binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
|
|
35
|
-
@deployer = FullTestDeploy.new(config)
|
|
36
|
-
@deployer.deploy
|
|
37
|
-
end
|
|
38
|
-
|
|
39
9
|
context "with a Gemfile.lock" do
|
|
40
10
|
before(:all) do
|
|
41
|
-
|
|
42
|
-
$DISABLE_LOCKFILE = false
|
|
43
|
-
deploy_test_application
|
|
11
|
+
deploy_test_application('ey_yml')
|
|
44
12
|
end
|
|
45
13
|
|
|
46
14
|
it "runs the right bundler command" do
|
|
@@ -69,12 +37,6 @@ describe "Deploying an application that uses Bundler" do
|
|
|
69
37
|
File.read(File.join(@deploy_dir, 'path-when-migrating')).should include('ey_bundler_binstubs')
|
|
70
38
|
end
|
|
71
39
|
|
|
72
|
-
it "runs 'bundle install' with custom --without options" do
|
|
73
|
-
bundle_install_cmd = @deployer.commands.grep(/bundle _\S+_ install/).first
|
|
74
|
-
bundle_install_cmd.should_not be_nil
|
|
75
|
-
bundle_install_cmd.should include("--without release test")
|
|
76
|
-
end
|
|
77
|
-
|
|
78
40
|
it "creates a ruby version file" do
|
|
79
41
|
File.exist?(File.join(@deploy_dir, 'shared', 'bundled_gems', 'RUBY_VERSION')).should be_true
|
|
80
42
|
end
|
|
@@ -90,13 +52,10 @@ describe "Deploying an application that uses Bundler" do
|
|
|
90
52
|
|
|
91
53
|
context "without a Gemfile.lock" do
|
|
92
54
|
before(:all) do
|
|
93
|
-
|
|
94
|
-
$DISABLE_LOCKFILE = true
|
|
95
|
-
deploy_test_application
|
|
55
|
+
deploy_test_application('no_gemfile_lock')
|
|
96
56
|
end
|
|
97
57
|
|
|
98
58
|
it "installs the proper Bundler version" do
|
|
99
|
-
@bundler_version.should == "1.0.21" # Something should break when the default changes.
|
|
100
59
|
install_bundler_command_ran = @deployer.commands.detect{ |command| command.index("install_bundler") }
|
|
101
60
|
install_bundler_command_ran.should_not be_nil
|
|
102
61
|
install_bundler_command_ran.should include("#{@binpath} install_bundler #{@bundler_version}")
|
|
@@ -116,7 +75,7 @@ describe "Deploying an application that uses Bundler" do
|
|
|
116
75
|
File.exist?(File.join(@deploy_dir, 'shared', 'bundled_gems', 'SYSTEM_VERSION')).should be_true
|
|
117
76
|
end
|
|
118
77
|
|
|
119
|
-
it "
|
|
78
|
+
it "sets GIT_SSH environment variable" do
|
|
120
79
|
install_cmd = @deployer.commands.grep(/GIT_SSH/).first
|
|
121
80
|
install_cmd.should match(/export GIT_SSH.*install_bundler/)
|
|
122
81
|
end
|