capistrano-magento2 0.8.7 → 0.8.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0873b9252da2bdba39fcc7f9b3360582696ec9d159ac1e28f3c74ee1823b4f86'
4
- data.tar.gz: 6f3508a50bb1bcc01e7e7c139335da4912241b6779d7ce56f71aa36a7a8ab743
3
+ metadata.gz: f1ecc432d10021f836a35005807a6dc5127499d561a2081bd31168c2d1fc76a3
4
+ data.tar.gz: ba295633cb33ae700bb1b9ddf5c99d418469079b91ef2c87173c5425e72bd20f
5
5
  SHA512:
6
- metadata.gz: a30733e4c4f5e48dfe03d6e064042e58a5451ef10963c04cf6e6cdead4839e23acfc98d1f38c203241dfb477a92283953141b03b500fc2583b6e28ccd11d20ea
7
- data.tar.gz: ef98b2145f7526a1aac1b8217941bdf230e24e93ddc37a8331b4a054242acf0d5275d6bbccc6660799127e7d867cbc59e13bec42f611cde13f27d74993faab32
6
+ metadata.gz: 45e6e75fc726d56da63cbb53c46c17852e37472e5d6d34c53b8652417d4d3c35dac4fd6cb7ce5c5556f2cda7907b890415497cd6b57f0a5b9efa94cff02c9879
7
+ data.tar.gz: 6db56c44607d0e4258fcb5dd84a3ee0e2d148dd010765b64fca5db056f3a89610f27ce1e1d507499eeeb6d931ef13457dfd6b152b93b8b2d68e9da712f56c37b
data/.travis.yml CHANGED
@@ -1,3 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- 2.2
3
+ 2.4
4
+
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Capistrano::Magento2 Change Log
2
2
 
3
+ 0.8.8
4
+ ==========
5
+
6
+ * Added support for zero-side-effect pipeline deployments when scopes/themes have been dumped to config.php
7
+
3
8
  0.8.7
4
9
  ==========
