capistrano-sozo_magento2 1.3.1 → 1.4.0

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: 1b1790fdeb92ff66403be9ccd3f3977ad51383a401deeb09d073e927f1dff17f
4
- data.tar.gz: 38e34911ea738869e55fe0d0fe5b5e6baad4207a7af91fbbbcae8a615f1b6208
3
+ metadata.gz: ab55bf423e1766857aeff0a542b1b2657e35a6401d7dda6469404df07060d90c
4
+ data.tar.gz: 43a54ea1407c899c1f9545c6cb6703977ac70690053f6efdd61d18024eb933dd
5
5
  SHA512:
6
- metadata.gz: 81a868673b25d2ee710b90dba9be7b478b48dbe80b5c238dcdbe493e6255d6647202b619b6bb0c9d71c2c34632d7757450252193e1f218e571dba14dd3dd9e00
7
- data.tar.gz: 3125ca35d6f5e0b0ef62cf3283fdf9f97935e5ff3a56268ac8c52c231ff7c36459084f9d72a174a5b60b073a9dd9fe557250e4d81bcede40f30852d38e688547
6
+ metadata.gz: 0d068c92ebcd093a49b7ca63685a0d27e898aa3884d5ecd9a5ea9b7c339eae83c700eccaab3b5ac959b2c12d20cfae7d7526376365045996e8d88e5a38802dff
7
+ data.tar.gz: 42b84543c461b955f32cff824750a12b06ed8de464c5b6227915440b28f732a3d22355a0066bd38c45f425b16c58ecaa11e4d7ea6f40cbd7d078f15a5d5e39dd
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ --protected
2
+ --no-private
3
+ -
4
+ CHANGELOG.md
5
+ LICENSE
data/CHANGELOG.md CHANGED
@@ -22,6 +22,20 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
22
22
  ## [Unreleased]
23
23
 
24
24
 
25
+ ## [v1.4.0] - 2021-08-03
26
+ ### Added
27
+ - New `deploy:check` info output with key information displayed.
28
+ - Magento Cron control now included in the deployment methods with `:handle_cron` option (default false).
29
+ - New check `sozo:git:check` to see if the branch exists in the repository before deployment begins.
30
+ - Documented code with Yardoc
31
+
32
+ ### Changed
33
+ - Delay added (3 seconds) before trying to delete a failed deployment to allow file or disk activity to finish.
34
+ - Added sudo to failed deployments release deleting.
35
+ - Changed maintenance mode path to use the `deploy_root` location from `current_path`
36
+ - Checked all boolean values against string "true" or "false" using .to_s == 'true'
37
+
38
+
25
39
  ## [v1.3.1] - 2021-07-29
26
40
  ### Changed
27
41
  - Changed ENV options for WordPress plugins and themes removal.
@@ -17,12 +17,16 @@ load File.expand_path('../tasks/provision.rake', __FILE__)
17
17
  load File.expand_path('../tasks/server.rake', __FILE__)
18
18
  load File.expand_path('../tasks/wordpress.rake', __FILE__)
19
19
 
20
+ after 'deploy:check', 'sozo:git:check'
21
+ after 'deploy:check', 'sozo:info'
22
+
20
23
  after 'deploy:updating', 'composer:install'
21
24
  after 'deploy:updating', 'magento:patches:apply'
22
25
  after 'deploy:updating', 'magento:setup:permissions'
23
26
 
24
27
  before 'deploy:updated', 'slack:deploying'
25
28
  before 'deploy:updated', 'db:backup'
29
+ before 'deploy:updated', 'magento:cron:remove'
26
30
  before 'deploy:updated', 'sozo:config:setup'
27
31
  before 'deploy:updated', 'magento:maintenance:enable'
28
32
 
@@ -39,12 +43,15 @@ after 'deploy:finishing', 'wordpress:cleanup'
39
43
  after 'deploy:finishing', 'sozo:optimise'
40
44
  after 'deploy:finishing', 'server:service:restart'
41
45
  after 'deploy:finishing', 'magento:maintenance:disable'
46
+ after 'deploy:finishing', 'magento:cron:install'
42
47
 
43
48
  after 'deploy:finished', "slack:deployed"
44
49
  after 'deploy:finished', "db:cleanup"
45
50
 
46
51
  after 'deploy:failed', "sozo:fix_current"
47
52
  after 'deploy:failed', "slack:failed"
