capistrano-bundle_rsync 0.5.2 → 0.6.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +30 -0
- data/CHANGELOG.md +18 -0
- data/README.md +12 -1
- data/capistrano-bundle_rsync.gemspec +2 -2
- data/lib/capistrano/bundle_rsync/bundler.rb +28 -10
- data/lib/capistrano/bundle_rsync/config.rb +21 -10
- data/lib/capistrano/bundle_rsync/defaults.rb +42 -0
- data/lib/capistrano/bundle_rsync/git.rb +1 -1
- data/lib/capistrano/bundle_rsync/git_turbo.rb +96 -0
- data/lib/capistrano/bundle_rsync/local_git.rb +1 -1
- data/lib/capistrano/bundle_rsync/plugin.rb +5 -0
- data/lib/capistrano/bundle_rsync/scm.rb +3 -21
- data/lib/capistrano/bundle_rsync.rb +3 -0
- data/lib/capistrano/tasks/bundle_rsync.rake +5 -1
- data/spec/spec_helper.rb +19 -3
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdbec22674e3aa432b0f63649aff52b7f0d78973ba111942b645457275cec18d
|
4
|
+
data.tar.gz: d6497efbdf096e3d20a0fb8a1dc2bd9104ea56246940e0e50a3ff17be09020a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7178f6918d8a847d66d04aa5e054f61a698f5313851642082f32d720e88bb4f631e1b457b00232810b97add0af3a329d1ef4858623e51f756a99b41b1fd1732
|
7
|
+
data.tar.gz: c171464ff5632dd688295f2ca86a2f090ba23bdba858ca0182d83caf82bf2bcd76fbdd454d5c861a8406f9907746ae004c0c0564a4caf9ed5c8c4f57a22a3f51
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
|
8
|
+
pull_request:
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
name: Ruby ${{ matrix.ruby }}
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby:
|
17
|
+
- '2.7'
|
18
|
+
- '3.0'
|
19
|
+
- '3.1'
|
20
|
+
- '3.2'
|
21
|
+
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v3
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
28
|
+
bundler-cache: true
|
29
|
+
- name: Run Test
|
30
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# 0.6.0 (2025/03/14)
|
2
|
+
|
3
|
+
New Features:
|
4
|
+
|
5
|
+
* Introduce `set :bundle_rsync_scm, :git_turbo` strategy for super-fast deployment (@aeroastro)
|
6
|
+
* Support `set :bundle_rsync_app_path, <path>` option to specify where to run `bundle` (@aeroastro)
|
7
|
+
* Support `set :bundle_rsync_bundle_install_jobs, <N>` option to control `bundle install --jobs <N>` (thanks to @grezar)
|
8
|
+
|
9
|
+
Enhancements:
|
10
|
+
|
11
|
+
* Improve plugin support (`set_defaults`) for Capistrano 3.7+ (@aeroastro)
|
12
|
+
* Accelerate deployment by syncing multiple configs with one `rsync` call (@aeroastro)
|
13
|
+
|
14
|
+
Fixes:
|
15
|
+
|
16
|
+
* Allow `capistrano-bundle_rsync` to deploy apps with different Ruby version from that of deploying environment (@aeroastro)
|
17
|
+
* Fix bundler deprecation of `Bundler.with_clean_env` (@aeroastro)
|
18
|
+
|
1
19
|
# 0.5.2 (2019/02/14)
|
2
20
|
|
3
21
|
Fixes:
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ branch | `master` | The Git branch to checkout.
|
|
51
51
|
ssh_options | `{}` | Configuration of ssh :user and :keys.
|
52
52
|
keep\_releases | 5 | The number of releases to keep.
|
53
53
|
scm | nil | Must be `bundle_rsync` to use capistrano-bundle_rsync.
|
54
|
-
bundle_rsync_scm | `git` | SCM Strategy inside `bundle_rsync`. `git
|
54
|
+
bundle_rsync_scm | `git` | SCM Strategy inside `bundle_rsync`. `git`, `local_git`, or `git_turbo` can be specified.
|
55
55
|
bundle_rsync_local_base_path | `$(pwd)/.local_repo` | The base directory to clone repository
|
56
56
|
bundle_rsync_local_mirror_path | `#{base_path}/mirror"` | Path where to mirror your repository
|
57
57
|
bundle_rsync_local_releases_path | `"#{base_path}/releases"` | The releases base directory to checkout your repository
|
@@ -64,10 +64,21 @@ bundle_rsync_rsync_bwlimit | nil | Configuration of rsync --bwlimit (KBPS) optio
|
|
64
64
|
bundle_rsync_rsync_options | `-az --delete` | Configuration of rsync options.
|
65
65
|
bundle_rsync_config_files | `nil` | Additional files to rsync. Specified files are copied into `config` directory.
|
66
66
|
bundle_rsync_shared_dirs | `nil` | Additional directories to rsync. Specified directories are copied into `shared` directory.
|
67
|
+
bundle_rsync_app_path | `.` | A relative app path from local `bundle_rsync_local_release_path` and from remote `release_path`. `bundle` commands are executed here, and directories like `.bundle/config` and `config` will be located in this directory.
|
67
68
|
bundle_rsync_skip_bundle | false | (Secret option) Do not `bundle` and rsync bundle.
|
69
|
+
bundle_rsync_bundle_install_jobs | `nil` | Configuration of bundle install with --jobs option.
|
68
70
|
bundle_rsync_bundle_install_standalone | `nil` | bundle install with --standalone option. Set one of `true`, `false`, an `Array` of groups, or a white space separated `String`.
|
69
71
|
bundle_rsync_bundle_without | `[:development, :test]` | Configuration of bundle install with --without option.
|
70
72
|
|
73
|
+
### BundleRsync SCM Strategies
|
74
|
+
|
75
|
+
* git
|
76
|
+
* Original Strategy Using Git
|
77
|
+
* local_git
|
78
|
+
* Directly Rsync Local (Non-Bare) Git Directory at `repo_url` Path to Remote Release Path
|
79
|
+
* git_turbo
|
80
|
+
* Super-Fast Deployment Utilizing Git Worktree, Hardlink, and Rsync
|
81
|
+
|
71
82
|
## Task Orders
|
72
83
|
|
73
84
|
```
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "capistrano-bundle_rsync"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.6.0"
|
8
8
|
spec.authors = ["Naotoshi Seo", "tohae"]
|
9
9
|
spec.email = ["sonots@gmail.com", "tohaechan@gmail.com"]
|
10
10
|
spec.description = %q{Deploy an application and bundled gems via rsync}
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency 'capistrano', '>= 3.3.3'
|
21
21
|
spec.add_dependency 'parallel'
|
22
|
-
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "bundler"
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3"
|
25
25
|
end
|
@@ -3,22 +3,40 @@ require 'capistrano/configuration/filter'
|
|
3
3
|
|
4
4
|
class Capistrano::BundleRsync::Bundler < Capistrano::BundleRsync::Base
|
5
5
|
def install
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
within config.local_release_app_path do
|
7
|
+
Bundler.public_send(Bundler.respond_to?(:with_unbundled_env) ? :with_unbundled_env : :with_clean_env) do
|
8
|
+
with bundle_app_config: config.local_base_path, rbenv_version: nil, rbenv_dir: nil do
|
9
|
+
bundle_commands = if test :rbenv, 'version'
|
10
|
+
%w[rbenv exec bundle]
|
11
|
+
else
|
12
|
+
%w[bundle]
|
13
|
+
end
|
14
|
+
|
15
|
+
execute *bundle_commands, 'config', '--local', 'deployment', 'true'
|
16
|
+
execute *bundle_commands, 'config', '--local', 'path', config.local_bundle_path
|
17
|
+
execute *bundle_commands, 'config', '--local', 'without', *config.bundle_without
|
18
|
+
|
19
|
+
opts = ['--quiet']
|
20
|
+
if jobs = config.bundle_install_jobs
|
21
|
+
opts.push('--jobs', jobs)
|
22
|
+
end
|
23
|
+
|
24
|
+
if standalone = config.bundle_install_standalone_option
|
25
|
+
opts.push(standalone)
|
26
|
+
end
|
27
|
+
|
28
|
+
execute *bundle_commands, *opts
|
29
|
+
execute :rm, "#{config.local_base_path}/config"
|
11
30
|
end
|
12
|
-
execute :bundle, opts
|
13
|
-
execute :rm, "#{config.local_base_path}/config"
|
14
31
|
end
|
15
32
|
end
|
16
33
|
end
|
17
34
|
|
18
35
|
def rsync
|
19
36
|
hosts = release_roles(:all)
|
37
|
+
release_app_path = config.release_app_path
|
20
38
|
on hosts, in: :groups, limit: config.max_parallels(hosts) do
|
21
|
-
within
|
39
|
+
within release_app_path do
|
22
40
|
execute :mkdir, '-p', '.bundle'
|
23
41
|
end
|
24
42
|
end
|
@@ -29,7 +47,7 @@ BUNDLE_FROZEN: '1'
|
|
29
47
|
BUNDLE_PATH: #{shared_path.join('bundle')}
|
30
48
|
BUNDLE_WITHOUT: #{config.bundle_without.join(':')}
|
31
49
|
BUNDLE_DISABLE_SHARED_GEMS: '1'
|
32
|
-
BUNDLE_BIN: #{
|
50
|
+
BUNDLE_BIN: #{release_app_path.join('bin')}
|
33
51
|
EOS
|
34
52
|
# BUNDLE_BIN requires rbenv-binstubs plugin to make it effectively work
|
35
53
|
bundle_config_path = "#{config.local_base_path}/bundle_config"
|
@@ -40,7 +58,7 @@ BUNDLE_BIN: #{release_path.join('bin')}
|
|
40
58
|
Parallel.each(hosts, in_threads: config.max_parallels(hosts)) do |host|
|
41
59
|
ssh = config.build_ssh_command(host)
|
42
60
|
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_bundle_path}/ #{host}:#{shared_path}/bundle/"
|
43
|
-
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{bundle_config_path} #{host}:#{
|
61
|
+
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{bundle_config_path} #{host}:#{release_app_path}/.bundle/config"
|
44
62
|
end
|
45
63
|
end
|
46
64
|
end
|
@@ -1,23 +1,31 @@
|
|
1
1
|
module Capistrano::BundleRsync
|
2
2
|
class Config
|
3
3
|
def self.local_base_path
|
4
|
-
@local_base_path ||= fetch(:bundle_rsync_local_base_path)
|
4
|
+
@local_base_path ||= fetch(:bundle_rsync_local_base_path)
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.local_mirror_path
|
8
|
-
@local_mirror_path ||= fetch(:bundle_rsync_local_mirror_path)
|
8
|
+
@local_mirror_path ||= fetch(:bundle_rsync_local_mirror_path)
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.local_releases_path
|
12
|
-
@local_releases_path ||= fetch(:bundle_rsync_local_releases_path)
|
12
|
+
@local_releases_path ||= fetch(:bundle_rsync_local_releases_path)
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.local_release_path
|
16
|
-
@local_release_path ||= fetch(:bundle_rsync_local_release_path)
|
16
|
+
@local_release_path ||= fetch(:bundle_rsync_local_release_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.local_release_app_path
|
20
|
+
@local_release_app_path ||= Pathname.new(local_release_path).join(fetch(:bundle_rsync_app_path))
|
17
21
|
end
|
18
22
|
|
19
23
|
def self.local_bundle_path
|
20
|
-
@local_bundle_path ||= fetch(:bundle_rsync_local_bundle_path)
|
24
|
+
@local_bundle_path ||= fetch(:bundle_rsync_local_bundle_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.release_app_path
|
28
|
+
@release_app_path ||= release_path.join(fetch(:bundle_rsync_app_path))
|
21
29
|
end
|
22
30
|
|
23
31
|
def self.config_files
|
@@ -60,7 +68,7 @@ module Capistrano::BundleRsync
|
|
60
68
|
# NOTE: :password is not supported.
|
61
69
|
def self.build_ssh_command(host)
|
62
70
|
user_opt, key_opt, port_opt = "", "", ""
|
63
|
-
ssh_options = fetch(:bundle_rsync_ssh_options)
|
71
|
+
ssh_options = fetch(:bundle_rsync_ssh_options)
|
64
72
|
if user = host.user || ssh_options[:user]
|
65
73
|
user_opt = " -l #{user}"
|
66
74
|
end
|
@@ -75,7 +83,7 @@ module Capistrano::BundleRsync
|
|
75
83
|
end
|
76
84
|
|
77
85
|
def self.keep_releases
|
78
|
-
@keep_releases = fetch(:bundle_rsync_keep_releases)
|
86
|
+
@keep_releases = fetch(:bundle_rsync_keep_releases)
|
79
87
|
end
|
80
88
|
|
81
89
|
# Fetch the :bundle_rsync_max_parallels,
|
@@ -85,14 +93,17 @@ module Capistrano::BundleRsync
|
|
85
93
|
end
|
86
94
|
|
87
95
|
def self.rsync_options
|
88
|
-
|
89
|
-
fetch(:bundle_rsync_rsync_options) || "-az --delete#{bwlimit}"
|
96
|
+
fetch(:bundle_rsync_rsync_options)
|
90
97
|
end
|
91
98
|
|
92
99
|
def self.skip_bundle
|
93
100
|
fetch(:bundle_rsync_skip_bundle)
|
94
101
|
end
|
95
102
|
|
103
|
+
def self.bundle_install_jobs
|
104
|
+
fetch(:bundle_rsync_bundle_install_jobs)
|
105
|
+
end
|
106
|
+
|
96
107
|
def self.bundle_install_standalone
|
97
108
|
fetch(:bundle_rsync_bundle_install_standalone)
|
98
109
|
end
|
@@ -111,7 +122,7 @@ module Capistrano::BundleRsync
|
|
111
122
|
end
|
112
123
|
|
113
124
|
def self.bundle_without
|
114
|
-
fetch(:bundle_rsync_bundle_without)
|
125
|
+
fetch(:bundle_rsync_bundle_without)
|
115
126
|
end
|
116
127
|
end
|
117
128
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module BundleRsync
|
3
|
+
module Defaults
|
4
|
+
def self.set_defaults
|
5
|
+
set_if_empty :bundle_rsync_scm, 'git'
|
6
|
+
|
7
|
+
set_if_empty :bundle_rsync_local_base_path, "#{Dir::pwd}/.local_repo"
|
8
|
+
set_if_empty :bundle_rsync_local_mirror_path, -> { "#{fetch(:bundle_rsync_local_base_path)}/mirror" }
|
9
|
+
set_if_empty :bundle_rsync_local_releases_path, -> { "#{fetch(:bundle_rsync_local_base_path)}/releases" }
|
10
|
+
set_if_empty :bundle_rsync_local_release_path, -> {
|
11
|
+
if fetch(:bundle_rsync_scm).to_s == 'local_git'
|
12
|
+
repo_url
|
13
|
+
else # git (default)
|
14
|
+
"#{fetch(:bundle_rsync_local_releases_path)}/#{Time.new.strftime('%Y%m%d%H%M%S')}"
|
15
|
+
end
|
16
|
+
}
|
17
|
+
set_if_empty :bundle_rsync_local_bundle_path, -> { "#{fetch(:bundle_rsync_local_base_path)}/bundle" }
|
18
|
+
|
19
|
+
set_if_empty :bundle_rsync_ssh_options, -> { fetch(:ssh_options, {}) }
|
20
|
+
set_if_empty :bundle_rsync_keep_releases, -> { fetch(:keep_releases) }
|
21
|
+
|
22
|
+
set_if_empty :bundle_rsync_max_parallels, -> { release_roles(:all).size }
|
23
|
+
set_if_empty :bundle_rsync_rsync_bwlimit, nil
|
24
|
+
set_if_empty :bundle_rsync_rsync_options, -> {
|
25
|
+
bwlimit = fetch(:bundle_rsync_rsync_bwlimit)
|
26
|
+
|
27
|
+
bwlimit_option = bwlimit ? " --bwlimit #{bwlimit}" : ""
|
28
|
+
"-az --delete#{bwlimit_option}"
|
29
|
+
}
|
30
|
+
|
31
|
+
set_if_empty :bundle_rsync_config_files, nil
|
32
|
+
set_if_empty :bundle_rsync_shared_dirs, nil
|
33
|
+
set_if_empty :bundle_rsync_app_path, '.'
|
34
|
+
|
35
|
+
set_if_empty :bundle_rsync_skip_bundle, false # NOTE: This is secret option
|
36
|
+
set_if_empty :bundle_rsync_bundle_install_jobs, nil
|
37
|
+
set_if_empty :bundle_rsync_bundle_install_standalone, nil
|
38
|
+
set_if_empty :bundle_rsync_bundle_without, [:development, :test]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -3,7 +3,7 @@ require 'capistrano/configuration/filter'
|
|
3
3
|
|
4
4
|
class Capistrano::BundleRsync::Git < Capistrano::BundleRsync::SCM
|
5
5
|
def check
|
6
|
-
|
6
|
+
execute("git ls-remote #{repo_url} HEAD")
|
7
7
|
execute("mkdir -p #{config.local_base_path}")
|
8
8
|
end
|
9
9
|
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'capistrano/bundle_rsync/scm'
|
3
|
+
|
4
|
+
# Make Deployment Super-Fast by Utilizing Hardlink and Rsync
|
5
|
+
class Capistrano::BundleRsync::GitTurbo < Capistrano::BundleRsync::SCM
|
6
|
+
def check
|
7
|
+
execute :git, 'ls-remote', repo_url, 'HEAD'
|
8
|
+
execute :mkdir, '-p', config.local_base_path
|
9
|
+
execute :mkdir, '-p', config.local_releases_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def clone
|
13
|
+
if test "[ -f #{config.local_mirror_path}/HEAD ]"
|
14
|
+
info t(:mirror_exists, at: config.local_mirror_path)
|
15
|
+
else
|
16
|
+
execute :git, :clone, '--mirror', repo_url, config.local_mirror_path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
within config.local_mirror_path do
|
22
|
+
execute :git, :remote, :update, '--prune'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_release
|
27
|
+
set_current_revision
|
28
|
+
|
29
|
+
worktree = local_worktree_path
|
30
|
+
if test "[ -f #{worktree.join('.git')} ]"
|
31
|
+
within worktree do
|
32
|
+
execute :git, 'checkout', '--detach', fetch(:current_revision)
|
33
|
+
execute :git, 'reset', '--hard'
|
34
|
+
execute :git, 'clean', '--force', '-x'
|
35
|
+
end
|
36
|
+
else
|
37
|
+
within config.local_mirror_path do
|
38
|
+
execute :git, 'worktree', 'add', '-f', '--detach', worktree, fetch(:current_revision)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
source = fetch(:repo_tree) ? worktree.join(fetch(:repo_tree)) : worktree
|
43
|
+
within config.local_base_path do
|
44
|
+
execute :cp, '-al', source, config.local_release_path
|
45
|
+
end
|
46
|
+
|
47
|
+
within config.local_release_path do
|
48
|
+
execute :rm, '-f', '.git'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def clean_release
|
53
|
+
releases = capture(:ls, '-x', config.local_releases_path).split
|
54
|
+
if releases.count >= config.keep_releases
|
55
|
+
directories = (releases - releases.last(config.keep_releases))
|
56
|
+
if directories.any?
|
57
|
+
directories_str = directories.map do |release|
|
58
|
+
File.join(config.local_releases_path, release)
|
59
|
+
end.join(' ')
|
60
|
+
execute :rm, '-rf', directories_str
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def rsync_release
|
66
|
+
hosts = release_roles(:all)
|
67
|
+
c = config
|
68
|
+
on hosts, in: :groups, limit: config.max_parallels(hosts), wait: 0 do |host|
|
69
|
+
execute :mkdir, '-p', releases_path
|
70
|
+
|
71
|
+
if source = capture(:ls, '-x', releases_path).split.last
|
72
|
+
execute :cp, '-al', releases_path.join(source), release_path
|
73
|
+
else
|
74
|
+
execute :mkdir, '-p', release_path
|
75
|
+
end
|
76
|
+
|
77
|
+
run_locally do
|
78
|
+
ssh = c.build_ssh_command(host)
|
79
|
+
execute :rsync, "#{c.rsync_options} --rsh='#{ssh}' #{c.local_release_path}/ #{host}:#{release_path}/"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def set_current_revision
|
85
|
+
within config.local_mirror_path do
|
86
|
+
set :current_revision, capture(:git, "rev-list --max-count=1 #{fetch(:branch)}")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def local_worktree_path
|
93
|
+
Pathname.new("#{fetch(:bundle_rsync_local_base_path)}/git_turbo_worktree")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
@@ -4,7 +4,7 @@ require 'capistrano/configuration/filter'
|
|
4
4
|
class Capistrano::BundleRsync::LocalGit < Capistrano::BundleRsync::SCM
|
5
5
|
def check
|
6
6
|
raise ArgumentError.new('`repo_url` must be local path to use `local_git` scm') unless local_path?(repo_url)
|
7
|
-
|
7
|
+
execute("git ls-remote #{repo_url} HEAD")
|
8
8
|
execute("mkdir -p #{config.local_base_path}")
|
9
9
|
end
|
10
10
|
|
@@ -1,9 +1,14 @@
|
|
1
1
|
require 'capistrano/bundle_rsync'
|
2
2
|
require 'capistrano/scm/plugin'
|
3
|
+
require 'capistrano/bundle_rsync/defaults'
|
3
4
|
|
4
5
|
module Capistrano
|
5
6
|
module BundleRsync
|
6
7
|
class Plugin < Capistrano::SCM::Plugin
|
8
|
+
def set_defaults
|
9
|
+
Defaults.set_defaults
|
10
|
+
end
|
11
|
+
|
7
12
|
def register_hooks
|
8
13
|
after "deploy:new_release_path", "bundle_rsync:create_release"
|
9
14
|
before "deploy:check", "bundle_rsync:check"
|
@@ -5,19 +5,6 @@ require 'capistrano/configuration/filter'
|
|
5
5
|
#
|
6
6
|
# @abstract
|
7
7
|
class Capistrano::BundleRsync::SCM < Capistrano::BundleRsync::Base
|
8
|
-
# @abstract
|
9
|
-
#
|
10
|
-
# Your implementation should check the existence of a cache repository on
|
11
|
-
# the deployment target
|
12
|
-
#
|
13
|
-
# @return [Boolean]
|
14
|
-
#
|
15
|
-
def test
|
16
|
-
raise NotImplementedError.new(
|
17
|
-
"Your SCM strategy module should provide a #test method"
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
8
|
# @abstract
|
22
9
|
#
|
23
10
|
# Your implementation should check if the specified remote-repository is
|
@@ -107,20 +94,15 @@ class Capistrano::BundleRsync::SCM < Capistrano::BundleRsync::Base
|
|
107
94
|
if config_files = config.config_files
|
108
95
|
Parallel.each(hosts, in_threads: config.max_parallels(hosts)) do |host|
|
109
96
|
ssh = config.build_ssh_command(host)
|
110
|
-
config_files.
|
111
|
-
basename = File.basename(config_file)
|
112
|
-
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config_file} #{host}:#{release_path}/config/#{basename}"
|
113
|
-
end
|
97
|
+
execute :rsync, rsync_options, "--rsh='#{ssh}'", *config_files.map(&:to_s), "#{host}:#{config.release_app_path}/config/"
|
114
98
|
end
|
115
99
|
end
|
116
100
|
|
117
101
|
if shared_dirs = config.shared_dirs
|
118
102
|
Parallel.each(hosts, in_threads: config.max_parallels(hosts)) do |host|
|
119
103
|
ssh = config.build_ssh_command(host)
|
120
|
-
shared_dirs.
|
121
|
-
|
122
|
-
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{shared_dir}/ #{host}:#{shared_path}/#{basename}/"
|
123
|
-
end
|
104
|
+
shared_dirs_without_suffix = shared_dirs.map { |dir| dir.to_s.delete_suffix('/') }
|
105
|
+
execute :rsync, rsync_options, "--rsh='#{ssh}'", *shared_dirs_without_suffix, "#{host}:#{shared_path}/"
|
124
106
|
end
|
125
107
|
end
|
126
108
|
end
|
@@ -15,10 +15,14 @@ namespace :bundle_rsync do
|
|
15
15
|
|
16
16
|
def bundle_rsync_scm
|
17
17
|
@bundle_rsync_scm ||=
|
18
|
-
|
18
|
+
case fetch(:bundle_rsync_scm).to_s
|
19
|
+
when 'local_git'
|
19
20
|
require 'capistrano/bundle_rsync/local_git'
|
20
21
|
set :bundle_rsync_local_release_path, repo_url
|
21
22
|
Capistrano::BundleRsync::LocalGit.new(self)
|
23
|
+
when 'git_turbo'
|
24
|
+
require 'capistrano/bundle_rsync/git_turbo'
|
25
|
+
Capistrano::BundleRsync::GitTurbo.new(self)
|
22
26
|
else
|
23
27
|
require 'capistrano/bundle_rsync/git'
|
24
28
|
Capistrano::BundleRsync::Git.new(self)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,20 @@
|
|
1
|
-
require 'capistrano/all'
|
2
|
-
|
3
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
4
|
-
|
2
|
+
|
3
|
+
# Emulate cap command
|
4
|
+
# https://github.com/capistrano/capistrano/blob/31e142d56f8d894f28404fb225dcdbe7539bda18/bin/cap
|
5
|
+
require "capistrano/all"
|
6
|
+
|
7
|
+
# Emulate Capfile
|
8
|
+
|
9
|
+
# Load DSL and Setup Up Stages
|
10
|
+
require 'capistrano/setup'
|
11
|
+
|
12
|
+
# Includes default deployment tasks
|
13
|
+
require 'capistrano/deploy'
|
14
|
+
|
15
|
+
if Gem::Version.new(Capistrano::VERSION) >= Gem::Version.new('3.7')
|
16
|
+
require 'capistrano/bundle_rsync/plugin'
|
17
|
+
install_plugin Capistrano::BundleRsync::Plugin
|
18
|
+
else
|
19
|
+
require 'capistrano/bundle_rsync'
|
20
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-bundle_rsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
- tohae
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2025-03-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: capistrano
|
@@ -43,16 +42,16 @@ dependencies:
|
|
43
42
|
name: bundler
|
44
43
|
requirement: !ruby/object:Gem::Requirement
|
45
44
|
requirements:
|
46
|
-
- - "
|
45
|
+
- - ">="
|
47
46
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
47
|
+
version: '0'
|
49
48
|
type: :development
|
50
49
|
prerelease: false
|
51
50
|
version_requirements: !ruby/object:Gem::Requirement
|
52
51
|
requirements:
|
53
|
-
- - "
|
52
|
+
- - ">="
|
54
53
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
54
|
+
version: '0'
|
56
55
|
- !ruby/object:Gem::Dependency
|
57
56
|
name: rake
|
58
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,6 +88,7 @@ executables: []
|
|
89
88
|
extensions: []
|
90
89
|
extra_rdoc_files: []
|
91
90
|
files:
|
91
|
+
- ".github/workflows/test.yml"
|
92
92
|
- ".gitignore"
|
93
93
|
- ".rspec"
|
94
94
|
- CHANGELOG.md
|
@@ -110,7 +110,9 @@ files:
|
|
110
110
|
- lib/capistrano/bundle_rsync/base.rb
|
111
111
|
- lib/capistrano/bundle_rsync/bundler.rb
|
112
112
|
- lib/capistrano/bundle_rsync/config.rb
|
113
|
+
- lib/capistrano/bundle_rsync/defaults.rb
|
113
114
|
- lib/capistrano/bundle_rsync/git.rb
|
115
|
+
- lib/capistrano/bundle_rsync/git_turbo.rb
|
114
116
|
- lib/capistrano/bundle_rsync/local_git.rb
|
115
117
|
- lib/capistrano/bundle_rsync/plugin.rb
|
116
118
|
- lib/capistrano/bundle_rsync/scm.rb
|
@@ -121,7 +123,6 @@ homepage: https://github.com/sonots/capistrano-bundle_rsync
|
|
121
123
|
licenses:
|
122
124
|
- MIT
|
123
125
|
metadata: {}
|
124
|
-
post_install_message:
|
125
126
|
rdoc_options: []
|
126
127
|
require_paths:
|
127
128
|
- lib
|
@@ -136,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
137
|
- !ruby/object:Gem::Version
|
137
138
|
version: '0'
|
138
139
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
140
|
-
signing_key:
|
140
|
+
rubygems_version: 3.6.2
|
141
141
|
specification_version: 4
|
142
142
|
summary: Deploy an application and bundled gems via rsync.
|
143
143
|
test_files:
|