capistrano-withrsync 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1f63b8e34f6b36e17cc7f1aa3bb12f16f5911b8
4
- data.tar.gz: a17e0538c3f58d3f6e3fa141490f338320d63544
3
+ metadata.gz: 9024bc30f23503a0351a2d4d6ede53fc4e522a95
4
+ data.tar.gz: 3d65c63d21ded7fd3761b5a4b4f9d496eb319d68
5
5
  SHA512:
6
- metadata.gz: 92d56e18ac4c0ecdadb4983403cdbf63fb87f9bc1ef69ce4742eee448fc41db796dac1d61ced716af9d387da8b9639d9a6f9cc1a1bdcc1dac1ce3a86e5ca061d
7
- data.tar.gz: 8d3856bea902a339613854b8455f8999a8f766eb050c0aa0bfb17df22b1c17f00bc00bb8f55c3488163b9cfac185fc043c8f19fcfce49d8e9f219219201ecc7e
6
+ metadata.gz: 2b6021dcf6c61af1f934e4c6a59dcc4df584b65a54d4f240b4016e25ded50cd181740c4fa0ef786d950cf364c09abc151c4bec724c2557bec89d5776d1429463
7
+ data.tar.gz: 4ff0d05aff67bd0a99369854948d1460796744b1b09fd1c2f5468caa6694a99e42b5897e221102546c565195077017fef4b44b172cfeb0bd3502a810c327c15f
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
- --require spec_helper
2
+ --require helper
3
+ --format documentation
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in capistrano-withrsync.gemspec
4
3
  gemspec
5
4
 
6
- gem 'pry'
7
- gem 'rspec'
8
- gem 'tid'
5
+ group :test do
6
+ gem 'rspec'
7
+ gem 'pry'
8
+ end
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:test) do |spec|
6
+ spec.pattern = 'spec/**/*_spec.rb'
7
+ end
8
+
9
+ task :default => :test
@@ -85,21 +85,14 @@ namespace :rsync do
85
85
 
86
86
  desc 'Sync to deployment hosts from local'
87
87
  task sync: :'rsync:stage' do
88
- last_rsync_to = nil
89
- release_roles(:all).each do |role|
90
- unless Capistrano::Configuration.env.filter(role).roles_array.empty?
91
- run_locally do
92
- user = "#{role.user}@" if !role.user.nil?
93
- rsync_options = "#{fetch(:rsync_options).join(' ')}"
94
- rsync_from = "#{fetch(:rsync_src)}/"
95
- rsync_to = Shellwords.escape("#{user}#{role.hostname}:#{fetch(:rsync_dest_fullpath) || release_path}")
96
-
97
- unless rsync_to == last_rsync_to
98
- execute :rsync, rsync_options, rsync_from, rsync_to
99
- last_rsync_to = rsync_to
100
- end
101
- end
102
- end
88
+ release_roles(:all).each do |server|
89
+ run_locally do
90
+ user = "#{server.user}@" if !server.user.nil?
91
+ rsync_options = "#{fetch(:rsync_options).join(' ')}"
92
+ rsync_from = "#{fetch(:rsync_src)}/"
93
+ rsync_to = Shellwords.escape("#{user}#{server.hostname}:#{fetch(:rsync_dest_fullpath) || release_path}")
94
+ execute :rsync, rsync_options, rsync_from, rsync_to
95
+ end unless server.roles.empty?
103
96
  end
104
97
  end
105
98
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Withrsync
3
- VERSION = '0.2.2'
3
+ VERSION = '0.2.3'
4
4
  end
5
5
  end
