capistrano-opscomplete 0.6.4 → 1.0.1

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
  SHA256:
3
- metadata.gz: e0b8b15686f2822308863e7af85b079aa35e1473fbd23c3ed8a31251686d02b4
4
- data.tar.gz: 2907023f2972eba8710484f9d2a995b028021e8db4a7b21677672c489f42454f
3
+ metadata.gz: d1cf4271a72e12d2b60d9cbd229b58d64701e1b3958c7d795910f05165a2be98
4
+ data.tar.gz: edec14befbf173cc3e5bcfa16c6ee54feabf28eba6b8f44cdd59b0f54bbbbbf5
5
5
  SHA512:
6
- metadata.gz: '0288303aa496066cc38cba7ee7136647c8da697841831efd16dcd2203794225260e7d2564e99d0b1c6a8b5c874e2f67b31bfd90fb9c95c59b65ea4472f37f824'
7
- data.tar.gz: 35d0304e8b112ee6939bd0c20f93b73c1ec39dcaf753673aa0441f91dd3f46ffb244752c2a3c2098c3d035c7648575e24ec0c3292767aeb602534fae6cdb0f84
6
+ metadata.gz: 5237d339e6abe4060590948891b34809abbbe13c6b24fad22f9bd7292a24d6c220c6f81931388d61c2cffdd3731afcd8197b611b87b5bb7227781782d633b9e7
7
+ data.tar.gz: b368b6403f897168a4c1d257e6b0caebfad7fa87eae9cf7369c62584fa8e45e61b91a0bbbf8010e6c8db8214f05f4460084b36afb50ed2a0253d41b9506ada63
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ ## [1.0.1] - 2021-03-16
2
+
3
+ ### Fixed
4
+ - Made it possible to use `--dry-run` ([#27](https://github.com/makandra/capistrano-opscomplete/issues/27)
5
+
6
+ ## [1.0.0] - 2021-03-16
7
+
8
+ ### Changed
9
+ - Version bump to 1.0 and switch to semantic versioning: There were no breaking changes
10
+ - Remove rbenv dependency for our opscomplete infrastructure
11
+
12
+ ## [0.6.7] - 2021-02-05
13
+
14
+ ### Fixed
15
+ - Fix missing command in opscomplete:nodejs:check
16
+
17
+ ### Changed
18
+ - Improve error message for wrong Node.js version
19
+
20
+ ## [0.6.6] - 2020-12-08
21
+
22
+ ### Fixed
23
+ - Fix the error `undefined method 'after' for main:Object (NoMethodError)` when starting the rails application with capistrano-opscomplete required
24
+
25
+ ## [0.6.5] - 2020-11-20
26
+
27
+ ### Fixed
28
+ - Correct warning message for `opscomplete:ruby:broken_gems_warning`
29
+
1
30
  ## [0.6.4] - 2020-11-19
2
31
 
3
32
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-opscomplete (0.6.4)
4
+ capistrano-opscomplete (1.0.1)
5
5
  capistrano (>= 3.0, < 4.0.0)
6
6
  rake
7
7
 
@@ -10,28 +10,28 @@ GEM
10
10
  specs:
11
11
  airbrussh (1.4.0)
12
12
  sshkit (>= 1.6.1, != 1.7.0)
13
- ast (2.4.0)
14
- capistrano (3.11.2)
13
+ ast (2.4.2)
14
+ capistrano (3.16.0)
15
15
  airbrussh (>= 1.0.0)
16
16
  i18n
17
17
  rake (>= 10.0.0)
18
18
  sshkit (>= 1.9.0)
19
- concurrent-ruby (1.1.6)
20
- i18n (1.8.4)
19
+ concurrent-ruby (1.1.9)
20
+ i18n (1.8.10)
21
21
  concurrent-ruby (~> 1.0)
22
22
  jaro_winkler (1.5.4)
23
- makandra-rubocop (4.2.0)
23
+ makandra-rubocop (4.4.0)
24
24
  rubocop (~> 0.76.0)
25
25
  rubocop-rails (~> 2.3.2)
26
- net-scp (2.0.0)
27
- net-ssh (>= 2.6.5, < 6.0.0)
28
- net-ssh (5.2.0)
29
- parallel (1.19.1)
30
- parser (2.7.0.2)
31
- ast (~> 2.4.0)
26
+ net-scp (3.0.0)
27
+ net-ssh (>= 2.6.5, < 7.0.0)
28
+ net-ssh (6.1.0)
29
+ parallel (1.20.1)
30
+ parser (3.0.1.1)
31
+ ast (~> 2.4.1)
32
32
  rack (2.2.3)
33
33
  rainbow (3.0.0)
34
- rake (13.0.1)
34
+ rake (13.0.3)
35
35
  rubocop (0.76.0)
36
36
  jaro_winkler (~> 1.5.1)
37
37
  parallel (~> 1.10)
@@ -42,11 +42,11 @@ GEM
42
42
  rubocop-rails (2.3.2)
43
43
  rack (>= 1.1)
44
44
  rubocop (>= 0.72.0)
45
- ruby-progressbar (1.10.1)
46
- sshkit (1.20.0)
45
+ ruby-progressbar (1.11.0)
46
+ sshkit (1.21.2)
47
47
  net-scp (>= 1.1.2)
48
48
  net-ssh (>= 2.8.0)
49
- unicode-display_width (1.6.0)
49
+ unicode-display_width (1.6.1)
50
50
 
51
51
  PLATFORMS
52
52
  ruby
data/README.md CHANGED
@@ -111,11 +111,11 @@ More specifically this task will:
111
111
  1) The value of `:opscomplete_ruby_version` from your capistrano config. Leave this empty unless you want to override the desired version.
112
112
  2) A file in the `release_path` on the server (e.g. `/var/www/staging.myapp.biz/releases/20180523234205/.ruby-version`)