53
+ after 'deploy:failed', 'magento:cron:remove'
54
+ after 'deploy:failed', 'magento:cron:install'
48
55
  after 'deploy:failed', 'magento:maintenance:disable'
49
56
 
50
57
  namespace :load do
@@ -42,6 +42,9 @@ set :slack_webhook, 'https://hooks.slack.com/services/T06K8GR2L/
42
42
  # Deployment defaults
43
43
  set :magento_deploy_confirm_roles, fetch(:magento_deploy_confirm_roles, [])
44
44
 
45
+ # Handle removing and installing of cron tasks?
46
+ set :handle_cron, fetch(:handle_cron, false)
47
+
45
48
  # Other defaults (for future use)
46
49
  # Clear or leave the failed deployment dirs
47
50
  set :clear_failures, fetch(:clear_failures, true)
@@ -0,0 +1,64 @@
1
+ require "capistrano/doctor/output_helpers"
2
+
3
+ include Capistrano::DSL
4
+
5
+ # @author Clive Walkden
6
+ module SozoMagento2
7
+ # Class to out key information at the end of the deploy:check command
8
+ module Info
9
+ # Class to out key information at the end of the deploy:check command
10
+ class Info
11
+ WHITELIST = %i(
12
+ branch
13
+ environment
14
+ handle_cron
15
+ slack_channel
16
+ url
17
+ ).freeze
18
+ private_constant :WHITELIST
19
+
20
+ include Capistrano::Doctor::OutputHelpers
21
+
22
+ # Initialize the class with access to env data
23
+ def initialize(env=Capistrano::Configuration.env)
24
+ @env = env
25
+ end
26
+
27
+ # Output the key information in the CLI
28
+ def call
29
+ title("Deployment Info")
30
+
31
+ values = inspect_all_values
32
+
33
+ table(values.keys.sort_by(&:to_s)) do |key, row|
34
+ row.yellow if values[key] == "\"production\""
35
+ row << key.inspect
36
+ row << ''
37
+ row << values[key]
38
+ end
39
+
40
+ puts("")
41
+ warning("Make sure you check these values before deploying!")
42
+ puts("")
43
+ end
44
+
45
+ private
46
+
47
+ attr_reader :env
48
+
49
+ # Read all variables in
50
+ def variables
51
+ env.variables
52
+ end
53
+
54
+ # Only include variables in the whitelist
55
+ def inspect_all_values
56
+ variables.keys.each_with_object({}) do |key, inspected|
57
+ if WHITELIST.include?(key)
58
+ inspected[key] = variables.peek(key).inspect
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -2,8 +2,12 @@ require 'json'
2
2
 
3
3
  include Capistrano::DSL
4
4
 
5
+ # @author Clive Walkden
5
6
  module SozoMagento2
7
+ # Slack message template
6
8
  module Slack
9
+ # Slack message template
10
+ # @return [String] the template hash
7
11
  def message_hash
