Skip to content

Commit

Permalink
Moved core module dependencies into post-provision script.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Aug 16, 2024
1 parent b475fa2 commit e51ef37
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 72 deletions.
42 changes: 35 additions & 7 deletions .scaffold/tests/bats/provision.bats
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ assert_provision_info() {
# Custom post-install script.
"Running custom post-install script './scripts/custom/provision-10-example.sh'."
"@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();"
"@drush -y pm:install ys_core"
"@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy"
"@drush -y pm:install redis"
"@drush -y pm:install clamav"
"@drush -y pm:install search_api search_api_solr"
"@drush -y pm:install ys_core ys_search"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
# Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script.
Expand Down Expand Up @@ -246,7 +250,11 @@ assert_provision_info() {
# Custom post-install script.
"Running custom post-install script './scripts/custom/provision-10-example.sh'."
"@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();"
"@drush -y pm:install ys_core"
"@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy"
"@drush -y pm:install redis"
"@drush -y pm:install clamav"
"@drush -y pm:install search_api search_api_solr"
"@drush -y pm:install ys_core ys_search"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
# Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script.
Expand Down Expand Up @@ -370,7 +378,11 @@ assert_provision_info() {
# Custom post-install script.
"Running custom post-install script './scripts/custom/provision-10-example.sh'."
"@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();"
"@drush -y pm:install ys_core"
"@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy"
"@drush -y pm:install redis"
"@drush -y pm:install clamav"
"@drush -y pm:install search_api search_api_solr"
"@drush -y pm:install ys_core ys_search"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
# Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script.
Expand Down Expand Up @@ -498,7 +510,11 @@ assert_provision_info() {
# Custom post-install script.
"Running custom post-install script './scripts/custom/provision-10-example.sh'."
"@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();"
"@drush -y pm:install ys_core"
"@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy"
"@drush -y pm:install redis"
"@drush -y pm:install clamav"
"@drush -y pm:install search_api search_api_solr"
"@drush -y pm:install ys_core ys_search"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
# Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script.
Expand Down Expand Up @@ -622,7 +638,11 @@ assert_provision_info() {
# Custom post-install script.
"Running custom post-install script './scripts/custom/provision-10-example.sh'."
"@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();"
"@drush -y pm:install ys_core"
"@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy"
"@drush -y pm:install redis"
"@drush -y pm:install clamav"
"@drush -y pm:install search_api search_api_solr"
"@drush -y pm:install ys_core ys_search"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
# Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script.
Expand Down Expand Up @@ -740,7 +760,11 @@ assert_provision_info() {
# Custom post-install script.
"Running custom post-install script './scripts/custom/provision-10-example.sh'."
"@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();"
"@drush -y pm:install ys_core"
"@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy"
"@drush -y pm:install redis"
"@drush -y pm:install clamav"
"@drush -y pm:install search_api search_api_solr"
"@drush -y pm:install ys_core ys_search"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
# Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script.
Expand Down Expand Up @@ -865,7 +889,11 @@ assert_provision_info() {
# Custom post-install script.
"Running custom post-install script './scripts/custom/provision-10-example.sh'."
"@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();"
"@drush -y pm:install ys_core"
"@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy"
"@drush -y pm:install redis"
"@drush -y pm:install clamav"
"@drush -y pm:install search_api search_api_solr"
"@drush -y pm:install ys_core ys_search"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
# Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script.
Expand Down
23 changes: 16 additions & 7 deletions scripts/custom/provision-10-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,26 @@ if echo "${DREVOPS_PROVISION_ENVIRONMENT:-}" | grep -q -e dev -e test -e ci -e l
# Set site name.
drush php:eval "\Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();"

# Enable contrib modules.
drush pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy

#;< REDIS
drush pm:install redis
#;> REDIS

#;< CLAMAV
drush pm:install clamav
#;> CLAMAV

#;< SOLR
drush pm:install search_api search_api_solr
#;> SOLR

# Enable custom site module and run its deployment hooks.
#
# In this example, the deployment hook implementation conditionally enables
# other custom modules:
# - Redis cache backend, if it is used in the project
# - ClamAV, if it is used in the project
# - Additional Solr search configuration, if Solr is used in the project
#
# Note that deployment hooks for already enabled modules have run in the
# parent "provision.sh" script.
drush pm:install ys_core
drush pm:install ys_core ys_search
drush deploy:hook

# Conditionally perform an action if this is a "fresh" database.
Expand Down
47 changes: 0 additions & 47 deletions web/modules/custom/ys_core/ys_core.deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* Deploy functions called from drush deploy:hook.
*
* @see https://www.drush.org/latest/deploycommand/
*
* phpcs:disable Squiz.WhiteSpace.FunctionSpacing.Before
* phpcs:disable Squiz.WhiteSpace.FunctionSpacing.After
*/

declare(strict_types=1);

use Drupal\Core\Extension\ExtensionDiscovery;

/**
* Installs custom theme.
*/
Expand All @@ -22,45 +17,3 @@ function ys_core_deploy_install_theme(): void {
\Drupal::service('theme_installer')->install(['your_site_theme']);
\Drupal::service('config.factory')->getEditable('system.theme')->set('default', 'your_site_theme')->save();
}

// phpcs:ignore #;< REDIS
/**
* Enables Redis module.
*/
function ys_core_deploy_enable_redis(): void {
$listing = new ExtensionDiscovery(\Drupal::root());
$modules = $listing->scan('module');
if (!empty($modules['redis'])) {
\Drupal::service('module_installer')->install(['redis']);
}
}

// phpcs:ignore #;> REDIS

// phpcs:ignore #;< CLAMAV
/**
* Enables Search API and Search API Solr modules.
*/
function ys_core_deploy_enable_clamav(): void {
$listing = new ExtensionDiscovery(\Drupal::root());
$modules = $listing->scan('module');
if (!empty($modules['clamav'])) {
\Drupal::service('module_installer')->install(['media']);
\Drupal::service('module_installer')->install(['clamav']);
}
}

// phpcs:ignore #;> CLAMAV

// phpcs:ignore #;< SOLR
/**
* Enables Search API and Search API Solr modules.
*/
function ys_core_deploy_enable_search_api_solr(): void {
$listing = new ExtensionDiscovery(\Drupal::root());
$modules = $listing->scan('module');
if (!empty($modules['search_api']) && !empty($modules['search_api_solr']) && !empty($modules['ys_search'])) {
\Drupal::service('module_installer')->install(['ys_search']);
}
}
// phpcs:ignore #;> SOLR
11 changes: 0 additions & 11 deletions web/modules/custom/ys_core/ys_core.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,3 @@ type: module
description: Core feature for YOURSITE site.
core_version_requirement: ^10
package: your_site
dependencies:
- admin_toolbar:admin_toolbar
- coffee:coffee
- config_split:config_split
- config_update:config_update
- drupal:media
- environment_indicator:environment_indicator
- pathauto:pathauto
- redirect:redirect
- shield:shield
- stage_file_proxy:stage_file_proxy

1 comment on commit e51ef37

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.