113
113
  3) A file in the current working directory of your local checkout (e.g. `/home/user/code/myapp/.ruby-version`)
114
- - If the desired version is not installed, it checks if it can be installed using `ruby-build` and installs it.
115
- - Check if `rbenv global` version is set according to application's `.ruby-version` file. Change it if required.
114
+ - If the desired version is not installed, it checks if it can be installed and installs it.
115
+ - Check if the global version is set according to application's `.ruby-version` file. Change it if required.
116
116
  - Install `bundler`. It is tried to determine the version that was used to create the `Gemfile.lock` (`BUNDLED WITH`) if it is present.
117
117
  - Install `geordi` gem if required.
118
- - Run `rbenv rehash` if required.
118
+ - Rehash the shims if required.
119
119
 
120
120
  **Note:** If, for any reason, no `.ruby-version` file can be found in your release or current working directory, you may set the following option in `deploy.rb`:
121
121
 
File without changes
@@ -3,19 +3,7 @@ module Capistrano
3
3
  # A whole capistrano/rake namespace, for grouping our helpers and tasks
4
4
  module Opscomplete
5
5
  def managed_ruby?
6
- test("[ -f #{rbenv_root_path}/.ruby_managed_by_makandra ]")
7
- end
8
-
9
- def rbenv_ruby_build_path
10
- "#{rbenv_root_path}/plugins/ruby-build"
11
- end
12
-
13
- def rbenv_repo_url
14
- 'https://github.com/rbenv/rbenv.git'
15
- end
16
-
17
- def ruby_build_repo_url
18
- 'https://github.com/rbenv/ruby-build.git'
6
+ test(:ruby_update_management_tool, 'managed')
19
7
  end
20
8
 
21
9
  def app_ruby_version
@@ -64,57 +52,40 @@ module Capistrano
64
52
  end
65
53
  end
66
54
 
67
- def rbenv_installable_rubies
68
- rbenv_installable_rubies = capture(:rbenv, :install, '--list-all').split("\n")
69
- rbenv_installable_rubies.map!(&:strip)
70
- rbenv_installable_rubies.delete('Available version:')
71
- rbenv_installable_rubies
55
+ def ruby_installable_versions
56
+ ruby_installable_versions = capture(:ruby_installable_versions).split("\n")
57
+ ruby_installable_versions.map!(&:strip)
58
+ ruby_installable_versions
72
59
  end
