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.
Files changed (99) hide show
  1. data/lib/engineyard-serverside.rb +2 -0
  2. data/lib/engineyard-serverside/cli.rb +83 -48
  3. data/lib/engineyard-serverside/configuration.rb +85 -18
  4. data/lib/engineyard-serverside/deploy.rb +105 -91
  5. data/lib/engineyard-serverside/deploy_hook.rb +22 -20
  6. data/lib/engineyard-serverside/deprecation.rb +9 -17
  7. data/lib/engineyard-serverside/future.rb +10 -4
  8. data/lib/engineyard-serverside/futures/celluloid.rb +3 -13
  9. data/lib/engineyard-serverside/futures/dataflow.rb +8 -13
  10. data/lib/engineyard-serverside/lockfile_parser.rb +1 -1
  11. data/lib/engineyard-serverside/rails_asset_support.rb +26 -10
  12. data/lib/engineyard-serverside/server.rb +17 -12
  13. data/lib/engineyard-serverside/shell.rb +98 -0
  14. data/lib/engineyard-serverside/shell/formatter.rb +71 -0
  15. data/lib/engineyard-serverside/shell/helpers.rb +29 -0
  16. data/lib/engineyard-serverside/strategies/git.rb +33 -63
  17. data/lib/engineyard-serverside/task.rb +34 -13
  18. data/lib/engineyard-serverside/version.rb +1 -1
  19. data/spec/basic_deploy_spec.rb +15 -50
  20. data/spec/bundler_deploy_spec.rb +3 -44
  21. data/spec/configuration_spec.rb +72 -0
  22. data/spec/custom_deploy_spec.rb +3 -4
  23. data/spec/deploy_hook_spec.rb +210 -162
  24. data/spec/deprecation_spec.rb +4 -26
  25. data/spec/ey_yml_customized_deploy_spec.rb +68 -0
  26. data/spec/fixtures/repos/assets_disabled/Gemfile +6 -0
  27. data/spec/fixtures/repos/assets_disabled/Gemfile.lock +90 -0
  28. data/spec/fixtures/repos/assets_disabled/README +1 -0
  29. data/spec/fixtures/repos/assets_disabled/Rakefile +5 -0
  30. data/spec/fixtures/repos/assets_disabled/config/application.rb +5 -0
  31. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +6 -0
  32. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +90 -0
  33. data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +1 -0
  34. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +5 -0
  35. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +5 -0
  36. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +4 -0
  37. data/spec/fixtures/repos/assets_enabled/Gemfile +6 -0
  38. data/spec/fixtures/repos/assets_enabled/Gemfile.lock +90 -0
  39. data/spec/fixtures/repos/assets_enabled/README +1 -0
  40. data/spec/fixtures/repos/assets_enabled/Rakefile +5 -0
  41. data/spec/fixtures/repos/assets_enabled/config/application.rb +5 -0
  42. data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +1 -0
  43. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +5 -0
  44. data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +4 -0
  45. data/spec/fixtures/repos/assets_in_hook/Gemfile +6 -0
  46. data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +90 -0
  47. data/spec/fixtures/repos/assets_in_hook/README +2 -0
  48. data/spec/fixtures/repos/assets_in_hook/Rakefile +5 -0
  49. data/spec/fixtures/repos/assets_in_hook/config/application.rb +5 -0
  50. data/spec/fixtures/repos/assets_in_hook/deploy/before_migrate.rb +1 -0
  51. data/spec/fixtures/repos/default/Gemfile +5 -0
  52. data/spec/fixtures/repos/default/Gemfile.lock +14 -0
  53. data/spec/fixtures/repos/default/README +5 -0
  54. data/spec/fixtures/repos/ey_yml/Gemfile +4 -0
  55. data/spec/fixtures/repos/ey_yml/Gemfile.lock +12 -0
  56. data/spec/fixtures/repos/ey_yml/README +1 -0
  57. data/spec/fixtures/repos/ey_yml/config/ey.yml +12 -0
  58. data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +6 -0
  59. data/spec/fixtures/repos/ey_yml_alt/Gemfile +4 -0
  60. data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +12 -0
  61. data/spec/fixtures/repos/ey_yml_alt/README +1 -0
  62. data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +6 -0
  63. data/spec/fixtures/repos/ey_yml_alt/ey.yml +12 -0
  64. data/spec/fixtures/repos/hook_fails/README +1 -0
  65. data/spec/fixtures/repos/hook_fails/deploy/before_migrate.rb +1 -0
  66. data/spec/fixtures/repos/hooks/README +1 -0
  67. data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +1 -0
  68. data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +1 -0
  69. data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +1 -0
  70. data/spec/fixtures/repos/hooks/deploy/after_restart.rb +1 -0
  71. data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +1 -0
  72. data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +1 -0
  73. data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +1 -0
  74. data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +1 -0
  75. data/spec/fixtures/repos/hooks/deploy/before_restart.rb +1 -0
  76. data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +1 -0
  77. data/spec/fixtures/repos/no_ey_config/Gemfile +4 -0
  78. data/spec/fixtures/repos/no_ey_config/Gemfile.lock +12 -0
  79. data/spec/fixtures/repos/no_ey_config/README +1 -0
  80. data/spec/fixtures/repos/no_gemfile_lock/Gemfile +5 -0
  81. data/spec/fixtures/repos/no_gemfile_lock/README +1 -0
  82. data/spec/fixtures/repos/nodejs/README +1 -0
  83. data/spec/fixtures/repos/nodejs/package.json +7 -0
  84. data/spec/fixtures/repos/not_bundled/README +1 -0
  85. data/spec/fixtures/{gemfiles/1.0.21-rails-31-with-sqlite → repos/sqlite3/Gemfile} +0 -0
  86. data/spec/fixtures/{lockfiles/1.0.21-rails-31-with-sqlite → repos/sqlite3/Gemfile.lock} +0 -0
  87. data/spec/fixtures/repos/sqlite3/README +1 -0
  88. data/spec/git_strategy_spec.rb +11 -2
  89. data/spec/lockfile_parser_spec.rb +8 -3
  90. data/spec/nodejs_deploy_spec.rb +1 -26
  91. data/spec/rails31_deploy_spec.rb +23 -31
  92. data/spec/services_deploy_spec.rb +41 -100
  93. data/spec/shell_spec.rb +50 -0
  94. data/spec/spec_helper.rb +80 -66
  95. data/spec/sqlite3_deploy_spec.rb +10 -16
  96. data/spec/support/integration.rb +45 -139
  97. metadata +233 -78
  98. data/lib/engineyard-serverside/logged_output.rb +0 -91
  99. data/spec/logged_output_spec.rb +0 -55