8
12
  {
9
13
  "channel" => fetch(:slack_channel),
@@ -1,5 +1,9 @@
1
+ # @author Clive Walkden
1
2
  module Capistrano
3
+ # The plugin version number
2
4
  module SozoMagento2
3
- VERSION = "1.3.1"
5
+ # The plugin version number
6
+ # @return [String] The gem version number
7
+ VERSION = "1.4.0"
4
8
  end
5
9
  end
@@ -1,3 +1,4 @@
1
+ # Composer namespace
1
2
  namespace :composer do
2
3
  desc "Install the Composer dependencies"
3
4
  task :install do
@@ -28,7 +28,7 @@ namespace :db do
28
28
  task :wp_db_backup do
29
29
  # Backup the database with a timestamp
30
30
  on roles :all do
31
- if (fetch(:wp_backup) == "true")
31
+ if (fetch(:wp_backup).to_s == "true")
32
32
  info "Backing up WordPress database."
33
33
  execute :n98magerun, 'db:dump', "--root-dir='#{fetch(:mage_root)}'",
34
34
  '--compression="gzip"',
@@ -41,7 +41,12 @@ namespace :deploy do
41
41
  task :failed do
42
42
  on release_roles :all do |host|
43
43
  on roles :production, :staging, :testing do
44
- execute :rm, '-rf', release_path
44
+ # Hold for a few seconds to make sure all disk related actions have completed
45
+ info "Waiting for file / disk writing to complete"
46
+ sleep(3)
47
+ # Added sudo to make sure we can clear everything
48
+ info "Removing failed deployment"
49
+ execute :sudo, 'rm', '-rf', release_path
45
50
  info "Removed failed deployment"
46
51
  end
47
52
  end
@@ -1,5 +1,31 @@
1
1
  namespace :magento do
2
2
 
3
+ namespace :cron do
4
+ desc 'Remove cron'
5
+ task :remove do
6
+ on release_roles :all do
7
+ info "Disabling cron"
8
+ if (fetch(:handle_cron).to_s == "true")
9
+ execute :php, '-f', "#{fetch(:deploy_root)}/magento2/bin/magento", 'cron:remove'
10
+ else
11
+ info "Cron not controlled by capistrano"
12
+ end
13
+ end
14
+ end
15
+
16
+ desc 'Install cron'
17
+ task :install do
18
+ on release_roles :all do
19
+ info "Enabling cron"
20
+ if (fetch(:handle_cron).to_s == "true")
21
+ execute :php, '-f', "#{fetch(:deploy_root)}/magento2/bin/magento", 'cron:install', '-d'
22
+ else
23
+ info "Cron not controlled by capistrano"
24
+ end
25
+ end
26
+ end
27
+ end
28
+
3
29
  namespace :cache do
4
30
  desc 'Flush Magento cache storage'
5
31
  task :flush do
@@ -195,22 +221,14 @@ namespace :magento do
195
221
  desc 'Enable maintenance mode'
196
222
  task :enable do
197
223
  on release_roles :all do
198
- within current_path do
199
- if File.exist?("magento/bin/magento")
200
- execute :php, '-f', 'magento/bin/magento', 'maintenance:enable'
201
- end
202
- end
224
+ execute :php, '-f', "#{fetch(:deploy_root)}/magento2/bin/magento", 'maintenance:enable'
203
225
  end
204
226
  end
205
227
 
206
228
  desc 'Disable maintenance mode'
207
229
  task :disable do
208
230
  on release_roles :all do
209
- within current_path do
210
- if File.exist?("magento/bin/magento")
211
- execute :php, '-f', 'magento/bin/magento', 'maintenance:disable'
212
- end
213
- end
231
+ execute :php, '-f', "#{fetch(:deploy_root)}/magento2/bin/magento", 'maintenance:disable'
214
232
  end
215
233
  end
216
234
 
@@ -1,5 +1,32 @@
1
+ require 'capistrano/sozo_magento2/info'
2
+
3
+ include SozoMagento2::Info
4
+
1
5
  namespace :sozo do
2
6
 
7
+ desc "Info"
8
+ task :info do
9
+ on roles(:all) do
10
+ SozoMagento2::Info::Info.new.call
11
+ end
12
+ end
13
+
14
+ namespace :git do
15
+ desc "Git branch Check"
16
+ task :check do
17
+ on roles(:all) do
18
+ check = capture(:git, 'ls-remote', '--heads', fetch(:repo_url), fetch(:branch), '|', 'wc', '-l')
19
+
20
+ if check.to_i == 1
21
+ info "Branch is available for deployment."
22
+ else
23
+ error "Branch does not exist in git repository, have you pushed your changes?"
24
+ exit 1
25
+ end
26
+ end
27
+ end
28
+ end
29
+
3
30
  desc "Fix current directory if needed"
4
31
  task :fix_current do
5
32
  on roles(:all) do
@@ -64,7 +91,6 @@ namespace :sozo do
64
91
  end
65
92
  on roles :production do
66
93
  within release_path do
67
- invoke 'magento:cache:enable'
68
94
  invoke 'magento:cache:flush'
69
95
  invoke 'magento:indexer:reindex'
70
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-sozo_magento2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clive Walkden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-30 00:00:00.000000000 Z
11
+ date: 2021-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -32,6 +32,7 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - ".gitignore"
35
+ - ".yardopts"
35
36
  - BUILD.md
36
37
  - CHANGELOG.md
37
38
  - Gemfile
@@ -40,6 +41,7 @@ files:
40
41
  - capistrano-sozo_magento.gemspec
41
42
  - lib/capistrano/sozo_magento2.rb
42
43
  - lib/capistrano/sozo_magento2/defaults.rb
44
+ - lib/capistrano/sozo_magento2/info.rb
43
45
  - lib/capistrano/sozo_magento2/slack.rb
44
46
  - lib/capistrano/sozo_magento2/version.rb
45
47
  - lib/capistrano/tasks/composer.rake