73
60
 
74
- def rbenv_root_path
75
- capture(:rbenv, :root)
76
- end
77
-
78
- def rbenv_installed_rubies
79
- if test("[ -d #{rbenv_root_path}/versions ]")
80
- rbenv_installed_rubies = capture(:ls, '-1', "#{rbenv_root_path}/versions").split("\n")
81
- rbenv_installed_rubies.map!(&:strip)
82
- else
83
- warn("Could not look up installed versions from missing '.rbenv/versions' directory. This is probably the first ruby install for this rbenv.")
84
- []
85
- end
86
- end
87
-
88
- def rbenv_exec(*args)
89
- execute(:rbenv, :exec, *args)
61
+ def ruby_installed_versions
62
+ ruby_installed_versions = capture(:ruby_installed_versions).split("\n")
63
+ ruby_installed_versions.map!(&:strip)
64
+ warn('Could not look up installed versions. This is probably the first ruby install.') if ruby_installed_versions.empty?
65
+ ruby_installed_versions
90
66
  end
91
67
 
92
68
  def gem_installed?(name, version = nil)
93
69
  if version
94
- test(:rbenv, :exec, "gem query --quiet --installed --version '#{version}' --name-matches '^#{name}$'")
70
+ test(:ruby_installed_gem, name, '--version', "'#{version}'")
95
71
  else
96
- test(:rbenv, :exec, :gem, :query, "--quiet --installed --name-matches ^#{name}$")
72
+ test(:ruby_installed_gem, name)
97
73
  end
98
74
  end
99
75
 
100
76
  def gem_install(name, version = nil, force = false)
101
77
  if version
102
- rbenv_exec('gem install', name, '--no-document', '--version', "'#{version}'", force ? '--force' : '')
78
+ execute(:ruby_install_gem, name, '--version', "'#{version}'", force ? '--force' : '')
103
79
  else
104
- rbenv_exec('gem install', name, '--no-document')
80
+ execute(:ruby_install_gem, name)
105
81
  end
106
82
  end
107
83
 
108
- def rubygems_install(version)
109
- rbenv_exec("gem update --no-document --system '#{version}'")
110
- end
111
-
112
84
  def managed_nodejs?
113
- test("[ -f ${HOME}/.nodejs_managed_by_makandra ]")
85
+ test('[ -f ${HOME}/.nodejs_managed_by_makandra ]')
114
86
  end
115
87
 
116
88
  def app_nodejs_version
117
-
118
89
  # 1) Get version from capistrano configuration (highest precedence, 'override')
119
90
  if fetch(:opscomplete_nodejs_version)
120
91
  debug("Using version from :opscomplete_nodejs_version setting: #{fetch(:opscomplete_nodejs_version)}.")
@@ -140,6 +111,10 @@ module Capistrano
140
111
  nodejs_installed_versions = capture(:nodejs_installed_versions).split("\n")
141
112
  nodejs_installed_versions.map!(&:strip)
142
113
  end
114
+
115
+ def validation_error!(message)
116
+ raise Capistrano::ValidationError, message unless dry_run?
117
+ end
143
118
  end
144
119
  end
145
120
  end
@@ -6,4 +6,4 @@ require 'rake'
6
6
  load File.expand_path('opscomplete/ruby.rake', __dir__)
7
7
  load File.expand_path('opscomplete/nodejs.rake', __dir__)
8
8
  load File.expand_path('opscomplete/supervisor.rake', __dir__)
9
- load File.expand_path('../opscomplete/hooks.rb', __FILE__)
9
+ load File.expand_path('opscomplete/hooks.rb', __dir__)
@@ -13,9 +13,8 @@ namespace :opscomplete do
13
13
  task :check do
14
14
  on roles fetch(:nodejs_roles, :all) do |host|
15
15
  warn("#{host}: Managed Node.js environment! Won't do any changes to nodejs version.") if managed_nodejs?