@@ -0,0 +1 @@
1
+ Standard rails31 app with asset compilation enabled.
@@ -0,0 +1,5 @@
1
+ desc 'Precompile yar assetz'
2
+ task 'assets:precompile' do
3
+ sh 'touch precompiled'
4
+ end
5
+
@@ -0,0 +1,5 @@
1
+ module Rails31
2
+ class Application < Rails::Application
3
+ config.assets.enabled = true
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ an app that we otherwise wouldn't compile assets, but precompile_assets is set to true in ey.yml
@@ -0,0 +1,5 @@
1
+ desc 'Precompile yar assetz'
2
+ task 'assets:precompile' do
3
+ sh 'touch precompiled'
4
+ end
5
+
@@ -0,0 +1,4 @@
1
+ environments:
2
+ env:
3
+ precompile_assets: true
4
+ maintenance_on_migrate: false
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem 'rake'
4
+ gem 'pg'
5
+ gem 'ey_config'
6
+ gem 'rails'
@@ -0,0 +1,90 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.3)
5
+ actionpack (= 3.2.3)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.3)
8
+ activemodel (= 3.2.3)
9
+ activesupport (= 3.2.3)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.1)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.2)
17
+ activemodel (3.2.3)
18
+ activesupport (= 3.2.3)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.3)
21
+ activemodel (= 3.2.3)
22
+ activesupport (= 3.2.3)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.3)
26
+ activemodel (= 3.2.3)
27
+ activesupport (= 3.2.3)
28
+ activesupport (3.2.3)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.2)
32
+ builder (3.0.0)
33
+ erubis (2.7.0)
34
+ ey_config (0.0.5)
35
+ hike (1.2.1)
36
+ i18n (0.6.0)
37
+ journey (1.0.3)
38
+ json (1.6.6)
39
+ mail (2.4.4)
40
+ i18n (>= 0.4.0)
41
+ mime-types (~> 1.16)
42
+ treetop (~> 1.4.8)
43
+ mime-types (1.18)
44
+ multi_json (1.3.2)
45
+ pg (0.13.2)
46
+ polyglot (0.3.3)
47
+ rack (1.4.1)
48
+ rack-cache (1.2)
49
+ rack (>= 0.4)
50
+ rack-ssl (1.3.2)
51
+ rack
52
+ rack-test (0.6.1)
53
+ rack (>= 1.0)
54
+ rails (3.2.3)
55
+ actionmailer (= 3.2.3)
56
+ actionpack (= 3.2.3)
57
+ activerecord (= 3.2.3)
58
+ activeresource (= 3.2.3)
59
+ activesupport (= 3.2.3)
60
+ bundler (~> 1.0)
61
+ railties (= 3.2.3)
62
+ railties (3.2.3)
63
+ actionpack (= 3.2.3)
64
+ activesupport (= 3.2.3)
65
+ rack-ssl (~> 1.3.2)
66
+ rake (>= 0.8.7)
67
+ rdoc (~> 3.4)
68
+ thor (~> 0.14.6)
69
+ rake (0.9.2.2)
70
+ rdoc (3.12)
71
+ json (~> 1.4)
72
+ sprockets (2.1.2)
73
+ hike (~> 1.2)
74
+ rack (~> 1.0)
75
+ tilt (~> 1.1, != 1.3.0)
76
+ thor (0.14.6)
77
+ tilt (1.3.3)
78
+ treetop (1.4.10)
79
+ polyglot
80
+ polyglot (>= 0.3.1)
81
+ tzinfo (0.3.33)
82
+
83
+ PLATFORMS
84
+ ruby
85
+
86
+ DEPENDENCIES
87
+ ey_config
88
+ pg
89
+ rails
90
+ rake
@@ -0,0 +1,2 @@
1
+ Assets are pre-compiled in a hook, as if the user had set up a hook before we
2
+ began supporting asset precompilation in rails.
@@ -0,0 +1,5 @@
1
+ desc 'Precompile yar assetz'
2
+ task 'assets:precompile' do
3
+ sh 'touch precompiled'
4
+ end
5
+
@@ -0,0 +1,5 @@
1
+ module Rails31
2
+ class Application < Rails::Application
3
+ config.assets.enabled = true
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ run 'touch custom_compiled && mkdir public/assets'
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'rake'
4
+ gem 'pg'
5
+ gem 'ey_config'
@@ -0,0 +1,14 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ey_config (0.0.5)
5
+ pg (0.13.2)
6
+ rake (0.9.2.2)
7
+
8
+ PLATFORMS
9
+ ruby
10
+
11
+ DEPENDENCIES
12
+ ey_config
13
+ pg
14
+ rake
@@ -0,0 +1,5 @@
1
+ This is a simple bundled fake app for specs.
2
+
3
+ All the files in this directory are copied into a temporary git repository
4
+ during spec runs. The rest of the "git repository" stuff comes from
5
+ gitrepo.tar.gz which is copied first to create the repo.
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem 'rake'
4
+ gem 'ey_config'
@@ -0,0 +1,12 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ey_config (0.0.5)
5
+ rake (0.9.2.2)
6
+
7
+ PLATFORMS
8
+ ruby
9
+
10
+ DEPENDENCIES
11
+ ey_config
12
+ rake
@@ -0,0 +1 @@
1
+ This repo has an ey.yml file for testing config loading.
@@ -0,0 +1,12 @@
1
+ environments:
2
+ env:
3
+ copy_exclude:
4
+ - .git
5
+ - README
6
+ migrate: true
7
+ migration_command: 'uh oh'
8
+ branch: branch_from_ey_yml
9
+ custom: custom_from_ey_yml
10
+ bundle_without: only test
11
+ maintenance_on_migrate: false
12
+ ignore_database_adapter_warning: true
@@ -0,0 +1,6 @@
1
+ run "echo '#{config.custom}' > custom_hook"
2
+ if File.exist?(config.maintenance_page_enabled_path)
3
+ run "echo 'maintenance page enabled' > maintenance_enabled"
4
+ else
5
+ run "echo 'no maintenance page' > maintenance_disabled"
6
+ end
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem 'rake'
4
+ gem 'ey_config'
@@ -0,0 +1,12 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ey_config (0.0.5)
5
+ rake (0.9.2.2)
6
+
7
+ PLATFORMS
8
+ ruby
9
+
10
+ DEPENDENCIES
11
+ ey_config
12
+ rake
@@ -0,0 +1 @@
1
+ This repo has an ey.yml file for testing config loading.
@@ -0,0 +1,6 @@
1
+ run "echo '#{config.custom}' > custom_hook"
2
+ if File.exist?(config.maintenance_page_enabled_path)
3
+ run "echo 'maintenance page enabled' > maintenance_enabled"
4
+ else
5
+ run "echo 'no maintenance page' > maintenance_disabled"
6
+ end
@@ -0,0 +1,12 @@
1
+ environments:
2
+ env:
3
+ copy_exclude:
4
+ - .git
5
+ - README
6
+ migrate: true
7
+ migration_command: 'uh oh'
8
+ branch: branch_from_ey_yml
9
+ custom: custom_from_ey_yml
10
+ bundle_without: only test
11
+ maintenance_on_migrate: true
12
+ maintenance_on_restart: true
@@ -0,0 +1 @@
1
+ In this app the before migrate hook raises.
@@ -0,0 +1 @@
1
+ raise "Hook failing in #{__FILE__}"
@@ -0,0 +1 @@
1
+ Run ALL of the hooks!
@@ -0,0 +1 @@
1
+ run 'touch after_bundle.ran'
@@ -0,0 +1 @@
1
+ run 'touch after_compile_assets.ran'
@@ -0,0 +1 @@
1
+ run 'touch after_migrate.ran'
@@ -0,0 +1 @@
1
+ run 'touch after_restart.ran'
@@ -0,0 +1 @@
1
+ run 'touch after_symlink.ran'
@@ -0,0 +1 @@
1
+ run 'touch before_bundle.ran'
@@ -0,0 +1 @@
1
+ run 'touch before_compile_assets.ran'
@@ -0,0 +1 @@
1
+ run 'touch before_migrate.ran'
@@ -0,0 +1 @@
1
+ run 'touch before_restart.ran'
@@ -0,0 +1 @@
1
+ run 'touch before_symlink.ran'
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem 'rake'
4
+ gem 'pg'
@@ -0,0 +1,12 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ pg (0.11.0)
5
+ rake (0.9.2.2)
6
+
7
+ PLATFORMS
8
+ ruby
9
+
10
+ DEPENDENCIES
11
+ pg
12
+ rake
@@ -0,0 +1 @@
1
+ This repo is missing ey_config which is used for services testing.
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'rake'
4
+ gem 'pg'
5
+ gem 'ey_config'
@@ -0,0 +1 @@
1
+ Gemfile, but no Gemfile.lock
@@ -0,0 +1 @@
1
+ Simple Node.js app.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "node-example",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "express": "2.5.8"
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ This app is not bundled. No Gemfile or Gemfile lock here.
@@ -0,0 +1 @@
1
+ This repo uses sqlite3 gem instead of the usual database adapters.
@@ -2,8 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  describe "the git deploy strategy" do
4
4
  subject do
