capistrano-unison 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +1 -0
- data/capistrano-unison.gemspec +20 -0
- data/lib/capistrano-unison.rb +3 -0
- data/lib/capistrano/recipes/deploy/strategy/unison.rb +25 -0
- data/lib/capistrano/unison.rb +34 -0
- data/lib/capistrano/unison/version.rb +5 -0
- metadata +70 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Josh Nichols
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Capistrano::Unison
|
2
|
+
|
3
|
+
Capistrano::Unison is a deployment strategy for [Capistrano](http://capify.org/) that uses [Unison](http://www.cis.upenn.edu/~bcpierce/unison/) to syncrhronize the working directory with the filesystem on the remote side. The result is very similar to [Capistrano::Deploy::Strategy::Copy](https://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy/strategy/copy.rb), except it is significantly faster and can feasibly used to pull changes on the remote end down.
|
4
|
+
|
5
|
+
The main motivation for this is to speed up testing deploys while doing devopsy things with [capistrano]((http://capify.org/), [moonshine](http://github.com/railsmachine/moonshine), [puppet](http://puppetlabs.com/), etc, while avoiding having to commit changes that are still being developed. [capistrano-cowboy](http://github.com/railsmachine/capistrano-cowboy) was our first attempt at this workflow, but for sufficiently large repositories and sufficiently slow uplinks, the feedback cycle is enough to kick a developer out of The Zone(tm).
|
6
|
+
|
7
|
+
During initial development, capistrano-cowboy deploys took over 2 minutes, and capistrano-unison depoys took 15 seconds. It was pretty shocking
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem 'capistrano-unison', :require => false
|
15
|
+
end
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install capistrano-unison
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Add to `config/deploy.rb`:
|
28
|
+
|
29
|
+
require 'capistrano/unison'
|
30
|
+
|
31
|
+
You need to install unison locally first, which most packages managers have:
|
32
|
+
|
33
|
+
# on debian/ubuntu
|
34
|
+
$ sudo apt-get install unison # for
|
35
|
+
# on macos with homebrew
|
36
|
+
$ brew install unison
|
37
|
+
|
38
|
+
Important note! The major.minor version of unison needs to match on client and server, or it will fail with sads.
|
39
|
+
|
40
|
+
You have to do an initial setup to get unison installed on the remote end:
|
41
|
+
|
42
|
+
$ cap <stage> unison:setup
|
43
|
+
|
44
|
+
Now you can use the `unison` task to enable unison deploys just for this run:
|
45
|
+
|
46
|
+
$ cap <stage> unison deploy
|
47
|
+
|
48
|
+
## TODO
|
49
|
+
|
50
|
+
* Don't hardcode local directory '.' (borrow from :repository when using scm none?)
|
51
|
+
* Support ignores, like .git
|
52
|
+
* Test and document using to pulling remote changes back to local directory
|
53
|
+
* Write tests with [capistrano-spec](https://github.com/technicalpickles/capistrano-spec)
|
54
|
+
* Reset unison lock files and info, ie that is kept on ~/.unison. Interrupting a unison run can leave these around, and is super annoying to manually remove. unison will spit out what needs to be removed as part of its output, so that could be parsed
|
55
|
+
* Test and fix working with conflicting versions of unison on client/server
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
1. Fork it
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/unison/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "capistrano-unison"
|
8
|
+
gem.version = Capistrano::Unison::VERSION
|
9
|
+
gem.authors = ["Josh Nichols"]
|
10
|
+
gem.email = ["josh@technicalpickles.com"]
|
11
|
+
gem.description = %q{Capistrano::Unison adds support to capistrano for deploying with unison. This lets you synchronize your local working directory with a cache on the remote servers, significantly speeding up deployment times if you are testing a lot of very small changes during deployment.}
|
12
|
+
gem.summary = %q{Deploy code using capistrano and unison}
|
13
|
+
gem.homepage = "http://github.com/railsmachine/capistrano-unison"
|
14
|
+
gem.add_dependency('capistrano')
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'capistrano/recipes/deploy/strategy/base'
|
2
|
+
module Capistrano
|
3
|
+
module Deploy
|
4
|
+
module Strategy
|
5
|
+
class Unison < Base
|
6
|
+
def deploy!
|
7
|
+
find_servers.each do |server|
|
8
|
+
flags = [
|
9
|
+
'-auto',
|
10
|
+
'-batch',
|
11
|
+
'-terse',
|
12
|
+
'-contactquietly',
|
13
|
+
'-force .',
|
14
|
+
'-ignore "Name {.git}"',
|
15
|
+
'-ignore "Name {,.}*{.git}"'
|
16
|
+
]
|
17
|
+
system "unison #{flags.join(' ')} . ssh://#{server}/#{shared_path}/unison-copy"
|
18
|
+
# abort unless $?.success?
|
19
|
+
end
|
20
|
+
run "ln -sf #{shared_path}/unison-copy #{release_path}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
|
3
|
+
module Capistrano
|
4
|
+
module Unison
|
5
|
+
def self.load_into(configuration)
|
6
|
+
configuration.load do
|
7
|
+
namespace :unison do
|
8
|
+
task :default do
|
9
|
+
set :repository, "."
|
10
|
+
set :deploy_via, :unison
|
11
|
+
set :scm, :none
|
12
|
+
after 'moonshine:configure', 'unison:default'
|
13
|
+
end
|
14
|
+
task :setup do
|
15
|
+
sudo "apt-get update"
|
16
|
+
sudo "apt-get install -y unison"
|
17
|
+
copy # do an initial copy
|
18
|
+
end
|
19
|
+
task :copy do
|
20
|
+
find_servers.each do |server|
|
21
|
+
system "unison -auto -batch -contactquietly . ssh://#{server}/#{shared_path}/unison-copy"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if Capistrano::Configuration.instance
|
33
|
+
Capistrano::Unison.load_into(Capistrano::Configuration.instance)
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-unison
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Nichols
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: &70331390884500 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70331390884500
|
25
|
+
description: Capistrano::Unison adds support to capistrano for deploying with unison.
|
26
|
+
This lets you synchronize your local working directory with a cache on the remote
|
27
|
+
servers, significantly speeding up deployment times if you are testing a lot of
|
28
|
+
very small changes during deployment.
|
29
|
+
email:
|
30
|
+
- josh@technicalpickles.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- capistrano-unison.gemspec
|
41
|
+
- lib/capistrano-unison.rb
|
42
|
+
- lib/capistrano/recipes/deploy/strategy/unison.rb
|
43
|
+
- lib/capistrano/unison.rb
|
44
|
+
- lib/capistrano/unison/version.rb
|
45
|
+
homepage: http://github.com/railsmachine/capistrano-unison
|
46
|
+
licenses: []
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.8.10
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Deploy code using capistrano and unison
|
69
|
+
test_files: []
|
70
|
+
has_rdoc:
|