16
- unless capture(:nodejs_current_version) == app_nodejs_version
17
- raise Capistrano::ValidationError,
18
- "#{host}: Node.js version is not set according to application\'s .node-version or .nvmrc file. Use cap opscomplete:nodejs:ensure."
16
+ unless capture(:nodejs_get_version, release_path) == app_nodejs_version
17
+ validation_error!("#{host}: Node.js version is not set according to application\'s .node-version or .nvmrc file. Use cap opscomplete:nodejs:ensure.")
19
18
  end
20
19
  info("#{host}: Node.js #{app_nodejs_version} is installed.")
21
20
  end
@@ -33,7 +32,7 @@ namespace :opscomplete do
33
32
  invoke('opscomplete:nodejs:update_nodejs_build')
34
33
  on roles fetch(:nodejs_roles, :all) do |host|
35
34
  if managed_nodejs?
36
- raise Capistrano::ValidationError, "#{host}: Managed Node.js environment! Won't do any changes to Node.js version."
35
+ validation_error!("#{host}: Managed Node.js environment! Won't do any changes to Node.js version.")
37
36
  end
38
37
  if nodejs_installed_versions.include?(app_nodejs_version)
39
38
  info("#{host}: Node.js #{app_nodejs_version} is installed.")
@@ -43,8 +42,9 @@ namespace :opscomplete do
43
42
  execute(:nodejs_install_version, "'#{app_nodejs_version}'")
44
43
  end
45
44
  else
46
- raise Capistrano::ValidationError,
47
- "#{host}: Configured Node.js version is neither installed nor installable."
45
+ info("#{host}: Check if the configured Node.js version is part of the installable versions")
46
+ execute :nodejs_installable_versions
47
+ validation_error!("#{host}: Configured Node.js version is neither installed nor installable.")
48
48
  end
49
49
  execute(:nodejs_set_version, "'#{app_nodejs_version}'")
50
50
  end
@@ -9,80 +9,69 @@ namespace :opscomplete do
9
9
  end
10
10
 
11
11
  namespace :ruby do
12
- # desc 'Rehash rbenv shims (run this after installing executables).'
13
- task :rehash do
14
- on roles fetch(:rbenv_roles, :all) do
15
- execute(:rbenv, :rehash)
16
- end
17
- end
18
-
19
- desc 'Check if rbenv global Ruby version is set according to application\'s .ruby-version.'
12
+ desc 'Check if Ruby version is set according to application\'s .ruby-version.'
20
13
  task :check do
21
14
  on roles fetch(:rbenv_roles, :all) do |host|
22
15
  warn("#{host}: Managed Ruby environment! Won't do any changes to ruby version.") if managed_ruby?
23
- unless capture(:rbenv, :global) == app_ruby_version
24
- raise Capistrano::ValidationError,
25
- "#{host}: Ruby version is not set according to application\'s .ruby-version file. Use cap opscomplete:ruby:ensure."
16
+ unless capture(:ruby_get_current_version) == app_ruby_version
17
+ validation_error!("#{host}: Ruby version is not set according to application\'s .ruby-version file. Use cap opscomplete:ruby:ensure.")
26
18
  end
27
19
  info("#{host}: Ruby #{app_ruby_version} is installed.")
28
20
  end
29
21
  end
30
22
 
31
- # desc 'Install rbenv plugin ruby-build'
23
+ desc 'Install Ruby version management tool dependencies'
32
24
  task :install_ruby_build do
33
25
  on roles fetch(:rbenv_roles, :all) do
34
- next if test "[ -d #{rbenv_ruby_build_path} ]"
35
- execute :git, :clone, ruby_build_repo_url, rbenv_ruby_build_path
26
+ execute(:ruby_update_management_tool, :install_build)
36
27
  end
37
28
  end
38
29
 
39
- # desc 'Update rbenv plugin ruby-build'
30
+ desc 'Update Ruby version management tool'
40
31
  task :update_ruby_build do
41
32
  on roles fetch(:rbenv_roles, :all) do