5
10
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/capistrano-magento2.svg)](https://badge.fury.io/rb/capistrano-magento2)
4
4
 
5
- A Capistrano extension for Magento 2 deployments. Takes care of specific Magento 2 requirements and adds tasks specific to the Magento 2 application.
5
+ A Capistrano extension for Magento 2 deployments. Takes care of specific Magento 2 requirements and adds tasks specific to the Magento 2 application. Supports zero-down deployments based on differences in deployed `config.php` and db status as reported by Magento's `setup:db:status` CLI command. When themes and scopes have been dumped to `config.php` via `bin/magento app:config:dump scopes themes i18n` then zero-side-effect pipeline will be utilized such that no database nor cache backend configuration are available during the build process.
6
6
 
7
7
  ## Supported Magento Versions
8
8
 
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Capistrano
11
11
  module Magento2
12
- VERSION = '0.8.7'
12
+ VERSION = '0.8.8'
13
13
  end
14
14
  end
@@ -13,6 +13,23 @@ namespace :deploy do
13
13
  before 'deploy:check:linked_files', 'magento:deploy:check'
14
14
  before 'deploy:symlink:linked_files', 'magento:deploy:local_config'
15
15
 
16
+ # If both 'scopes' and 'themes' are available in app/etc/config.php then the build should not require database or
17
+ # cache backend configuration to deploy. Removing the link to app/etc/env.php in this case prevents any possible
18
+ # side effects that may arise from the build running in parallel to the live production release (such as the cache
19
+ # being randomly disabled during the composer install step of the build, something which has been observed). This
20
+ # requires "bin/magento scopes themes i18n" be run to dump theme/store config and the result comitted to repository
21
+ before 'deploy:symlink:linked_files', :detect_scd_config do
22
+ on primary fetch(:magento_deploy_setup_role) do
23
+ unless test %Q[#{SSHKit.config.command_map[:php]} -r '
24
+ $cfg = include "#{release_path}/app/etc/config.php";
25
+ exit((int)(isset($cfg["scopes"]) && isset($cfg["themes"])));
26
+ ']
27
+ info "Removing app/etc/env.php from :linked_dirs for zero-side-effect pipeline deployment."
28
+ remove :linked_files, 'app/etc/env.php'
29
+ end
30
+ end
31
+ end
32
+
16
33
  before :starting, :confirm_action do
17
34
  if fetch(:magento_deploy_confirm).include? fetch(:stage).to_s
18
35
  print "\e[0;31m Are you sure you want to deploy to #{fetch(:stage).to_s}? [y/n] \e[0m"
@@ -21,17 +38,33 @@ namespace :deploy do
21
38
  end
22
39
  end
23
40
 
41
+ # Links app/etc/env.php if previously dropped from :linked_dirs in :detect_scd_config
42
+ task 'symlink:link_env_php' do
43
+ on release_roles :all do
44
+ # Normally this would be wrapped in a conditional, but during SCD and/or DI compile Magento frequently writes
45
+ # to cache_types -> compiled_config resulting in an env.php file being present (albeit the wrong one)
46
+ execute :ln, "-fsn #{shared_path}/app/etc/env.php #{release_path}/app/etc/env.php"
47
+ end
48
+ end
49
+
24
50
  task :updated do
25
51
  invoke 'magento:deploy:verify'
26
52
  invoke 'magento:composer:install' if fetch(:magento_deploy_composer)
27
53
  invoke 'magento:deploy:version_check'
28
54
  invoke 'magento:setup:permissions'
55
+
29
56
  if fetch(:magento_deploy_production)
30
- invoke 'magento:deploy:mode:production'
31
57
  invoke 'magento:setup:static-content:deploy'
32
58
  invoke 'magento:setup:di:compile'
33
59
  invoke 'magento:composer:dump-autoload' if fetch(:magento_deploy_composer)
34
60
  end
61
+
62
+ invoke 'deploy:symlink:link_env_php'
63
+
64
+ if fetch(:magento_deploy_production)
65
+ invoke 'magento:deploy:mode:production'
66
+ end
67
+
35
68
  invoke 'magento:setup:permissions'
36
69
  invoke 'magento:maintenance:check'
37
70
  invoke 'magento:maintenance:enable' if fetch(:magento_deploy_maintenance)
@@ -218,8 +218,10 @@ namespace :magento do
218
218
  exit 1 # only need to check the repo once, so we immediately exit
219
219
  end
220
220
 
221
+ # Checking app/etc/env.php in shared_path vs release_path to support the zero-side-effect
222
+ # builds as implemented in the :detect_scd_config hook of deploy.rake
221
223
  unless test %Q[#{SSHKit.config.command_map[:php]} -r '
222
- $cfg = include "#{release_path}/app/etc/env.php";
224
+ $cfg = include "#{shared_path}/app/etc/env.php";
223
225
  exit((int)!isset($cfg["install"]["date"]));
224
226
  ']
225
227
  error "\e[0;31mError on #{host}:\e[0m No environment configuration could be found." +
@@ -317,11 +319,13 @@ namespace :magento do
317
319
  task :compile do
318
320
  on release_roles :all do
319
321
  within release_path do
320
- output = capture :magento, 'setup:di:compile --no-ansi', verbosity: Logger::INFO
322
+ with mage_mode: :production do
323
+ output = capture :magento, 'setup:di:compile --no-ansi', verbosity: Logger::INFO
321
324
 
322
- # 2.1.x doesn't return a non-zero exit code for certain errors (see davidalger/capistrano-magento2#41)
323
- if output.to_s.include? 'Errors during compilation'
324
- raise Exception, 'DI compilation command execution failed'
325
+ # 2.1.x doesn't return a non-zero exit code for certain errors (see davidalger/capistrano-magento2#41)
326
+ if output.to_s.include? 'Errors during compilation'
327
+ raise Exception, 'DI compilation command execution failed'
328
+ end
325
329
  end
326
330
  end
327
331
  end
@@ -332,66 +336,68 @@ namespace :magento do
332
336
  desc 'Deploys static view files'
333
337
  task :deploy do
334
338
  on release_roles :all do
335
- _magento_version = magento_version
339
+ with mage_mode: :production do
340
+ _magento_version = magento_version
336
341
 
337
- deploy_themes = fetch(:magento_deploy_themes)
338
- deploy_jobs = fetch(:magento_deploy_jobs)
339
-
340
- if deploy_themes.count() > 0
341
- deploy_themes = deploy_themes.join(' -t ').prepend(' -t ')
342
- else
343
- deploy_themes = nil
344
- end
345
-
346
- if deploy_jobs
347
- deploy_jobs = "--jobs #{deploy_jobs} "
348
- else
349
- deploy_jobs = nil
350
- end
342
+ deploy_themes = fetch(:magento_deploy_themes)
343
+ deploy_jobs = fetch(:magento_deploy_jobs)
351
344
 
352
- # Workaround core-bug with multi-lingual deployments on Magento 2.1.3 and greater. In these versions each
353
- # language must be iterated individually. See issue #72 for details.
354
- if _magento_version >= Gem::Version.new('2.1.3')
355
- deploy_languages = fetch(:magento_deploy_languages)
356
- else
357
- deploy_languages = [fetch(:magento_deploy_languages).join(' ')]
358
- end
345
+ if deploy_themes.count() > 0
346
+ deploy_themes = deploy_themes.join(' -t ').prepend(' -t ')
347
+ else
348
+ deploy_themes = nil
349
+ end
359
350
 
360
- # Magento 2.2 introduced static content compilation strategies that can be one of the following:
361
- # quick (default), standard (like previous versions) or compact
362
- compilation_strategy = fetch(:magento_deploy_strategy)
363
- if compilation_strategy and _magento_version >= Gem::Version.new('2.2.0')
364
- compilation_strategy = "-s #{compilation_strategy} "
365
- else
366
- compilation_strategy = nil
367
- end
351
+ if deploy_jobs
352
+ deploy_jobs = "--jobs #{deploy_jobs} "
353
+ else
354
+ deploy_jobs = nil
355
+ end
368
356
 
369
- within release_path do
370
- # Magento 2.1 will fail to deploy if this file does not exist and static asset signing is enabled
371
- execute :touch, "#{release_path}/pub/static/deployed_version.txt"
357
+ # Workaround core-bug with multi-lingual deployments on Magento 2.1.3 and greater. In these versions each
358
+ # language must be iterated individually. See issue #72 for details.
359
+ if _magento_version >= Gem::Version.new('2.1.3')
360
+ deploy_languages = fetch(:magento_deploy_languages)
361
+ else
362
+ deploy_languages = [fetch(:magento_deploy_languages).join(' ')]
363
+ end
372
364
 
373
- # This loop exists to support deploy on versions where each language must be deployed seperately
374
- deploy_languages.each do |lang|
375
- static_content_deploy "#{compilation_strategy}#{deploy_jobs}#{lang}#{deploy_themes}"
365
+ # Magento 2.2 introduced static content compilation strategies that can be one of the following:
366
+ # quick (default), standard (like previous versions) or compact
367
+ compilation_strategy = fetch(:magento_deploy_strategy)
368
+ if compilation_strategy and _magento_version >= Gem::Version.new('2.2.0')
369
+ compilation_strategy = "-s #{compilation_strategy} "
370
+ else
371
+ compilation_strategy = nil
376
372
  end
377
- end
378
373
 
379
- # Run again with HTTPS env var set to 'on' to pre-generate secure versions of RequireJS configs. A
380
- # single run on these Magento versions will fail to generate the secure requirejs-config.js file.
381
- if _magento_version < Gem::Version.new('2.1.8')
382
- deploy_flags = ['css', 'less', 'images', 'fonts', 'html', 'misc', 'html-minify']
383
- .join(' --no-').prepend(' --no-');
374
+ within release_path do
375
+ # Magento 2.1 will fail to deploy if this file does not exist and static asset signing is enabled
376
+ execute :touch, "#{release_path}/pub/static/deployed_version.txt"
384
377
 
385
- within release_path do with(https: 'on') {
386
378
  # This loop exists to support deploy on versions where each language must be deployed seperately
387
379
  deploy_languages.each do |lang|
388
- static_content_deploy "#{compilation_strategy}#{deploy_jobs}#{lang}#{deploy_themes}#{deploy_flags}"
380
+ static_content_deploy "#{compilation_strategy}#{deploy_jobs}#{lang}#{deploy_themes}"
389
381
  end
390
- } end
391
- end
382
+ end
392
383
 
393
- # Set the deployed_version of static content to ensure it matches across all hosts
394
- upload!(StringIO.new(deployed_version), "#{release_path}/pub/static/deployed_version.txt")
384
+ # Run again with HTTPS env var set to 'on' to pre-generate secure versions of RequireJS configs. A
385
+ # single run on these Magento versions will fail to generate the secure requirejs-config.js file.
386
+ if _magento_version < Gem::Version.new('2.1.8')
387
+ deploy_flags = ['css', 'less', 'images', 'fonts', 'html', 'misc', 'html-minify']
388
+ .join(' --no-').prepend(' --no-');
389
+
390
+ within release_path do with(https: 'on') {
391
+ # This loop exists to support deploy on versions where each language must be deployed seperately
392
+ deploy_languages.each do |lang|
393
+ static_content_deploy "#{compilation_strategy}#{deploy_jobs}#{lang}#{deploy_themes}#{deploy_flags}"
394
+ end
395
+ } end
396
+ end
397
+
398
+ # Set the deployed_version of static content to ensure it matches across all hosts
399
+ upload!(StringIO.new(deployed_version), "#{release_path}/pub/static/deployed_version.txt")
400
+ end
395
401
  end
396
402
  end
397
403
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-magento2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.7
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Alger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-01 00:00:00.000000000 Z
11
+ date: 2019-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.0.2
103
+ rubygems_version: 3.0.3
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: A Capistrano extension for Magento 2 deployments.