capistrano-redeploy 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/README.md +4 -2
  2. data/capistrano-redeploy.gemspec +5 -0
  3. data/lib/capistrano-redeploy.rb +2 -1
  4. data/lib/capistrano-redeploy/version.rb +1 -1
  5. data/test/centos6-64/.gitignore +5 -0
  6. data/test/centos6-64/.swp +0 -0
  7. data/test/centos6-64/Capfile +2 -0
  8. data/test/centos6-64/Gemfile +2 -0
  9. data/test/centos6-64/Vagrantfile +99 -0
  10. data/test/centos6-64/run.sh +7 -0
  11. data/test/config/deploy.rb +167 -0
  12. data/test/config/templates/global.sbt.erb +1 -0
  13. data/test/precise64/.gitignore +5 -0
  14. data/test/precise64/Capfile +2 -0
  15. data/test/precise64/Gemfile +2 -0
  16. data/test/precise64/Vagrantfile +99 -0
  17. data/test/precise64/run.sh +7 -0
  18. data/test/project/.gitignore +15 -0
  19. data/test/project/Gemfile +38 -0
  20. data/test/project/README.rdoc +261 -0
  21. data/test/project/Rakefile +7 -0
  22. data/test/project/app/assets/images/rails.png +0 -0
  23. data/test/project/app/assets/javascripts/application.js +15 -0
  24. data/test/project/app/assets/stylesheets/application.css +13 -0
  25. data/test/project/app/controllers/application_controller.rb +3 -0
  26. data/test/project/app/helpers/application_helper.rb +2 -0
  27. data/test/project/app/mailers/.gitkeep +0 -0
  28. data/test/project/app/models/.gitkeep +0 -0
  29. data/test/project/app/views/layouts/application.html.erb +14 -0
  30. data/test/project/config.ru +4 -0
  31. data/test/project/config/application.rb +62 -0
  32. data/test/project/config/boot.rb +6 -0
  33. data/test/project/config/database.yml +25 -0
  34. data/test/project/config/environment.rb +5 -0
  35. data/test/project/config/environments/development.rb +37 -0
  36. data/test/project/config/environments/production.rb +67 -0
  37. data/test/project/config/environments/test.rb +37 -0
  38. data/test/project/config/initializers/backtrace_silencers.rb +7 -0
  39. data/test/project/config/initializers/inflections.rb +15 -0
  40. data/test/project/config/initializers/mime_types.rb +5 -0
  41. data/test/project/config/initializers/secret_token.rb +7 -0
  42. data/test/project/config/initializers/session_store.rb +8 -0
  43. data/test/project/config/initializers/wrap_parameters.rb +14 -0
  44. data/test/project/config/locales/en.yml +5 -0
  45. data/test/project/config/routes.rb +58 -0
  46. data/test/project/db/seeds.rb +7 -0
  47. data/test/project/lib/assets/.gitkeep +0 -0
  48. data/test/project/lib/tasks/.gitkeep +0 -0
  49. data/test/project/log/.gitkeep +0 -0
  50. data/test/project/public/404.html +26 -0
  51. data/test/project/public/422.html +26 -0
  52. data/test/project/public/500.html +25 -0
  53. data/test/project/public/favicon.ico +0 -0
  54. data/test/project/public/index.html +241 -0
  55. data/test/project/public/robots.txt +5 -0
  56. data/test/project/script/rails +6 -0
  57. data/test/project/test/fixtures/.gitkeep +0 -0
  58. data/test/project/test/functional/.gitkeep +0 -0
  59. data/test/project/test/integration/.gitkeep +0 -0
  60. data/test/project/test/performance/browsing_test.rb +12 -0
  61. data/test/project/test/test_helper.rb +13 -0
  62. data/test/project/test/unit/.gitkeep +0 -0
  63. data/test/project/vendor/assets/javascripts/.gitkeep +0 -0
  64. data/test/project/vendor/assets/stylesheets/.gitkeep +0 -0
  65. data/test/project/vendor/plugins/.gitkeep +0 -0
  66. metadata +205 -3