42
- if test "[ -d #{rbenv_ruby_build_path} ]"
43
- within rbenv_ruby_build_path do
44
- execute :git, :pull, '-q'
45
- end
46
- else
47
- warn('Could not find ruby-build.')
48
- end
33
+ execute(:ruby_update_management_tool, :update_build)
49
34
  end
50
35
  end
51
36
 
52
- # desc 'Install bundler gem'
37
+ desc 'Rehash shims (run this after installing executables).'
38
+ task :rehash do
39
+ on roles fetch(:rbenv_roles, :all) do
40
+ execute(:ruby_update_management_tool, :rehash)
41
+ end
42
+ end
43
+
44
+ desc 'Install bundler gem'
53
45
  task :install_bundler do
54
46
  on roles fetch(:rbenv_roles, :all) do
55
47
  # manually specified version will take precedence
56
48
  specific_bundler_version = fetch(:bundler_version, app_gemfile_bundled_with_version)
57
-
58
49
  if specific_bundler_version
59
50
  # We have to set force = true to overwrite the binary
60
51
  gem_install('bundler', specific_bundler_version, true) unless gem_installed?('bundler', specific_bundler_version)
61
52
  else
62
53
  gem_install('bundler') unless gem_installed?('bundler')
63
54
  end
64
- set :rbenv_needs_rehash, true
65
55
  end
66
56
  end
67
57
 
68
- # desc 'Install geordi gem'
58
+ desc 'Install geordi gem'
69
59
  task :install_geordi do
70
60
  on roles fetch(:rbenv_roles, :all) do
71
61
  gem_install('geordi') unless gem_installed?('geordi')
72
- set :rbenv_needs_rehash, true
73
62
  end
74
63
  end
75
64
 
65
+ desc 'Install RubyGems'
76
66
  task :install_rubygems do
77
67
  on roles fetch(:rbenv_roles, :all) do
78
- # if no rubygems_version was set, we use and don't check the rubygems version installed by rbenv
68
+ # if no rubygems_version was set, we use and don't check the installed rubygems version
79
69
  if fetch(:rubygems_version, false)
80
- current_rubygems_version = capture(:rbenv, :exec, :gem, '--version').chomp
70
+ current_rubygems_version = capture(:ruby_get_current_version, :rubygems).chomp
81
71
  info("Ensuring requested RubyGems version #{fetch(:rubygems_version)}")
82
72
  next if current_rubygems_version == fetch(:rubygems_version)
83
73
  info("Previously installed RubyGems version was #{current_rubygems_version}")
84
- rbenv_exec(:gem, :update, '--no-document', '--system', "'#{fetch(:rubygems_version)}'")
85
- set :rbenv_needs_rehash, true
74
+ execute(:ruby_install_version, :rubygems, "'#{fetch(:rubygems_version)}'")
86
75
  end
87
76
  end
88
77
  end
@@ -92,29 +81,27 @@ namespace :opscomplete do
92
81
  invoke('opscomplete:ruby:update_ruby_build')
93
82
  on roles fetch(:rbenv_roles, :all) do |host|
94
83
  if managed_ruby?
95
- raise Capistrano::ValidationError, "#{host}: Managed Ruby environment! Won't do any changes to Ruby version."
84
+ validation_error!("#{host}: Managed Ruby environment! Won't do any changes to Ruby version.")
96
85
  end
97
- if rbenv_installed_rubies.include?(app_ruby_version)
86
+ if ruby_installed_versions.include?(app_ruby_version)
98
87
  info("#{host}: Ruby #{app_ruby_version} is installed.")
99
- elsif rbenv_installable_rubies.include?(app_ruby_version)
88
+ elsif ruby_installable_versions.include?(app_ruby_version)
100
89
  info("#{host}: Configured Ruby version is not installed, but available for installation.")
101
90
  with tmpdir: fetch(:tmp_dir) do
102
- execute(:rbenv, :install, "'#{app_ruby_version}'")
91
+ execute(:ruby_install_version, "'#{app_ruby_version}'")
103
92
  end
104
- set :rbenv_needs_rehash, true
105
93
  else
