engineyard-serverside 2.7.0.pre → 2.7.8pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/engineyard-serverside +1 -1
- data/lib/engineyard-serverside/about.rb +8 -7
- data/lib/engineyard-serverside/cli.rb +225 -4
- data/lib/engineyard-serverside/cli_helpers.rb +53 -0
- data/lib/engineyard-serverside/configuration.rb +0 -1
- data/lib/engineyard-serverside/dependency_manager/bundler.rb +18 -46
- data/lib/engineyard-serverside/dependency_manager/npm.rb +1 -12
- data/lib/engineyard-serverside/deploy.rb +45 -7
- data/lib/engineyard-serverside/deploy_hook.rb +83 -20
- data/lib/engineyard-serverside/maintenance.rb +9 -1
- data/lib/engineyard-serverside/paths.rb +0 -11
- data/lib/engineyard-serverside/rails_assets.rb +1 -2
- data/lib/engineyard-serverside/version.rb +1 -1
- data/spec/archive_deploy_spec.rb +53 -0
- data/spec/basic_deploy_spec.rb +26 -0
- data/spec/bundler_deploy_spec.rb +139 -0
- data/spec/configuration_spec.rb +205 -0
- data/spec/custom_deploy_spec.rb +128 -0
- data/spec/deploy_hook_spec.rb +362 -0
- data/spec/deprecation_spec.rb +23 -0
- data/spec/ey_yml_customized_deploy_spec.rb +99 -0
- data/spec/fixtures/gitrepo.tar.gz +0 -0
- data/{lib/engineyard-serverside/callbacks/hooks.rb → spec/fixtures/gitrepo/bar} +0 -0
- data/spec/fixtures/gitrepo/foo +0 -0
- data/spec/fixtures/invalid_hook.rb +1 -0
- data/spec/fixtures/lockfiles/0.9-no-bundler +111 -0
- data/spec/fixtures/lockfiles/0.9-with-bundler +117 -0
- data/spec/fixtures/lockfiles/1.0-no-bundler +54 -0
- data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +162 -0
- data/spec/fixtures/lockfiles/1.0.18-do_mysql +88 -0
- data/spec/fixtures/lockfiles/1.0.18-do_postgres +79 -0
- data/spec/fixtures/lockfiles/1.0.18-mysql +43 -0
- data/spec/fixtures/lockfiles/1.0.18-mysql2 +43 -0
- data/spec/fixtures/lockfiles/1.0.18-pg +43 -0
- data/spec/fixtures/lockfiles/1.0.6-no-bundler +51 -0
- data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +52 -0
- data/spec/fixtures/lockfiles/1.0.6-with-bundler +52 -0
- data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +112 -0
- data/spec/fixtures/lockfiles/not-a-lockfile +1 -0
- data/spec/fixtures/repos/assets_detected/Gemfile +5 -0
- data/spec/fixtures/repos/assets_detected/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_detected/README +1 -0
- data/spec/fixtures/repos/assets_detected/Rakefile +5 -0
- data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_detected/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_detected/config/ey.yml +3 -0
- data/spec/fixtures/repos/assets_disabled/Gemfile +5 -0
- data/spec/fixtures/repos/assets_disabled/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_disabled/README +1 -0
- data/spec/fixtures/repos/assets_disabled/Rakefile +6 -0
- data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_disabled/config/ey.yml +3 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +5 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +1 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +6 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -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 +5 -0
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +5 -0
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_disabled_utf8/README +3 -0
- data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +5 -0
- data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +7 -0
- data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +3 -0
- data/spec/fixtures/repos/assets_enabled_all/Gemfile +5 -0
- data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_enabled_all/README +1 -0
- data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_all/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +6 -0
- data/spec/fixtures/repos/assets_enabled_all/script/assets +5 -0
- data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +1 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +3 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +10 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +1 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +8 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +4 -0
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +5 -0
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_enabled_util_only/README +1 -0
- data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +6 -0
- data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +6 -0
- data/spec/fixtures/repos/assets_in_hook/Gemfile +5 -0
- data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +88 -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/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_in_hook/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_in_hook/config/ey.yml +3 -0
- data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +2 -0
- data/spec/fixtures/repos/bundle_fails/Gemfile +1 -0
- data/spec/fixtures/repos/bundle_fails/README +1 -0
- data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +1 -0
- data/spec/fixtures/repos/bundler_disabled/Gemfile +4 -0
- data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +12 -0
- data/spec/fixtures/repos/bundler_disabled/README +1 -0
- data/spec/fixtures/repos/bundler_disabled/config/ey.yml +2 -0
- data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +1 -0
- data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +1 -0
- data/spec/fixtures/repos/default/Gemfile +4 -0
- data/spec/fixtures/repos/default/Gemfile.lock +12 -0
- data/spec/fixtures/repos/default/README +5 -0
- data/spec/fixtures/repos/default/ey.yml +3 -0
- data/spec/fixtures/repos/executable_hooks/README +1 -0
- data/spec/fixtures/repos/executable_hooks/deploy/before_restart +72 -0
- data/spec/fixtures/repos/executable_hooks_not_executable/README +3 -0
- data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +3 -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 +18 -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_deploy.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_deploy.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_deploy.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/multi_dep_manager/README +1 -0
- data/spec/fixtures/repos/multi_dep_manager/composer.json +5 -0
- data/spec/fixtures/repos/multi_dep_manager/composer.lock +462 -0
- data/spec/fixtures/repos/multi_dep_manager/package.json +7 -0
- data/spec/fixtures/repos/multi_dep_manager/public/index.php +4 -0
- data/spec/fixtures/repos/no_ey_config/Gemfile +3 -0
- data/spec/fixtures/repos/no_ey_config/Gemfile.lock +10 -0
- data/spec/fixtures/repos/no_ey_config/README +1 -0
- data/spec/fixtures/repos/no_ey_config/ey.yml +3 -0
- data/spec/fixtures/repos/no_gemfile_lock/Gemfile +4 -0
- data/spec/fixtures/repos/no_gemfile_lock/README +1 -0
- data/spec/fixtures/repos/no_gemfile_lock/ey.yml +3 -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/repos/npm_disabled/README +1 -0
- data/spec/fixtures/repos/npm_disabled/config/ey.yml +2 -0
- data/spec/fixtures/repos/npm_disabled/package.json +7 -0
- data/spec/fixtures/repos/php_composer_disabled/README +1 -0
- data/spec/fixtures/repos/php_composer_disabled/composer.json +5 -0
- data/spec/fixtures/repos/php_composer_disabled/composer.lock +462 -0
- data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +2 -0
- data/spec/fixtures/repos/php_composer_disabled/public/index.php +4 -0
- data/spec/fixtures/repos/php_composer_lock/README +1 -0
- data/spec/fixtures/repos/php_composer_lock/composer.json +5 -0
- data/spec/fixtures/repos/php_composer_lock/composer.lock +462 -0
- data/spec/fixtures/repos/php_composer_lock/public/index.php +4 -0
- data/spec/fixtures/repos/php_no_composer_lock/README +1 -0
- data/spec/fixtures/repos/php_no_composer_lock/composer.json +21 -0
- data/spec/fixtures/repos/php_no_composer_lock/public/index.php +4 -0
- data/spec/fixtures/repos/public_system/Gemfile +4 -0
- data/spec/fixtures/repos/public_system/Gemfile.lock +12 -0
- data/spec/fixtures/repos/public_system/README +5 -0
- data/spec/fixtures/repos/public_system/ey.yml +3 -0
- data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +3 -0
- data/spec/fixtures/repos/sqlite3/Gemfile +4 -0
- data/spec/fixtures/repos/sqlite3/Gemfile.lock +89 -0
- data/spec/fixtures/repos/sqlite3/README +1 -0
- data/spec/fixtures/retwisj.war +0 -0
- data/spec/fixtures/valid_hook.rb +1 -0
- data/spec/git_strategy_spec.rb +34 -0
- data/spec/lockfile_parser_spec.rb +122 -0
- data/spec/maintenance_spec.rb +44 -0
- data/spec/multi_dependency_manager_spec.rb +25 -0
- data/spec/nodejs_deploy_spec.rb +30 -0
- data/spec/php_deploy_spec.rb +81 -0
- data/spec/platform_configure_spec.rb +61 -0
- data/spec/rails31_deploy_spec.rb +164 -0
- data/spec/restart_spec.rb +43 -0
- data/spec/rollback_spec.rb +87 -0
- data/spec/server_spec.rb +70 -0
- data/spec/services_deploy_spec.rb +153 -0
- data/spec/shell_spec.rb +57 -0
- data/spec/source/archive_spec.rb +33 -0
- data/spec/source/git_spec.rb +44 -0
- data/spec/spec_helper.rb +355 -0
- data/spec/sqlite3_deploy_spec.rb +38 -0
- data/spec/support/integration.rb +103 -0
- data/spec/support/source_doubles.rb +28 -0
- data/spec/support/timecop.rb +5 -0
- data/spec/symlink_spec.rb +15 -0
- metadata +522 -184
- data/lib/engineyard-serverside/callbacks.rb +0 -11
- data/lib/engineyard-serverside/callbacks/collection.rb +0 -17
- data/lib/engineyard-serverside/callbacks/collection/base.rb +0 -94
- data/lib/engineyard-serverside/callbacks/collection/combined.rb +0 -45
- data/lib/engineyard-serverside/callbacks/collection/deploy_hooks.rb +0 -21
- data/lib/engineyard-serverside/callbacks/collection/service_hooks.rb +0 -17
- data/lib/engineyard-serverside/callbacks/collection/service_hooks/collection.rb +0 -24
- data/lib/engineyard-serverside/callbacks/collection/service_hooks/combined.rb +0 -40
- data/lib/engineyard-serverside/callbacks/distributor.rb +0 -23
- data/lib/engineyard-serverside/callbacks/distributor/base.rb +0 -38
- data/lib/engineyard-serverside/callbacks/distributor/executable.rb +0 -19
- data/lib/engineyard-serverside/callbacks/distributor/executable/runnable.rb +0 -41
- data/lib/engineyard-serverside/callbacks/distributor/executable/unrunnable.rb +0 -19
- data/lib/engineyard-serverside/callbacks/distributor/ruby.rb +0 -59
- data/lib/engineyard-serverside/callbacks/distributor/ruby/distributor.rb +0 -57
- data/lib/engineyard-serverside/callbacks/hooks/app.rb +0 -17
- data/lib/engineyard-serverside/callbacks/hooks/base.rb +0 -39
- data/lib/engineyard-serverside/callbacks/hooks/service.rb +0 -24
- data/lib/engineyard-serverside/callbacks/service_hook.rb +0 -20
- data/lib/engineyard-serverside/cli/app.rb +0 -136
- data/lib/engineyard-serverside/cli/helpers.rb +0 -58
- data/lib/engineyard-serverside/cli/server_hash_extractor.rb +0 -49
- data/lib/engineyard-serverside/cli/workflows.rb +0 -45
- data/lib/engineyard-serverside/cli/workflows/base.rb +0 -78
- data/lib/engineyard-serverside/cli/workflows/calling_deploy_hooks.rb +0 -31
- data/lib/engineyard-serverside/cli/workflows/deploying_applications.rb +0 -28
- data/lib/engineyard-serverside/cli/workflows/disabling_maintenance.rb +0 -29
- data/lib/engineyard-serverside/cli/workflows/enabling_maintenance.rb +0 -29
- data/lib/engineyard-serverside/cli/workflows/errors.rb +0 -13
- data/lib/engineyard-serverside/cli/workflows/helpers.rb +0 -21
- data/lib/engineyard-serverside/cli/workflows/integrating_servers.rb +0 -71
- data/lib/engineyard-serverside/cli/workflows/restarting_applications.rb +0 -36
- data/lib/engineyard-serverside/cli/workflows/rolling_back_applications.rb +0 -28
- data/lib/engineyard-serverside/cli/workflows/showing_maintenance_status.rb +0 -28
- data/lib/engineyard-serverside/deploy_hook/callback_context.rb +0 -77
- data/lib/engineyard-serverside/propagator.rb +0 -59
- data/lib/engineyard-serverside/slug.rb +0 -7
- data/lib/engineyard-serverside/slug/distributor.rb +0 -58
- data/lib/engineyard-serverside/slug/enabler.rb +0 -100
- data/lib/engineyard-serverside/slug/failure_handler.rb +0 -24
- data/lib/engineyard-serverside/slug/finalizer.rb +0 -86
- data/lib/engineyard-serverside/slug/generator.rb +0 -29
- data/lib/engineyard-serverside/slug/migrator.rb +0 -41
- data/lib/engineyard-serverside/slug/restarter.rb +0 -103
- data/lib/engineyard-serverside/slug/source.rb +0 -16
- data/lib/engineyard-serverside/slug/source/updater.rb +0 -194
- data/lib/railway.rb +0 -43
- data/lib/result.rb +0 -7
- data/lib/result/base.rb +0 -41
- data/lib/result/dsl.rb +0 -16
- data/lib/result/failure.rb +0 -29
- data/lib/result/success.rb +0 -24
- data/lib/runner.rb +0 -34
@@ -1,194 +0,0 @@
|
|
1
|
-
require 'railway'
|
2
|
-
require 'runner'
|
3
|
-
|
4
|
-
module EY
|
5
|
-
module Serverside
|
6
|
-
module Slug
|
7
|
-
module Source
|
8
|
-
|
9
|
-
class Updater
|
10
|
-
include Railway
|
11
|
-
include Runner
|
12
|
-
|
13
|
-
step :create_source_cache
|
14
|
-
step :ensure_ssh_wrapper
|
15
|
-
step :determine_if_clone_needed
|
16
|
-
step :clone_if_necessary
|
17
|
-
step :prune_source_cache
|
18
|
-
step :fetch_updates
|
19
|
-
step :clean_local_branch
|
20
|
-
step :calculate_requested_revision
|
21
|
-
step :checkout_requested_revision
|
22
|
-
step :sync_submodules
|
23
|
-
step :update_submodules
|
24
|
-
step :clean_source_cache
|
25
|
-
|
26
|
-
attr_reader :source_cache, :uri, :git, :quiet, :ref, :config
|
27
|
-
|
28
|
-
def initialize(input = {})
|
29
|
-
@input = input
|
30
|
-
@config = input[:config]
|
31
|
-
source = input[:config].source
|
32
|
-
@source_cache = source.source_cache
|
33
|
-
@uri = source.uri
|
34
|
-
@quiet = source.opts[:verbose] ? '' : '--quiet'
|
35
|
-
@ref = source.ref
|
36
|
-
@git = "#{wrapped_git} --git-dir #{source_cache}/.git --work-tree #{source_cache}"
|
37
|
-
end
|
38
|
-
|
39
|
-
def update
|
40
|
-
call(@input)
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def wrapped_git
|
46
|
-
"GIT_SSH=#{paths.ssh_wrapper} git"
|
47
|
-
end
|
48
|
-
|
49
|
-
def create_source_cache(input = {})
|
50
|
-
begin
|
51
|
-
source_cache.mkpath
|
52
|
-
rescue
|
53
|
-
return Failure(:error => "Could not create #{source_cache}")
|
54
|
-
end
|
55
|
-
|
56
|
-
Success(input)
|
57
|
-
end
|
58
|
-
|
59
|
-
def ensure_ssh_wrapper(input = {})
|
60
|
-
wrapper_location = paths.ssh_wrapper
|
61
|
-
|
62
|
-
return Success(input) if File.executable?(wrapper_location)
|
63
|
-
|
64
|
-
begin
|
65
|
-
wrapper = File.open(wrapper_location, 'w', 0700)
|
66
|
-
wrapper.write <<-WRAPPER
|
67
|
-
#!/bin/sh
|
68
|
-
|
69
|
-
unset SSH_AUTH_SOCK
|
70
|
-
|
71
|
-
command=$(wcho "$*" | sed -e 's/^-batch //')
|
72
|
-
|
73
|
-
ssh -o CheckHostIP=no -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o LogLevel=INFO -o IdentityFile=#{paths.deploy_key} -o IdentitiesOnly=yes ${command}
|
74
|
-
WRAPPER
|
75
|
-
wrapper.close
|
76
|
-
rescue => e
|
77
|
-
return Failure(input.merge(:error => e))
|
78
|
-
end
|
79
|
-
|
80
|
-
Success(input)
|
81
|
-
end
|
82
|
-
|
83
|
-
def determine_if_clone_needed(input = {})
|
84
|
-
|
85
|
-
check =
|
86
|
-
source_cache.directory? &&
|
87
|
-
run_and_output("#{git} remote -v | grep original").include?(uri)
|
88
|
-
|
89
|
-
Success(input.merge(:clone_needed => !check))
|
90
|
-
end
|
91
|
-
|
92
|
-
def clone_if_necessary(input = {})
|
93
|
-
if input[:clone_needed]
|
94
|
-
unless run_and_success?("rm -rf #{source_cache} && git clone #{quiet} #{uri} #{source_cache} 2>&1")
|
95
|
-
|
96
|
-
return Failure(
|
97
|
-
input.merge(:error => "Could not clone #{uri} to #{source_cache}")
|
98
|
-
)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
Success(input)
|
103
|
-
end
|
104
|
-
|
105
|
-
def prune_source_cache(input = {})
|
106
|
-
return Failure(
|
107
|
-
input.merge(:error => "Could not prune #{source_cache}")
|
108
|
-
) unless run_and_success?("#{git} remote prune origin 2>&1")
|
109
|
-
|
110
|
-
Success(input)
|
111
|
-
end
|
112
|
-
|
113
|
-
def fetch_updates(input = {})
|
114
|
-
return Failure(
|
115
|
-
input.merge(:error => "Could not fetch #{source_cache}")
|
116
|
-
) unless run_and_success?("#{git} fetch --force --prune --update-head-ok #{quiet} origin '+refs/heads/*:refs/remotes/origin/*' '+refs/tags/*:refs/tags/*' 2>&1")
|
117
|
-
|
118
|
-
Success(input)
|
119
|
-
end
|
120
|
-
|
121
|
-
def clean_local_branch(input = {})
|
122
|
-
run_and_success?("#{git} show-branch #{ref} > /dev/null 2>&1 && #{git} branch -D #{ref} > /dev/null 2>&1")
|
123
|
-
|
124
|
-
Success(input)
|
125
|
-
end
|
126
|
-
|
127
|
-
def calculate_requested_revision(input = {})
|
128
|
-
remote_branch = Dir.chdir(source_cache) do
|
129
|
-
run_and_success?("#{git} show-branch origin/#{ref} > /dev/null 2>&1")
|
130
|
-
end
|
131
|
-
|
132
|
-
Success(
|
133
|
-
input.merge(
|
134
|
-
:requested_branch => remote_branch ? "origin/#{ref}" : ref
|
135
|
-
)
|
136
|
-
)
|
137
|
-
end
|
138
|
-
|
139
|
-
def checkout_requested_revision(input = {})
|
140
|
-
requested_branch = input[:requested_branch]
|
141
|
-
|
142
|
-
Dir.chdir(source_cache) {
|
143
|
-
run_and_success?(
|
144
|
-
"git checkout --force #{quiet} '#{requested_branch}'"
|
145
|
-
) || run_and_success?(
|
146
|
-
"git reset --hard #{quiet} '#{requested_branch}'"
|
147
|
-
)
|
148
|
-
} ?
|
149
|
-
Success(input) :
|
150
|
-
Failure(
|
151
|
-
input.merge(:error => "Could not check out #{requested_branch}")
|
152
|
-
)
|
153
|
-
end
|
154
|
-
|
155
|
-
def sync_submodules(input = {})
|
156
|
-
return Failure(
|
157
|
-
input.merge(:error => "Could not sync submodules")
|
158
|
-
) unless Dir.chdir(source_cache) {
|
159
|
-
run_and_success?("#{wrapped_git} submodule sync")
|
160
|
-
}
|
161
|
-
|
162
|
-
Success(input)
|
163
|
-
end
|
164
|
-
|
165
|
-
def update_submodules(input = {})
|
166
|
-
return Failure(
|
167
|
-
input.merge(:error => "Could not update submodules")
|
168
|
-
) unless Dir.chdir(source_cache) {
|
169
|
-
run_and_success?("#{wrapped_git} submodule update --init --recursive")
|
170
|
-
}
|
171
|
-
|
172
|
-
Success(input)
|
173
|
-
end
|
174
|
-
|
175
|
-
def clean_source_cache(input = {})
|
176
|
-
return Failure(
|
177
|
-
input.merge(:error => "Could not clean source")
|
178
|
-
) unless Dir.chdir(source_cache) {
|
179
|
-
run_and_success?('git clean -dfq')
|
180
|
-
}
|
181
|
-
|
182
|
-
Success(input)
|
183
|
-
end
|
184
|
-
|
185
|
-
def paths
|
186
|
-
config.paths
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
190
|
-
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
data/lib/railway.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'result'
|
2
|
-
|
3
|
-
module Railway
|
4
|
-
include Result::DSL
|
5
|
-
|
6
|
-
module DSL
|
7
|
-
def step(name, options = {})
|
8
|
-
with = options.delete(:with)
|
9
|
-
steps.push(:name => name, :with => with)
|
10
|
-
end
|
11
|
-
|
12
|
-
def steps
|
13
|
-
@steps ||= []
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.included(base)
|
18
|
-
base.send :extend, DSL
|
19
|
-
end
|
20
|
-
|
21
|
-
def call(input = {})
|
22
|
-
steps = self.class.steps
|
23
|
-
|
24
|
-
return Failure('No steps') if steps.empty?
|
25
|
-
|
26
|
-
steps.
|
27
|
-
inject(Success(input)) {|result, step|
|
28
|
-
result.and_then {|data|
|
29
|
-
dispatch_step(step, data)
|
30
|
-
}
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def dispatch_step(step, data)
|
36
|
-
begin
|
37
|
-
result = (step[:with] || self).send(step[:name], data)
|
38
|
-
result.is_a?(Result::Base) ? result : Success(result)
|
39
|
-
rescue => error
|
40
|
-
Failure(error)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/lib/result.rb
DELETED
data/lib/result/base.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
module Result
|
2
|
-
|
3
|
-
class Base
|
4
|
-
def initialize(to_wrap)
|
5
|
-
@wrapped = to_wrap
|
6
|
-
end
|
7
|
-
|
8
|
-
def success?
|
9
|
-
false
|
10
|
-
end
|
11
|
-
|
12
|
-
def failure?
|
13
|
-
false
|
14
|
-
end
|
15
|
-
|
16
|
-
def value
|
17
|
-
raise "not present"
|
18
|
-
end
|
19
|
-
|
20
|
-
def error
|
21
|
-
raise "not present"
|
22
|
-
end
|
23
|
-
|
24
|
-
def and_then
|
25
|
-
self
|
26
|
-
end
|
27
|
-
|
28
|
-
def or_else
|
29
|
-
self
|
30
|
-
end
|
31
|
-
|
32
|
-
def on_success
|
33
|
-
self
|
34
|
-
end
|
35
|
-
|
36
|
-
def on_failure
|
37
|
-
self
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
data/lib/result/dsl.rb
DELETED
data/lib/result/failure.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'result/base'
|
2
|
-
|
3
|
-
module Result
|
4
|
-
|
5
|
-
class Failure < Base
|
6
|
-
def initialize(to_wrap)
|
7
|
-
super
|
8
|
-
freeze
|
9
|
-
end
|
10
|
-
|
11
|
-
def error
|
12
|
-
@wrapped
|
13
|
-
end
|
14
|
-
|
15
|
-
def failure?
|
16
|
-
true
|
17
|
-
end
|
18
|
-
|
19
|
-
def or_else
|
20
|
-
yield error
|
21
|
-
end
|
22
|
-
|
23
|
-
def on_failure
|
24
|
-
yield error
|
25
|
-
super
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
data/lib/result/success.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'result/base'
|
2
|
-
|
3
|
-
module Result
|
4
|
-
|
5
|
-
class Success < Base
|
6
|
-
def value
|
7
|
-
@wrapped
|
8
|
-
end
|
9
|
-
|
10
|
-
def success?
|
11
|
-
true
|
12
|
-
end
|
13
|
-
|
14
|
-
def and_then
|
15
|
-
yield value
|
16
|
-
end
|
17
|
-
|
18
|
-
def on_success
|
19
|
-
yield value
|
20
|
-
super
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
data/lib/runner.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'engineyard-serverside/spawner'
|
2
|
-
|
3
|
-
module Runner
|
4
|
-
def runner
|
5
|
-
EY::Serverside::Spawner
|
6
|
-
end
|
7
|
-
|
8
|
-
# Internal: Run a command.
|
9
|
-
#
|
10
|
-
# cmd - A string command.
|
11
|
-
#
|
12
|
-
# Returns an instance of Spawner.
|
13
|
-
def run(cmd)
|
14
|
-
runner.run(cmd, shell, nil)
|
15
|
-
end
|
16
|
-
|
17
|
-
# Internal: Run a command and return the output.
|
18
|
-
#
|
19
|
-
# cmd - A string command.
|
20
|
-
#
|
21
|
-
# Returns the output of the command.
|
22
|
-
def run_and_output(cmd)
|
23
|
-
run(cmd).output
|
24
|
-
end
|
25
|
-
|
26
|
-
# Internal: Run a command and check if it was successful.
|
27
|
-
#
|
28
|
-
# cmd - A string command.
|
29
|
-
#
|
30
|
-
# Returns success.
|
31
|
-
def run_and_success?(cmd)
|
32
|
-
run(cmd).success?
|
33
|
-
end
|
34
|
-
end
|