data/README.md CHANGED
@@ -73,7 +73,7 @@ Redeploy files in `public` (except `public/assets` and `public/system`) from cur
73
73
 
74
74
  ### Redeploy files from local path with different names
75
75
 
76
- Redeploy files in `src/main/resources` from current directory to `target/webapp/WEB-INF`.
76
+ Redeploy files in `src/main/webapp` from current directory to `target/webapp/WEB-INF`.
77
77
 
78
78
  # config/deploy.rb
79
79
  set :scm, :git
@@ -83,10 +83,12 @@ Redeploy files in `src/main/resources` from current directory to `target/webapp/
83
83
  :scm => :none,
84
84
  :deploy_via => :copy,
85
85
  :repository => ".", # redeploy from current directory
86
+ :copy_cache => nil,
86
87
  }
87
- set :redeploy_source, "src/main/resources"
88
+ set :redeploy_source, "src/main/webapp"
88
89
  set :redeploy_destination, "target/webapp/WEB-INF"
89
90
  set :redeploy_children, ["."]
91
+ set :redeploy_exclusions, ["WEB-INF/web.xml"]
90
92
 
91
93
 
92
94
  ## Contributing
@@ -21,4 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency "capistrano"
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "capistrano-copy-subdir", ">= 0.1.0"
25
+ spec.add_development_dependency "capistrano-platform-resources", ">= 0.1.0"
26
+ spec.add_development_dependency "net-scp", "~> 1.0.4"
27
+ spec.add_development_dependency "net-ssh", "~> 2.2.2"
28
+ spec.add_development_dependency "vagrant", "~> 1.0.6"
24
29
  end
@@ -66,6 +66,7 @@ module Capistrano
66
66
  redeploy_variables.each do |key, val|
67
67
  set(key, val)
68
68
  end
69
+ logger.debug("Fetching source for re-deployment from #{repository} (#{scm}) via #{deploy_via}.")
69
70
  strategy.deploy!
70
71
  end
71
72
  run("rsync -lrpt #{(release_path + "/").dump} #{destination.dump}", options)
@@ -91,7 +92,7 @@ module Capistrano
91
92
  def redeploy!(source, destination, options={})
92
93
  exclusions = redeploy_exclusions.map { |e| "--exclude=#{e.dump}" }.join(" ")
93
94
  absolute_path_map(source, destination).each do |s, d|
94
- logger.info("redeploy: #{s} -> #{d}")
95
+ logger.debug("Re-deploying from `#{s}' to `#{d}'.")
95
96
  run("mkdir -p #{s.dump} #{d.dump}", options)
96
97
  run("rsync -lrpt #{exclusions} #{(s + "/").dump} #{d.dump}", options)