106
- raise Capistrano::ValidationError,
107
- "#{host}: Configured Ruby version is neither installed nor installable using ruby-install."
94
+ validation_error!("#{host}: Configured Ruby version is neither installed nor installable.")
108
95
  end
109
- unless capture(:rbenv, :global) == app_ruby_version
96
+ unless capture(:ruby_get_current_version) == app_ruby_version
110
97
  set :ruby_modified, true
111
- execute(:rbenv, :global, "'#{app_ruby_version}'")
98
+ execute(:ruby_set_version, "'#{app_ruby_version}'")
112
99
  end
113
100
  end
114
101
  invoke('opscomplete:ruby:install_rubygems')
115
102
  invoke('opscomplete:ruby:install_bundler')
116
103
  invoke('opscomplete:ruby:install_geordi')
117
- invoke('opscomplete:ruby:rehash') if fetch(:rbenv_needs_rehash, false)
104
+ invoke('opscomplete:ruby:rehash')
118
105
  end
119
106
 
120
107
  desc 'resets the global ruby version and gems to Gemfile and .ruby-version in current_path.'
@@ -125,16 +112,14 @@ namespace :opscomplete do
125
112
  if test("[ -f #{current_ruby_version_file_path} ]")
126
113
  execute(:rbenv, :global, capture(:cat, current_ruby_version_file_path))
127
114
  else
128
- raise Capistrano::ValidationError,
129
- "#{host}: Missing .ruby-version in #{current_path}. Won't set a new global version."
115
+ validation_error!("#{host}: Missing .ruby-version in #{current_path}. Won't set a new global version.")
130
116
  end
131
117
  if test("[ -f '#{current_path}/.bundle/config' ]")
132
118
  debug("#{host}: Found #{current_path}/.bundle/config, running bundle pristine.")
133
119
  set :bundle_gemfile, -> { current_path.join('Gemfile') }
134
120
  execute(:bundle, :pristine)
135
121
  else
136
- raise Capistrano::ValidationError,
137
- "Unable to find #{current_path}/.bundle/config, won't run bundle pristine."
122
+ validation_error!("Unable to find #{current_path}/.bundle/config, won't run bundle pristine.")
138
123
  end
139
124
  end
140
125
  end
@@ -144,10 +129,10 @@ namespace :opscomplete do
144
129
  task :broken_gems_warning do
145
130
  on roles fetch(:rbenv_roles, :all) do |host|
146
131
  if fetch(:ruby_modified, false)
147
- warn("Deploy failed and the ruby version has been modified in this deploy.")
148
- warn("If this was a minor ruby version upgrade your running application may run into issues with native gem extensions.")
149
- warn("If your deploy failed deploy:symlink:release you may run bundle exec `cap #{fetch(:stage)} opscomplete:ruby:reset`.")
150
- warn("Please refer https://makandracards.com/makandra/477884-bundler-in-deploy-mode-shares-gems-between-patch-level-ruby-versions")
132
+ warn('Deploy failed and the ruby version has been modified in this deploy.')
133
+ warn('If this was a minor ruby version upgrade your running application may run into issues with native gem extensions.')
134
+ warn("If your deploy failed before deploy:symlink:release you may run bundle exec 'cap #{fetch(:stage)} opscomplete:ruby:reset'.")
135
+ warn('Please refer https://makandracards.com/makandra/477884-bundler-in-deploy-mode-shares-gems-between-patch-level-ruby-versions')
151
136
  else
152
137
  debug("#{host}: Ruby not modified in current deploy.")
153
138
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Opscomplete
3
- VERSION = '0.6.4'.freeze
3
+ VERSION = '1.0.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-opscomplete
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makandra Operations
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-19 00:00:00.000000000 Z
11
+ date: 2021-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: makandra-rubocop
@@ -89,6 +89,7 @@ files:
89
89
  - bin/console
90
90
  - bin/setup
91
91
  - capistrano-opscomplete.gemspec
92
+ - lib/capistrano-opscomplete.rb
92
93
  - lib/capistrano/dsl/opscomplete.rb
93
94
  - lib/capistrano/opscomplete.rb
94
95
  - lib/capistrano/opscomplete/hooks.rb