5
- EY::Serverside::Strategies::Git.new(:repo => File.join(GITREPO_DIR, 'git'),
6
- :repository_cache => GITREPO_DIR, :ref => "master")
5
+ fixtures_dir = Pathname.new(__FILE__).dirname.join("fixtures")
6
+ gitrepo_dir = Pathname.new(Dir.tmpdir).join("gitrepo-#{Time.now.to_i}-#{$$}")
7
+ gitrepo_dir.mkdir
8
+ system "tar xzf #{fixtures_dir.join('gitrepo.tar.gz')} --strip-components 1 -C #{gitrepo_dir}"
9
+
10
+ EY::Serverside::Strategies::Git.new(
11
+ test_shell,
12
+ :repo => FIXTURES_DIR.join('repos','default'),
13
+ :repository_cache => gitrepo_dir,
14
+ :ref => "master"
15
+ )
7
16
  end
8
17
 
9
18
  before { subject.checkout }
@@ -18,6 +18,11 @@ describe "the bundler version retrieved from the lockfile" do
18
18
  lambda { get_version('0.9-with-bundler') }.should raise_error(RuntimeError, /Malformed or pre bundler-1.0.0 Gemfile.lock/)
19
19
  end
20
20
 
21
+ it "has a default version" do
22
+ EY::Serverside::LockfileParser.default_version.should == "1.1.3"
23
+ EY::Serverside::LockfileParser::DEFAULT.should == "1.1.3"
24
+ end
25
+
21
26
  it "returns the default version for a 1.0 lockfile without a bundler dependency" do