97
98
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module ReDeploy
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ /.bundle
2
+ /.vagrant
3
+ /known_hosts
4
+ /tmp
5
+ /vendor
Binary file
@@ -0,0 +1,2 @@
1
+ load "deploy"
2
+ load "../config/deploy"
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec(:path => "../..")
@@ -0,0 +1,99 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant::Config.run do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "centos6-64"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.3-x86_64-v20130101.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ config.vm.network :hostonly, "192.168.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ # config.vm.forward_port 80, 8080
33
+
34
+ # Share an additional folder to the guest VM. The first argument is
35
+ # an identifier, the second is the path on the guest to mount the
36
+ # folder, and the third is the path on the host to the actual folder.
37
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
38
+
39
+ # Enable provisioning with Puppet stand alone. Puppet manifests
40
+ # are contained in a directory path relative to this Vagrantfile.
41
+ # You will need to create the manifests directory and a manifest in
42
+ # the file precise-amd64.pp in the manifests_path directory.
43
+ #
44
+ # An example Puppet manifest to provision the message of the day:
45
+ #
46
+ # # group { "puppet":
47
+ # # ensure => "present",
48
+ # # }
49
+ # #
50
+ # # File { owner => 0, group => 0, mode => 0644 }
51
+ # #
52
+ # # file { '/etc/motd':
53
+ # # content => "Welcome to your Vagrant-built virtual machine!
54
+ # # Managed by Puppet.\n"
55
+ # # }
56
+ #
57
+ # config.vm.provision :puppet do |puppet|
58
+ # puppet.manifests_path = "manifests"
59
+ # puppet.manifest_file = "precise-amd64.pp"
60
+ # end
61
+
62
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
63
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
64
+ # some recipes and/or roles.
65
+ #
66
+ # config.vm.provision :chef_solo do |chef|
67
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
68
+ # chef.roles_path = "../my-recipes/roles"
69
+ # chef.data_bags_path = "../my-recipes/data_bags"
70
+ # chef.add_recipe "mysql"
71
+ # chef.add_role "web"
72
+ #
73
+ # # You may also specify custom JSON attributes:
74
+ # chef.json = { :mysql_password => "foo" }
75
+ # end
76
+
77
+ # Enable provisioning with chef server, specifying the chef server URL,
78
+ # and the path to the validation key (relative to this Vagrantfile).
79
+ #
80
+ # The Opscode Platform uses HTTPS. Substitute your organization for
81
+ # ORGNAME in the URL and validation key.
82
+ #
83
+ # If you have your own Chef Server, use the appropriate URL, which may be
84
+ # HTTP instead of HTTPS depending on your configuration. Also change the
85
+ # validation key to validation.pem.
86
+ #
87
+ # config.vm.provision :chef_client do |chef|
88
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
89
+ # chef.validation_key_path = "ORGNAME-validator.pem"
90
+ # end
91
+ #
92
+ # If you're using the Opscode platform, your validator client is
93
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
94
+ #
95
+ # IF you have your own Chef Server, the default validation client name is
96
+ # chef-validator, unless you changed the configuration.
97
+ #
98
+ # chef.validation_client_name = "ORGNAME-validator"
99
+ end
@@ -0,0 +1,7 @@
1
+ #!/bin/sh -e
2
+
3
+ bundle exec vagrant up
4
+ bundle exec cap test_all
5
+ bundle exec vagrant halt
6
+
7
+ # vim:set ft=sh :
@@ -0,0 +1,167 @@
1
+ set :application, "capistrano-redeploy"
2
+ set :repository, "git@github.com:yyuu/capistrano-redeploy.git"
3
+ set :deploy_to do
4
+ File.join("/home", user, application)
5
+ end
6
+ set :deploy_via, :copy_subdir
7
+ set :deploy_subdir, "test/project"
8
+ set :scm, :git
9
+ set :use_sudo, false
10
+ set :user, "vagrant"
11
+ set :password, "vagrant"
12
+ set :ssh_options, {:user_known_hosts_file => "/dev/null"}
13
+
14
+ role :web, "192.168.33.10"
15
+ role :app, "192.168.33.10"
16
+ role :db, "192.168.33.10", :primary => true
17
+
18
+ $LOAD_PATH.push(File.expand_path("../../lib", File.dirname(__FILE__)))
19
+ require "capistrano/configuration/resources/platform_resources"
20
+ require "capistrano-redeploy"
21
+ require "pathname"
22
+
23
+ task(:test_all) {
24
+ find_and_execute_task("test_default")
25
+ find_and_execute_task("test_none")
26
+ find_and_execute_task("test_none_with_rename_path")
27
+ }
28
+
29
+ on(:load) {
30
+ run("rm -rf #{deploy_to.dump}")
31
+ platform.packages.install("rsync") unless platform.packages.installed?("rsync")
32
+ find_and_execute_task("deploy:setup")
33
+ find_and_execute_task("deploy")
34
+ find_and_execute_task("deploy")
35
+ }
36
+
37
+ def reset_all!()
38
+ variables.each_key do |key|
39
+ reset!(key)
40
+ end
41
+ end
42
+
43
+ def _test_redeploy
44
+ public_path = File.join(current_path, "public")
45
+ backup_path = public_path + ".orig"
46
+ # touch currently deployed public contents with old timestamp
47
+ ts = (Time.now - 60*60*24*365).strftime("%Y%m%d%H%M")
48
+ run("touch -t #{ts} #{public_path}/*")
49
+ # copy public as public.orig
50
+ run("rm -rf #{backup_path.dump} && cp -RPp #{public_path.dump} #{backup_path.dump}")
51
+ find_and_execute_task("redeploy")
52
+ run("test #{File.join(backup_path, "index.html").dump} -ot #{File.join(public_path, "index.html").dump}")
53
+ ensure
54
+ run("rm -rf #{backup_path.dump}")
55
+ end
56
+
57
+ def _test_redeploy_exclusions
58
+ precompiled_asset = File.join(current_path, "public", "assets", "precompiled")
59
+ run("mkdir -p #{File.dirname(precompiled_asset).dump} && touch #{precompiled_asset.dump}")
60
+ find_and_execute_task("redeploy")
61
+ run("test -f #{precompiled_asset.dump}")
62
+ ensure
63
+ run("rm -f #{precompiled_asset.dump}")
64
+ end
65
+
66
+ namespace(:test_default) {
67
+ task(:default) {
68
+ methods.grep(/^test_/).each do |m|
69
+ send(m)
70
+ end
71
+ }
72
+ before "test_default", "test_default:setup"
73
+ after "test_default", "test_default:teardown"
74
+
75
+ task(:setup) {
76
+ set(:redeploy_source, ".")
77
+ set(:redeploy_destination, ".")
78
+ set(:redeploy_children, %w(public))
79
+ set(:redeploy_exclusions, %w(assets system))
80
+ set(:redeploy_variables, {})
81
+ reset_all!
82
+ }
83
+
84
+ task(:teardown) {
85
+ }
86
+
87
+ task(:test_redeploy) {
88
+ _test_redeploy
89
+ }
90
+
91
+ task(:test_redeploy_exclusions) {
92
+ _test_redeploy_exclusions
93
+ }
94
+ }
95
+
96
+ namespace(:test_none) {
97
+ task(:default) {
98
+ methods.grep(/^test_/).each do |m|
99
+ send(m)
100
+ end
101
+ }
102
+ before "test_none", "test_none:setup"
103
+ after "test_none", "test_none:teardown"
104
+
105
+ task(:setup) {
106
+ set(:redeploy_source, ".")
107
+ set(:redeploy_destination, ".")
108
+ set(:redeploy_children, %w(public))
109
+ set(:redeploy_exclusions, %w(assets system))
110
+ set(:redeploy_variables) {{
111
+ :scm => :none, :deploy_via => :copy,
112
+ :repository => File.expand_path("../project", File.dirname(__FILE__)),
113
+ }}
114
+ reset_all!
115
+ }
116
+
117
+ task(:teardown) {
118
+ }
119
+
120
+ task(:test_redeploy) {
121
+ _test_redeploy
122
+ }
123
+
124
+ task(:test_redeploy_exclusions) {
125
+ _test_redeploy_exclusions
126
+ }
127
+ }
128
+
129
+ namespace(:test_none_with_rename_path) {
130
+ task(:default) {
131
+ methods.grep(/^test_/).each do |m|
132
+ send(m)
133
+ end
134
+ }
135
+ before "test_none_with_rename_path", "test_none_with_rename_path:setup"
136
+ after "test_none_with_rename_path", "test_none_with_rename_path:teardown"
137
+
138
+ task(:setup) {
139
+ set(:redeploy_source, "app")
140
+ set(:redeploy_destination, "xxx")
141
+ set(:redeploy_children, %w(controllers models views))
142
+ set(:redeploy_exclusions, %w())
143
+ set(:redeploy_variables) {{
144
+ :scm => :none, :deploy_via => :copy,
145
+ :repository => File.expand_path("../project", File.dirname(__FILE__)),
146
+ }}
147
+ reset_all!
148
+ }
149
+
150
+ task(:teardown) {
151
+ }
152
+
153
+ task(:test_none_with_rename_path) {
154
+ begin
155
+ src_path = File.join(current_path, redeploy_source)
156
+ dst_path = File.join(current_path, redeploy_destination)
157
+ find_and_execute_task("redeploy")
158
+ redeploy_children.each do |c|
159
+ run("diff -r #{File.join(src_path, c).dump} #{File.join(dst_path, c).dump}")
160
+ end
161
+ ensure
162
+ run("rm -rf #{dst_path.dump}")
163
+ end
164
+ }
165
+ }
166
+
167
+ # vim:set ft=ruby sw=2 ts=2 :
@@ -0,0 +1 @@
1
+ credentials += Credentials("My Repository", "repository.example.com", "username", "password")
@@ -0,0 +1,5 @@
1
+ /.bundle
2
+ /.vagrant
3
+ /known_hosts
4
+ /tmp
5
+ /vendor
@@ -0,0 +1,2 @@
1
+ load "deploy"
2
+ load "../config/deploy"
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec(:path => "../..")
@@ -0,0 +1,99 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant::Config.run do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "precise64"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ config.vm.network :hostonly, "192.168.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ # config.vm.forward_port 80, 8080
33
+
34
+ # Share an additional folder to the guest VM. The first argument is
35
+ # an identifier, the second is the path on the guest to mount the
36
+ # folder, and the third is the path on the host to the actual folder.
37
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
38
+
39
+ # Enable provisioning with Puppet stand alone. Puppet manifests
40
+ # are contained in a directory path relative to this Vagrantfile.
41
+ # You will need to create the manifests directory and a manifest in
42
+ # the file precise-amd64.pp in the manifests_path directory.
43
+ #
44
+ # An example Puppet manifest to provision the message of the day:
45
+ #
46
+ # # group { "puppet":
47
+ # # ensure => "present",
48
+ # # }
49
+ # #
50
+ # # File { owner => 0, group => 0, mode => 0644 }
51
+ # #
52
+ # # file { '/etc/motd':
53
+ # # content => "Welcome to your Vagrant-built virtual machine!
54
+ # # Managed by Puppet.\n"
55
+ # # }
56
+ #
57
+ # config.vm.provision :puppet do |puppet|
58
+ # puppet.manifests_path = "manifests"
59
+ # puppet.manifest_file = "precise-amd64.pp"
60
+ # end
61
+
62
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
63
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
64
+ # some recipes and/or roles.
65
+ #
66
+ # config.vm.provision :chef_solo do |chef|
67
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
68
+ # chef.roles_path = "../my-recipes/roles"
69
+ # chef.data_bags_path = "../my-recipes/data_bags"
70
+ # chef.add_recipe "mysql"
71
+ # chef.add_role "web"
72
+ #
73
+ # # You may also specify custom JSON attributes:
74
+ # chef.json = { :mysql_password => "foo" }
75
+ # end
76
+
77
+ # Enable provisioning with chef server, specifying the chef server URL,
78
+ # and the path to the validation key (relative to this Vagrantfile).
79
+ #
80
+ # The Opscode Platform uses HTTPS. Substitute your organization for
81
+ # ORGNAME in the URL and validation key.
82
+ #
83
+ # If you have your own Chef Server, use the appropriate URL, which may be
84
+ # HTTP instead of HTTPS depending on your configuration. Also change the
85
+ # validation key to validation.pem.
86
+ #
87
+ # config.vm.provision :chef_client do |chef|
88
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
89
+ # chef.validation_key_path = "ORGNAME-validator.pem"
90
+ # end
91
+ #
92
+ # If you're using the Opscode platform, your validator client is
93
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
94
+ #
95
+ # IF you have your own Chef Server, the default validation client name is
96
+ # chef-validator, unless you changed the configuration.
97
+ #
98
+ # chef.validation_client_name = "ORGNAME-validator"
99
+ end