diff --git a/.scaffold/tests/bats/provision.bats b/.scaffold/tests/bats/provision.bats index 39913c0cb..2bd781a0f 100644 --- a/.scaffold/tests/bats/provision.bats +++ b/.scaffold/tests/bats/provision.bats @@ -17,25 +17,26 @@ assert_provision_info() { [ "${1}" == "1" ] && echo "Yes" || echo "No" } + assert_output_contains "Drupal core version : mocked_core_version" + assert_output_contains "Drush version : mocked_drush_version" + assert_output_contains "Started site provisioning." - assert_output_contains "Webroot dir : ${webroot}" - assert_output_contains "Profile : standard" - assert_output_contains "Public files path : /app/${webroot}/sites/default/files" - assert_output_contains "Private files path : /app/${webroot}/sites/default/files/private" - assert_output_contains "Temporary files path : /tmp" - assert_output_contains "Config path : $(pwd)/config/default" - assert_output_contains "DB dump file path : $(pwd)/.data/db.sql" - - assert_output_contains "Drush version : mocked_drush_version" - assert_output_contains "Drupal core version : mocked_core_version" - - assert_output_contains "Install from profile : $(format_yes_no "${1:-0}")" - assert_output_contains "Overwrite existing DB : $(format_yes_no "${2:-0}")" - assert_output_contains "Skip sanitization : $(format_yes_no "${3:-0}")" - assert_output_contains "Use maintenance mode : $(format_yes_no "${4:-1}")" - assert_output_contains "Skip post-install operations : $(format_yes_no "${5:-0}")" - assert_output_contains "Configuration files present : $(format_yes_no "${6:-0}")" - assert_output_contains "Existing site found : $(format_yes_no "${7:-0}")" + assert_output_contains "Webroot path : $(pwd)/${webroot}" + assert_output_contains "Public files path : /app/${webroot}/sites/default/files" + assert_output_contains "Private files path : /app/${webroot}/sites/default/files/private" + assert_output_contains "Temporary files path : /tmp" + assert_output_contains "Config files path : $(pwd)/config/default" + assert_output_contains "DB dump file path : $(pwd)/.data/db.sql" + + assert_output_contains "Profile : standard" + assert_output_contains "Configuration files present : $(format_yes_no "${6:-0}")" + assert_output_contains "Existing site found : $(format_yes_no "${7:-0}")" + + assert_output_contains "Install from profile : $(format_yes_no "${1:-0}")" + assert_output_contains "Overwrite existing DB : $(format_yes_no "${2:-0}")" + assert_output_contains "Skip DB sanitization : $(format_yes_no "${3:-0}")" + assert_output_contains "Skip post-provision operations : $(format_yes_no "${5:-0}")" + assert_output_contains "Use maintenance mode : $(format_yes_no "${4:-1}")" } @test "Provision: DB; no site" { @@ -82,8 +83,8 @@ assert_provision_info() { "- Existing site was not found when provisioning from the profile." "- Fresh site content will be created from the profile." - # Post-install operations. - "- Skipped running of post-install operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." + # Post-provision operations. + "- Skipped running of post-provision operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." # Maintenance mode. "Enabling maintenance mode." @@ -134,8 +135,8 @@ assert_provision_info() { "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. - "Fresh database detected. Performing additional operations." - "- Existing database detected. Skipping additional operations." + "Fresh database detected. Performing additional example operations." + "- Existing database detected. Performing additional example operations." "Completed running of custom post-install script './scripts/custom/provision-10-example.sh'." # Disabling maintenance mode. @@ -201,8 +202,8 @@ assert_provision_info() { "- Existing site was not found when provisioning from the profile." "- Fresh site content will be created from the profile." - # Post-install operations. - "- Skipped running of post-install operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." + # Post-provision operations. + "- Skipped running of post-provision operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." # Maintenance mode. "Enabling maintenance mode." @@ -249,8 +250,8 @@ assert_provision_info() { "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. - "- Fresh database detected. Performing additional operations." - "Existing database detected. Skipping additional operations." + "- Fresh database detected. Performing additional example operations." + "Existing database detected. Performing additional example operations." "Completed running of custom post-install script './scripts/custom/provision-10-example.sh'." # Disabling maintenance mode. @@ -321,8 +322,8 @@ assert_provision_info() { "- Existing site was not found when provisioning from the profile." "- Fresh site content will be created from the profile." - # Post-install operations. - "- Skipped running of post-install operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." + # Post-provision operations. + "- Skipped running of post-provision operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." # Maintenance mode. "Enabling maintenance mode." @@ -373,8 +374,8 @@ assert_provision_info() { "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. - "Fresh database detected. Performing additional operations." - "- Existing database detected. Skipping additional operations." + "Fresh database detected. Performing additional example operations." + "- Existing database detected. Performing additional example operations." "Completed running of custom post-install script './scripts/custom/provision-10-example.sh'." # Disabling maintenance mode. @@ -447,8 +448,8 @@ assert_provision_info() { "- Existing site was not found when provisioning from the profile." "- Fresh site content will be created from the profile." - # Post-install operations. - "- Skipped running of post-install operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." + # Post-provision operations. + "- Skipped running of post-provision operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." # Maintenance mode. "Enabling maintenance mode." @@ -501,8 +502,8 @@ assert_provision_info() { "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. - "Fresh database detected. Performing additional operations." - "- Existing database detected. Skipping additional operations." + "Fresh database detected. Performing additional example operations." + "- Existing database detected. Performing additional example operations." "Completed running of custom post-install script './scripts/custom/provision-10-example.sh'." # Disabling maintenance mode. @@ -573,8 +574,8 @@ assert_provision_info() { "Existing site was not found when provisioning from the profile." "Fresh site content will be created from the profile." - # Post-install operations. - "- Skipped running of post-install operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." + # Post-provision operations. + "- Skipped running of post-provision operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." # Maintenance mode. "Enabling maintenance mode." @@ -625,8 +626,8 @@ assert_provision_info() { "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. - "Fresh database detected. Performing additional operations." - "- Existing database detected. Skipping additional operations." + "Fresh database detected. Performing additional example operations." + "- Existing database detected. Performing additional example operations." "Completed running of custom post-install script './scripts/custom/provision-10-example.sh'." # Disabling maintenance mode. @@ -695,8 +696,8 @@ assert_provision_info() { "- Existing site was not found when provisioning from the profile." "- Fresh site content will be created from the profile." - # Post-install operations. - "- Skipped running of post-install operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." + # Post-provision operations. + "- Skipped running of post-provision operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." # Maintenance mode. "Enabling maintenance mode." @@ -743,8 +744,8 @@ assert_provision_info() { "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. - "- Fresh database detected. Performing additional operations." - "Existing database detected. Skipping additional operations." + "- Fresh database detected. Performing additional example operations." + "Existing database detected. Performing additional example operations." "Completed running of custom post-install script './scripts/custom/provision-10-example.sh'." # Disabling maintenance mode. @@ -816,8 +817,8 @@ assert_provision_info() { "- Existing site was not found when provisioning from the profile." "- Fresh site content will be created from the profile." - # Post-install operations. - "- Skipped running of post-install operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." + # Post-provision operations. + "- Skipped running of post-provision operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." # Maintenance mode. "Enabling maintenance mode." @@ -868,8 +869,8 @@ assert_provision_info() { "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. - "Fresh database detected. Performing additional operations." - "- Existing database detected. Skipping additional operations." + "Fresh database detected. Performing additional example operations." + "- Existing database detected. Performing additional example operations." "Completed running of custom post-install script './scripts/custom/provision-10-example.sh'." # Disabling maintenance mode. diff --git a/scripts/custom/provision-10-example.sh b/scripts/custom/provision-10-example.sh index bffa5b8aa..0b48540a2 100644 --- a/scripts/custom/provision-10-example.sh +++ b/scripts/custom/provision-10-example.sh @@ -6,7 +6,8 @@ # # For ordering multiple commands, use a two-digit suffix for clarity and consistency. # This approach ensures a clear sequence and avoids potential ordering issues. -# Examples: +# +# Example: # - provision-10-example.sh # - provision-20-example.sh # - provision-30-example.sh @@ -22,7 +23,7 @@ drush() { ./vendor/bin/drush -y "$@"; } # Perform operations based on the current environment. if echo "${DREVOPS_PROVISION_ENVIRONMENT:-}" | grep -q -e dev -e test -e ci -e local; then - echo "[INFO] Executing example operations in non-production environment." + echo "==> Executing example operations in non-production environment." # Below are examples of running operations. @@ -44,10 +45,10 @@ if echo "${DREVOPS_PROVISION_ENVIRONMENT:-}" | grep -q -e dev -e test -e ci -e l # Conditionally perform an action if this is a "fresh" database. if [ "${DREVOPS_PROVISION_OVERRIDE_DB:-0}" = "1" ]; then - echo " > Fresh database detected. Performing additional operations." + echo " > Fresh database detected. Performing additional example operations." else - echo " > Existing database detected. Skipping additional operations." + echo " > Existing database detected. Performing additional example operations." fi - echo "[ OK ] Finished executing example operations in non-production environment." + echo "==> Finished executing example operations in non-production environment." fi diff --git a/scripts/drevops/provision.sh b/scripts/drevops/provision.sh index c839af2de..41192960a 100755 --- a/scripts/drevops/provision.sh +++ b/scripts/drevops/provision.sh @@ -69,8 +69,10 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on -yesno() { [ "${1}" = "1" ] && echo "Yes" || echo "No"; } drush() { ./vendor/bin/drush -y "$@"; } +yesno() { [ "${1}" = "1" ] && echo "Yes" || echo "No"; } + +# ------------------------------------------------------------------------------ info "Started site provisioning." @@ -80,9 +82,10 @@ info "Started site provisioning." [ "${DREVOPS_DB_DIR#./}" != "${DREVOPS_DB_DIR}" ] && DREVOPS_DB_DIR="$(pwd)${DREVOPS_DB_DIR#.}" drush_version="$(drush --version | cut -d' ' -f4)" -drupal_core_version="$(drush status --field=drupal-version)" +drupal_version="$(drush status --field=drupal-version)" site_is_installed="$(drush status --fields=bootstrap | grep -q "Successful" && echo "1" || echo "0")" +# Discover the configuration directory path if not set. if [ -z "${DRUPAL_CONFIG_PATH}" ]; then DRUPAL_CONFIG_PATH="$(drush php:eval 'print realpath(\Drupal\Core\Site\Settings::get("config_sync_directory"));')" [ ! -d "${DRUPAL_CONFIG_PATH}" ] && fail "Config directory \"${DRUPAL_CONFIG_PATH:-}\" does not exist." && exit 1 @@ -94,27 +97,28 @@ site_has_config="$(test "$(ls -1 ${DRUPAL_CONFIG_PATH}/*.yml 2>/dev/null | wc -l # Print provisioning information. ################################################################################ echo -note "Webroot dir : ${DREVOPS_WEBROOT}" -note "Profile : ${DRUPAL_PROFILE}" -note "Public files path : ${DRUPAL_PUBLIC_FILES-}" -note "Private files path : ${DRUPAL_PRIVATE_FILES-}" -note "Temporary files path : ${DRUPAL_TEMPORARY_FILES-}" -note "Config path : ${DRUPAL_CONFIG_PATH}" -note "DB dump file path : ${DREVOPS_DB_DIR}/${DREVOPS_DB_FILE} ($([ -f "${DREVOPS_DB_DIR}/${DREVOPS_DB_FILE}" ] && echo "present" || echo "absent"))" +note "Drupal core version : ${drupal_version}" +note "Drush version : ${drush_version}" +echo +note "Webroot path : $(pwd)/${DREVOPS_WEBROOT}" +note "Public files path : ${DRUPAL_PUBLIC_FILES-}" +note "Private files path : ${DRUPAL_PRIVATE_FILES-}" +note "Temporary files path : ${DRUPAL_TEMPORARY_FILES-}" +note "Config files path : ${DRUPAL_CONFIG_PATH}" +note "DB dump file path : ${DREVOPS_DB_DIR}/${DREVOPS_DB_FILE} ($([ -f "${DREVOPS_DB_DIR}/${DREVOPS_DB_FILE}" ] && echo "present" || echo "absent"))" if [ -n "${DREVOPS_DB_IMAGE:-}" ]; then - note "DB dump container image : ${DREVOPS_DB_IMAGE}" + note "DB dump container image : ${DREVOPS_DB_IMAGE}" fi echo -note "Drush version : ${drush_version}" -note "Drupal core version : ${drupal_core_version}" +note "Profile : ${DRUPAL_PROFILE}" +note "Configuration files present : $(yesno "${site_has_config}")" +note "Existing site found : $(yesno "${site_is_installed}")" echo -note "Install from profile : $(yesno "${DREVOPS_PROVISION_USE_PROFILE}")" -note "Overwrite existing DB : $(yesno "${DREVOPS_PROVISION_OVERRIDE_DB}")" -note "Skip sanitization : $(yesno "${DREVOPS_PROVISION_SANITIZE_DB_SKIP}")" -note "Use maintenance mode : $(yesno "${DREVOPS_PROVISION_USE_MAINTENANCE_MODE}")" -note "Skip post-install operations : $(yesno "${DREVOPS_PROVISION_POST_OPERATIONS_SKIP}")" -note "Configuration files present : $(yesno "${site_has_config}")" -note "Existing site found : $(yesno "${site_is_installed}")" +note "Install from profile : $(yesno "${DREVOPS_PROVISION_USE_PROFILE}")" +note "Overwrite existing DB : $(yesno "${DREVOPS_PROVISION_OVERRIDE_DB}")" +note "Skip DB sanitization : $(yesno "${DREVOPS_PROVISION_SANITIZE_DB_SKIP}")" +note "Skip post-provision operations : $(yesno "${DREVOPS_PROVISION_POST_OPERATIONS_SKIP}")" +note "Use maintenance mode : $(yesno "${DREVOPS_PROVISION_USE_MAINTENANCE_MODE}")" echo ################################################################################ @@ -169,8 +173,6 @@ provision_from_profile() { # The code block below has explicit if-else conditions and verbose output to # ensure that this significant operation is executed correctly and has # sufficient output for debugging. -echo - if [ "${DREVOPS_PROVISION_USE_PROFILE}" != "1" ]; then info "Provisioning site from the database dump file." note "Dump file path: ${DREVOPS_DB_DIR}/${DREVOPS_DB_FILE}" @@ -221,7 +223,7 @@ fi echo if [ "${DREVOPS_PROVISION_POST_OPERATIONS_SKIP}" = "1" ]; then - info "Skipped running of post-install operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." + info "Skipped running of post-provision operations as DREVOPS_PROVISION_POST_OPERATIONS_SKIP is set to 1." echo info "Finished site provisioning." exit 0 @@ -237,8 +239,8 @@ fi # Get the current environment and export it for the downstream scripts. DREVOPS_PROVISION_ENVIRONMENT="$(drush php:eval "print \Drupal\core\Site\Settings::get('environment');")" info "Current Drupal environment: ${DREVOPS_PROVISION_ENVIRONMENT}" -export DREVOPS_PROVISION_ENVIRONMENT echo +export DREVOPS_PROVISION_ENVIRONMENT # Use 'drush deploy' if configuration files are present or use standalone commands otherwise. if [ "${site_has_config}" = "1" ]; then @@ -246,11 +248,13 @@ if [ "${site_has_config}" = "1" ]; then config_uuid="$(cat "${DRUPAL_CONFIG_PATH}/system.site.yml" | grep uuid | tail -c +7 | head -c 36)" drush config-set system.site uuid "${config_uuid}" pass "Updated site UUID from the configuration with ${config_uuid}." + echo fi info "Running deployment operations via 'drush deploy'." drush deploy pass "Completed deployment operations via 'drush deploy'." + echo # Import config_split configuration if the module is installed. # Drush deploy does not import config_split configuration on the first run. @@ -260,6 +264,7 @@ if [ "${site_has_config}" = "1" ]; then info "Importing config_split configuration." drush config:import pass "Completed config_split configuration import." + echo fi else info "Running database updates." @@ -275,6 +280,7 @@ else info "Running deployment operations via 'drush deploy:hook'." drush deploy:hook pass "Completed deployment operations via 'drush deploy:hook'." + echo fi # Sanitize database. @@ -291,7 +297,6 @@ fi if [ -d "./scripts/custom" ]; then for file in ./scripts/custom/provision-*.sh; do if [ -f "${file}" ]; then - echo info "Running custom post-install script '${file}'." echo . "${file}" diff --git a/web/sites/default/default.settings.php b/web/sites/default/default.settings.php index 63fb2df74..8819d6431 100644 --- a/web/sites/default/default.settings.php +++ b/web/sites/default/default.settings.php @@ -181,8 +181,8 @@ * * WARNING: The above defaults are designed for database portability. Changing * them may cause unexpected behavior, including potential data loss. See - * https://www.drupal.org/developing/api/database/configuration for more - * information on these defaults and the potential issues. + * https://www.drupal.org/docs/8/api/database-api/database-configuration for + * more information on these defaults and the potential issues. * * More details can be found in the constructor methods for each driver: * - \Drupal\mysql\Driver\Database\mysql\Connection::__construct()