22
27
  get_version('1.0-no-bundler').should == EY::Serverside::LockfileParser::DEFAULT
23
28
  end
@@ -80,15 +85,15 @@ describe "the bundler version retrieved from the lockfile" do
80
85
  end
81
86
 
82
87
  it "uses the default version when we get a pessimistic qualifier and is lower than the default version" do
83
- subject.fetch_version('1.0.1', '~>').should == '1.0.21'
88
+ subject.fetch_version('1.1.1', '~>').should == EY::Serverside::LockfileParser::DEFAULT
84
89
  end
85
90
 
86
91
  it "uses the given version when we get a pessimistic qualifier that doesn't match the default version" do
87
- subject.fetch_version('1.1.0', '~>').should == '1.1.0'
92
+ subject.fetch_version('1.0.0', '~>').should == '1.0.0'
88
93
  end
89
94
 
90
95
  it "uses the given version when it's geater of equal than the default version" do
91
- subject.fetch_version('1.1.0', '>=').should == '1.1.0'
96
+ subject.fetch_version('1.2.0', '>=').should == '1.2.0'
92
97
  end
93
98
 
94
99
  it "uses the default version when the given version is lower" do
@@ -1,33 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Deploying an application that uses Node.js and NPM" do
4
- def deploy_test_application
5
- @deploy_dir = File.join(Dir.tmpdir, "serverside-deploy-#{Time.now.to_i}-#{$$}")
6
-
7
- # set up EY::Serverside::Server like we're on a solo
8
- EY::Serverside::Server.reset
9
- EY::Serverside::Server.add(:hostname => 'localhost', :roles => %w[solo])
10
-
11
- # run a deploy
12
- config = EY::Serverside::Deploy::Configuration.new({
13
- "strategy" => "NodeIntegrationSpec",
14
- "deploy_to" => @deploy_dir,
15
- "group" => `id -gn`.strip,
16
- "stack" => 'nginx_nodejs',
17
- 'app' => 'nodeapp',
18
- 'framework_env' => 'staging'
19
- })
20
-
21
- @binpath = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'engineyard-serverside'))
22
- @deployer = FullTestDeploy.new(config)
23
- @deployer.deploy do
24
- FileUtils.mkdir_p(config.repository_cache) # block runs before deploy
25
- @deployer.generate_package_json_in(config.repository_cache)
26
- end
27
- end
28
-
29
4
  before(:all) do
30
- deploy_test_application
5
+ deploy_test_application('nodejs')
31
6
  end
32
7
 
33
8
  it "runs 'npm install'" do