data/spec/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'capistrano/all'
2
+ require 'rspec'
3
+
4
+ load 'capistrano/setup.rb'
5
+
6
+ def run_task(name, *args)
7
+ Rake.application.options.trace = !!ENV['DEBUG']
8
+ Rake::Task[name].reenable
9
+ Rake::Task[name].invoke(*args)
10
+ end
data/spec/task_spec.rb ADDED
@@ -0,0 +1,156 @@
1
+ describe 'task' do
2
+ let(:user) { 'deploy' }
3
+ let(:escaped_user) { 'deploy' }
4
+ let(:submodule) { false }
5
+
6
+ before do
7
+ Rake.application.rake_require 'capistrano/tasks/deploy'
8
+ Rake.application.rake_require 'capistrano/tasks/git'
9
+ Rake.application.rake_require 'capistrano/tasks/framework'
10
+ Rake.application.rake_require 'capistrano/tasks/withrsync'
11
+
12
+ # for capistrano v3.2
13
+ servers = Capistrano::Configuration.env.send(:servers)
14
+ servers.send(:servers).clear unless servers.to_a.length.zero?
15
+
16
+ server 'example1.com', user: user, roles: %w(web)
17
+ server 'example2.com', user: user, roles: %w(app web)
18
+ server 'example3.com', user: user, roles: %w(db), no_release: true
19
+
20
+ set :application, 'my_app_name'
21
+ set :repo_url, 'https://github.com/linyows/capistrano-withrsync.git'
22
+ set :branch, 'master'
23
+ set :deploy_to, Pathname.new('/var/www/app')
24
+ set :scm, :git
25
+ set :shared_path, deploy_to.join('shared')
26
+ set :current_path, deploy_to.join('current')
27
+ set :releases_path, deploy_to.join('releases')
28
+ set :release_path, releases_path.join(Time.now.utc.strftime "%Y%m%d%H%M%S")
29
+ set :rsync_with_submodules, submodule
30
+ set :format_options, log_file: nil
31
+ set :stage, 'test'
32
+ end
33
+
34
+ shared_context :create_src do
35
+ before do
36
+ allow_any_instance_of(SSHKit::Backend::Local).to receive(:execute).
37
+ with(:git, :clone, nil, fetch(:repo_url), fetch(:rsync_src))
38
+ end
39
+ end
40
+
41
+ shared_context :check_dir do
42
+ before do
43
+ allow_any_instance_of(SSHKit::Backend::Local).to receive(:execute).
44
+ with(" if test ! -d tmp/deploy\n then echo \"Directory does not exist '#{fetch :rsync_src}'\" 1>&2\n false\n fi\n", {:verbosity=>0})
45
+ end
46
+ end
47
+
48
+ shared_context :stage do
49
+ before do
50
+ allow_any_instance_of(SSHKit::Backend::Local).to receive(:execute).
51
+ with(:git, :fetch, nil, '--quiet --all --prune')
52
+ allow_any_instance_of(SSHKit::Backend::Local).to receive(:execute).
53
+ with(:git, :reset, '--hard origin/master')
54
+ end
55
+ end
56
+
57
+ shared_context :stage_with_submodule do
58
+ before do
59
+ allow_any_instance_of(SSHKit::Backend::Local).to receive(:execute).
60
+ with(:git, :fetch, '--recurse-submodules=on-demand', '--quiet --all --prune')
61
+ allow_any_instance_of(SSHKit::Backend::Local).to receive(:execute).
62
+ with(:git, :submodule, :update, '--init')
63
+ end
64
+ end
65
+
66
+ shared_context :sync do
67
+ before do
68
+ 1.upto 2 do |i|
69
+ host = "example#{i}.com"
70
+ allow_any_instance_of(SSHKit::Backend::Local).to receive(:execute).
71
+ with(:rsync, '--recursive --delete --delete-excluded --exclude .git* --exclude .svn*',
72
+ 'tmp/deploy/', "#{escaped_user}@#{host}:#{fetch(:deploy_to)}/shared/deploy")
73
+ end
74
+ end
75
+ end
76
+
77
+ describe 'attributes' do
78
+ %i(
79
+ rsync_options
80
+ rsync_copy_options
81
+ rsync_src
82
+ rsync_dest
83
+ rsync_dest_fullpath
84
+ rsync_with_submodules
85
+ ).each do |k|
86
+ it "contain #{k}" do
87
+ expect(env.keys).to include k
88
+ end
89
+ end
90
+ end
91
+
92
+ describe 'stage' do
93
+ include_context :create_src
94
+ include_context :check_dir
95
+ include_context :stage
96
+
97
+ it 'sets up repository on local' do
98
+ run_task :'rsync:stage'
99
+ end
100
+
101
+ context 'uses git submodule' do
102
+ let(:submodule) { true }
103
+ include_context :stage_with_submodule
104
+
105
+ it 'supports submodule' do
106
+ run_task :'rsync:stage'
107
+ end
108
+ end
109
+ end
110
+
111
+ describe 'sync' do
112
+ include_context :create_src
113
+ include_context :check_dir
114
+ include_context :stage
115
+ include_context :sync
116
+
117
+ it 'synchronizes to remote from local' do
118
+ run_task :'rsync:sync'
119
+ end
120
+
121
+ context 'includes space in username' do
122
+ let(:user) { 'deploy user' }
123
+ let(:escaped_user) { "deploy\\ user" }
124
+
125
+ it 'escapes username' do
126
+ run_task :'rsync:sync'
127
+ end
128
+ end
129
+
130
+ context 'excludes no-role hosts' do
131
+ before do
132
+ server 'example4.com', user: user, roles: %w()
133
+ server 'example5.com', user: user
134
+ end
135
+
136
+ it 'contains no-role hosts' do
137
+ run_task :'rsync:sync'
138
+ end
139
+ end
140
+ end
141
+
142
+ describe 'release' do
143
+ include_context :create_src
144
+ include_context :check_dir
145
+ include_context :stage
146
+ include_context :sync
147
+
148
+ it 'releases from temp directory on remote' do
149
+ allow_any_instance_of(SSHKit::Backend::Netssh).to receive(:execute).
150
+ with(:rsync, '--archive --acls --xattrs',
151
+ "#{fetch(:shared_path).join('deploy')}/", "#{fetch :release_path}/")
152
+
153
+ run_task :'rsync:release'
154
+ end
155
+ end
156
+ end
data/wercker.yml CHANGED
@@ -1,23 +1,14 @@
1
- box: wercker-labs/docker
1
+ box: wercker/rvm
2
2
  build:
3
3
  steps:
4
- - install-packages:
5
- packages: build-essential ruby2.0 ruby2.0-dev bundler
6
- - script:
7
- name: install latest docker
8
- code: |
9
- docker version
10
- curl -s http://get.docker.io/ubuntu/ | sudo sh
11
- docker version
12
- - script:
13
- name: chmod private key
14
- code: chmod 600 ./spec/tid/id_rsa
15
- - script:
16
- name: create ssh config
17
- code: |
18
- echo "Host *" >> ~/.ssh/config
19
- echo " StrictHostKeyChecking no" >> ~/.ssh/config
4
+ - rvm-use:
5
+ version: ruby-2.3.0
20
6
  - bundle-install
21
7
  - script:
22
8
  name: rspec
23
9
  code: bundle exec rspec
10
+
11
+ after-steps:
12
+ - linyows/slack_notification:
13
+ token: $SLACK_TOKEN
14
+ channel: C02FCHEQH
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-withrsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - linyows
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-24 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -71,15 +71,8 @@ files:
71
71
  - lib/capistrano/withrsync.rb
72
72
  - lib/capistrano/withrsync/rake/task.rb
73
73
  - lib/capistrano/withrsync/version.rb
74
- - spec/feature_spec.rb
75
- - spec/spec_helper.rb
76
- - spec/tid/Capfile
77
- - spec/tid/Dockerfile
78
- - spec/tid/Gemfile
79
- - spec/tid/config/deploy.rb
80
- - spec/tid/config/deploy/test.rb
81
- - spec/tid/id_rsa
82
- - spec/tid/id_rsa.pub
74
+ - spec/helper.rb
75
+ - spec/task_spec.rb
83
76
  - wercker.yml
84
77
  homepage: https://github.com/linyows/capistrano-withrsync
85
78
  licenses:
@@ -101,17 +94,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
94
  version: '0'
102
95
  requirements: []
103
96
  rubyforge_project:
104
- rubygems_version: 2.5.1
97
+ rubygems_version: 2.4.5
105
98
  signing_key:
106
99
  specification_version: 4
107
100
  summary: Capistrano with rsync
108
101
  test_files:
109
- - spec/feature_spec.rb
110
- - spec/spec_helper.rb
111
- - spec/tid/Capfile
112
- - spec/tid/Dockerfile
113
- - spec/tid/Gemfile
114
- - spec/tid/config/deploy.rb
115
- - spec/tid/config/deploy/test.rb
116
- - spec/tid/id_rsa
117
- - spec/tid/id_rsa.pub
102
+ - spec/helper.rb
103
+ - spec/task_spec.rb
data/spec/feature_spec.rb DELETED
@@ -1,17 +0,0 @@
1
- RSpec.describe 'Capistrano with Rsync' do
2
- describe '# bundle exec cap test deploy' do
3
- it 'successful' do
4
- Dir.chdir ENV['TID_BASE_PATH'] do
5
- _, _, ex = cmd 'bundle exec cap test deploy'
6
- expect(ex.exitstatus).to eq 0
7
- end
8
- end
9
-
10
- it 'puts some string' do
11
- Dir.chdir ENV['TID_BASE_PATH'] do
12
- out, _, _ = cmd 'bundle exec cap test deploy'
13
- expect(out).to include 'Running /usr/bin/env rsync -e \'ssh -p'
14
- end
15
- end
16
- end
17
- end
data/spec/spec_helper.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'tid'
2
-
3
- RSpec.configure do |config|
4
- config.expect_with :rspec do |expectations|
5
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
6
- end
7
-
8
- config.mock_with :rspec do |mocks|
9
- mocks.verify_partial_doubles = true
10
- end
11
-
12
- config.include(Tid)
13
- config.before(:all) {
14
- Tid.bundle
15
- Tid.prepare
16
- }
17
- config.after(:all) { Tid.clear }
18
- end
data/spec/tid/Capfile DELETED
@@ -1,3 +0,0 @@
1
- require 'capistrano/setup'
2
- require 'capistrano/deploy'
3
- require 'capistrano/withrsync'
data/spec/tid/Dockerfile DELETED
@@ -1,9 +0,0 @@
1
- FROM rastasheep/ubuntu-sshd:14.04
2
- MAINTAINER linyows <linyows@gmail.com>
3
-
4
- ENV HOME /root
5
- RUN apt-get install -y rsync
6
- RUN mkdir /root/.ssh
7
- ADD id_rsa.pub /root/.ssh/authorized_keys
8
- RUN chmod 700 /root/.ssh
9
- RUN chmod 600 /root/.ssh/authorized_keys
data/spec/tid/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'capistrano-withrsync'
@@ -1,24 +0,0 @@
1
- host = ENV['TID_HOSTNAME']
2
- port = ENV['TID_PORT']
3
-
4
- server host,
5
- user: 'root',
6
- roles: %w(app),
7
- ssh_options: {
8
- port: port,
9
- user: 'root',
10
- keys: %w(./id_rsa),
11
- forward_agent: false,
12
- auth_methods: %w(publickey)
13
- }
14
-
15
- namespace :rsync do
16
- set :rsync_options, [
17
- "-e 'ssh -p #{port} -i ./id_rsa'",
18
- '--recursive',
19
- '--delete',
20
- '--delete-excluded',
21
- '--exclude .git*',
22
- '--exclude .svn*',
23
- ]
24
- end
@@ -1,8 +0,0 @@
1
- Rake::Task['metrics:collect'].clear_actions
2
-
3
- set :application, 'capistrano_with_rsync'
4
- set :repo_url, 'https://github.com/linyows/capistrano-withrsync.git'
5
- set :deploy_to, '/var/capistrano_with_rsync'
6
- set :scm, :git
7
- set :format, :pretty
8
- set :log_level, :debug
data/spec/tid/id_rsa DELETED
@@ -1,27 +0,0 @@
1
- -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0FmOfvB9fEE43ez7Pts7f7qQxslVu
18
- lwiFInDQX21xP5OBTtyXdVSrRPmDTCQGtw4ECruvAoGAfsU5ckVWQUyM6kxnEjF5
19
- 6V2vN9sONIJViYzaZVL8WjXZrXjJ5Q6Klw6YZwg3u7cCRCV3UETuLzO/PSKY1dvh
20
- ioprFQxkohb/JZhkzcaQpWOe/3Q6i2pEeDtNVhQwiZoPXHW10jU2FkmLDP/gopAo
21
- n7hJEgVkD15eJUvtflJsE4kCgYA3z0RB9rdeIr8/y2KD7xFWAfgxzw4yWVjOU0th
22
- V4SqZr2YW9HvArPXX4915v64wpBvcH45IBrmtJMLrz/WITMbHc4S78Z+n6iHH7Gs
23
- RtheW+1aLraQOv+D4LTY8eWEc7rTfGHNLYqRSyanQkxTdyRs0x4Lj7r/frbbOmSh
24
- 8fa9KQKBgQDmxFjHtl7gS58+vlMQZ+M76ChUO+Bvlz4A7No52jQkDvHV0M2Ev5t1
25
- H74LIInwkghw8qAOiOSzaFEyEJANDGX9998qTLMKpQF/iZ5cz86uIKsqGBN9sM28
26
- zgAhOfA4IkTKAtDOWU9mH3ONet27Kx2acsansL5LU3evm+LE4M1Emg==
27
- -----END RSA PRIVATE KEY-----
data/spec/tid/id_rsa.pub DELETED
@@ -1 +0,0 @@
1
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDnhFW/f5eNQVw4kLlAPXChsjCQAC+JwTP8iGirSVWGHc1NK/vLImXdcqrYqqfNgKWfpMVdSJARLohp4N/e6wfnnAo6eSC27GaqfQurppVXovLyB9Pio64pMAx91C53ZVPm8FFYizGTE+iD1DrQRZ/326cIYHXrC4ysYA9HBjA9ANVsFxaUNHtWSSxexTW/DDe7Hn30ZsvqVPvge/NbzraifDCYKp6x58evvgCKL/mJFVNQFhht7+k3V2b8Xu2BPqcSSl1vPNHLpzLTM39/MJHoUJ2zXunWru6NsnPuHPPPcQnAUi5uO2eeMCo5AOxEROSV4zpHPCCElkdX8+w6rkdr tomohisaoda@PMAC127S.local