From c57a3c658966a0b33ca8cb294098bd8f0d013a51 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Tue, 24 Mar 2026 23:53:51 +1100 Subject: [PATCH 1/2] [#2374] Added opt-in repeated configuration import after initial import. --- .../docs/content/development/variables.mdx | 1 + .vortex/docs/content/drupal/provision.mdx | 7 +- .vortex/tests/bats/unit/provision.bats | 165 ++++++++++++++++++ scripts/vortex/provision.sh | 12 ++ 4 files changed, 183 insertions(+), 2 deletions(-) diff --git a/.vortex/docs/content/development/variables.mdx b/.vortex/docs/content/development/variables.mdx index 49b07f9e0..24314dfa7 100644 --- a/.vortex/docs/content/development/variables.mdx +++ b/.vortex/docs/content/development/variables.mdx @@ -388,6 +388,7 @@ The list below is automatically generated with [Shellvar](https://github.com/ale | `VORTEX_PROJECT` | Project name.

Drives internal naming within the codebase. Does not affect the names of containers and development URL - those depend on the project directory and can be overridden with [`$COMPOSE_PROJECT_NAME`](#compose_project_name). | `your_site` | `.env`, `scripts/vortex/info.sh` | | `VORTEX_PROVISION_ACQUIA_SKIP` | Skip Drupal site provisioning in Acquia environment. | `UNDEFINED` | `ACQUIA ENVIRONMENT` | | `VORTEX_PROVISION_CACHE_REBUILD_AFTER_DB_UPDATE_SKIP` | Skip cache rebuild after database updates. | `0` | `scripts/vortex/provision.sh` | +| `VORTEX_PROVISION_CONFIG_IMPORT_REPEAT` | Repeat configuration import after the initial import. Useful when database update hooks introduce new configuration that affects subsequent configuration imports (e.g., new config_split settings). | `0` | `scripts/vortex/provision.sh` | | `VORTEX_PROVISION_DB` | Provision database dump file. If not set, it will be auto-discovered from the VORTEX_DB_DIR directory using the VORTEX_DB_FILE name. | `UNDEFINED` | `scripts/vortex/provision.sh` | | `VORTEX_PROVISION_DB_DIR` | Directory with database dump file. | `./.data` | `scripts/vortex/provision.sh` | | `VORTEX_PROVISION_DB_FILE` | Database dump file name. | `db.sql` | `scripts/vortex/provision.sh` | diff --git a/.vortex/docs/content/drupal/provision.mdx b/.vortex/docs/content/drupal/provision.mdx index 2088ba08d..847949f5a 100644 --- a/.vortex/docs/content/drupal/provision.mdx +++ b/.vortex/docs/content/drupal/provision.mdx @@ -140,11 +140,13 @@ section. ▼ ⬇️ Import configuration (if config files present) ▼ +⑨ 🔁 Repeat configuration import (opt-in) + ▼ 🧹 Rebuild caches ▼ 🔄 Run deployment hooks ▼ -⑨ 😷 Run DB sanitization +⑩ 😷 Run DB sanitization ▼ ⚙️ Run custom scripts ▼ @@ -165,7 +167,8 @@ You can control the provisioning flow using the following environment variables: 6. `VORTEX_PROVISION_USE_MAINTENANCE_MODE=1`
Enable maintenance mode right after the site is bootstrappable and disable it at the end. Useful when you want to prevent users from accessing the site while it is being provisioned.

7. `VORTEX_PROVISION_VERIFY_CONFIG_UNCHANGED_AFTER_UPDATE=1`
Verify that active configuration was not changed by database updates. When enabled and config files are present, the provision will fail if `drush updatedb` modifies active configuration, preventing `drush config:import` from silently overwriting those changes.

8. `VORTEX_PROVISION_CACHE_REBUILD_AFTER_DB_UPDATE_SKIP=1`
Skip the cache rebuild that runs between database updates and configuration import. By default, caches are rebuilt after `drush updatedb` to ensure a clean state before importing configuration.

-9. `VORTEX_PROVISION_SANITIZE_DB_SKIP=1`
Disable database sanitization. +9. `VORTEX_PROVISION_CONFIG_IMPORT_REPEAT=1`
Repeat the configuration import after the initial import. Useful when database update hooks introduce new configuration that affects subsequent configuration imports (e.g., new config_split settings). Disabled by default.

+10. `VORTEX_PROVISION_SANITIZE_DB_SKIP=1`
Disable database sanitization. :::tip diff --git a/.vortex/tests/bats/unit/provision.bats b/.vortex/tests/bats/unit/provision.bats index b0c091ccf..c26ad75d5 100644 --- a/.vortex/tests/bats/unit/provision.bats +++ b/.vortex/tests/bats/unit/provision.bats @@ -549,6 +549,8 @@ assert_provision_info() { "Importing configuration." "@drush -y config:import" "Completed configuration import." + "- Repeating configuration import." + "- Completed repeated configuration import." "@drush -y pm:list --status=enabled # config_split" "Importing config_split configuration." "@drush -y config:import" @@ -1773,6 +1775,167 @@ assert_provision_info() { popd >/dev/null || exit 1 } +@test "Provision: DB; no site; config import repeat" { + pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1 + + # Remove .env file to test in isolation. + rm ./.env && touch ./.env + rm -f ./scripts/custom/provision-20-migration.sh + + export VORTEX_PROVISION_SANITIZE_DB_PASSWORD="MOCK_DB_SANITIZE_PASSWORD" + export CI=1 + + mkdir "./.data" + touch "./.data/db.sql" + + export VORTEX_PROVISION_CONFIG_IMPORT_REPEAT=1 + + mocked_uuid="c9360453-e1ea-4292-b074-ea375f97d72b" + echo "uuid: ${mocked_uuid}" >"./config/default/system.site.yml" + echo "name: 'SUT'" >>"./config/default/system.site.yml" + + create_global_command_wrapper "vendor/bin/drush" + + declare -a STEPS=( + # Drush status calls. + "@drush -y --version # Drush Commandline Tool mocked_drush_version" + "@drush -y status --field=drupal-version # mocked_core_version" + "@drush -y status --fields=bootstrap # fail" + "@drush -y php:eval print realpath(\Drupal\Core\Site\Settings::get(\"config_sync_directory\")); # $(pwd)/config/default" + + # Site provisioning information. + "Provisioning site from the database dump file." + "Dump file path: $(pwd)/.data/db.sql" + "- Existing site was found." + "- Site content will be preserved." + "- Sanitization will be skipped for an existing database." + "- Existing site content will be removed and fresh content will be imported from the database dump file." + "Existing site was not found." + "Fresh site content will be imported from the database dump file." + "@drush -y sql:drop" + "@drush -y sql:connect" + "- Unable to import database from file." + "- Dump file $(pwd)/.data/db.sql does not exist." + "- Site content was not changed." + "Imported database from the dump file." + # Profile. + "- Provisioning site from the profile." + "- Existing site content will be removed and new content will be created from the profile." + "- Installed a site from the profile." + "- Fresh site content will be created from the profile." + + # Drupal environment information. + "Current Drupal environment: ci" + "@drush -y php:eval print \Drupal\core\Site\Settings::get('environment'); # ci" + + # Post-provision operations. + "- Skipped running of post-provision operations as VORTEX_PROVISION_POST_OPERATIONS_SKIP is set to 1." + + # Maintenance mode. + "Enabling maintenance mode." + "@drush -y maint:set 1" + "Enabled maintenance mode." + + # UUID setup. + "@drush -y config-set system.site uuid ${mocked_uuid}" + "Updated site UUID from the configuration with ${mocked_uuid}" + + # Database updates. + "Running database updates." + "@drush -y updatedb --no-cache-clear" + "Completed running database updates." + + # Cache rebuild after database updates. + "Clearing cache after database updates." + "@drush -y cache:rebuild" + "Cache was cleared." + + # Configuration import. + "Importing configuration." + "@drush -y config:import" + "Completed configuration import." + + # Repeated configuration import. + "Repeating configuration import." + "@drush -y config:import" + "Completed repeated configuration import." + + "@drush -y pm:list --status=enabled # config_split" + "Importing config_split configuration." + "@drush -y config:import" + "Completed config_split configuration import." + + # Cache rebuild. + "Rebuilding cache." + "@drush -y cache:rebuild" + "Cache was rebuilt." + + # Deployment hooks. + "Running deployment hooks." + "@drush -y deploy:hook" + "Completed deployment hooks." + + # Database sanitization. + "Sanitizing database." + "@drush -y sql:sanitize --sanitize-password=MOCK_DB_SANITIZE_PASSWORD --sanitize-email=user+%uid@localhost" + "Sanitized database using drush sql:sanitize." + "- Updated username with user email." + "@drush -y sql:query --file=../scripts/sanitize.sql" + "Applied custom sanitization commands from file" + "@drush -y sql:query UPDATE \`users_field_data\` SET mail = '', name = '' WHERE uid = '0';" + "@drush -y sql:query UPDATE \`users_field_data\` SET name = '' WHERE uid = '0';" + "Reset user 0 username and email." + "- Updated user 1 email." + "- Skipped database sanitization as VORTEX_PROVISION_SANITIZE_DB_SKIP is set to 1." + + # Custom post-install script. + "Running custom post-install script './scripts/custom/provision-10-example.sh'." + "@drush -y php:eval print \Drupal\core\Site\Settings::get('environment'); # ci" + " > Setting site name." + "@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();" + " > Installing contrib modules." + "@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect robotstxt shield stage_file_proxy xmlsitemap" + " > Installing Redis module." + "@drush -y pm:install redis" + " > Installing and configuring ClamAV." + "@drush -y pm:install clamav" + "@drush -y config-set clamav.settings mode_daemon_tcpip.hostname clamav" + " > Installing Solr search modules." + "@drush -y pm:install search_api search_api_solr" + " > Installing custom site modules." + "@drush -y pm:install ys_base" + "@drush -y pm:install ys_search" + "@drush -y pm:install ys_demo" + " > Running deployment hooks." + "@drush -y deploy:hook" + " ==> Started example operations." + " Environment: ci" + " Running example operations in non-production environment." + # Assert that VORTEX_PROVISION_OVERRIDE_DB is correctly passed to the script. + " Fresh database detected. Performing additional example operations." + "- Existing database detected. Performing additional example operations." + " ==> Finished example operations." + "Completed running of custom post-install script './scripts/custom/provision-10-example.sh'." + + # Disabling maintenance mode. + "Disabling maintenance mode." + "@drush -y maint:set 0" + "Disabled maintenance mode." + + # Installation completion. + "Finished site provisioning" + ) + + mocks="$(run_steps "setup")" + + run ./scripts/vortex/provision.sh + assert_success + + run_steps "assert" "${mocks[@]}" + + popd >/dev/null || exit 1 +} + @test "Provision: DB; no site; no fallback" { pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1 @@ -1907,6 +2070,8 @@ assert_provision_info() { "Importing configuration." "@drush -y config:import" "Completed configuration import." + "- Repeating configuration import." + "- Completed repeated configuration import." "@drush -y pm:list --status=enabled # config_split" "Importing config_split configuration." "@drush -y config:import" diff --git a/scripts/vortex/provision.sh b/scripts/vortex/provision.sh index 9e508d2fa..48ba61098 100755 --- a/scripts/vortex/provision.sh +++ b/scripts/vortex/provision.sh @@ -47,6 +47,11 @@ VORTEX_PROVISION_VERIFY_CONFIG_UNCHANGED_AFTER_UPDATE="${VORTEX_PROVISION_VERIFY # Skip cache rebuild after database updates. VORTEX_PROVISION_CACHE_REBUILD_AFTER_DB_UPDATE_SKIP="${VORTEX_PROVISION_CACHE_REBUILD_AFTER_DB_UPDATE_SKIP:-0}" +# Repeat configuration import after the initial import. +# Useful when update hooks introduce new configuration that affects subsequent +# configuration imports (e.g., new config_split settings). +VORTEX_PROVISION_CONFIG_IMPORT_REPEAT="${VORTEX_PROVISION_CONFIG_IMPORT_REPEAT:-0}" + # Provision database dump file. # If not set, it will be auto-discovered from the VORTEX_DB_DIR directory using # the VORTEX_DB_FILE name. @@ -374,6 +379,13 @@ if [ "${site_has_config_files}" = "1" ]; then pass "Completed configuration import." echo + if [ "${VORTEX_PROVISION_CONFIG_IMPORT_REPEAT}" = "1" ]; then + task "Repeating configuration import." + drush config:import + pass "Completed repeated configuration import." + echo + fi + # Import config_split configuration if the module is installed. # Drush deploy does not import config_split configuration on the first run. # @see https://github.com/drush-ops/drush/issues/2449 From 6357e67dfa6ce320520988245bcaed16cc385154 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 25 Mar 2026 00:12:07 +1100 Subject: [PATCH 2/2] Regenerated variables documentation. --- .vortex/docs/content/development/variables.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vortex/docs/content/development/variables.mdx b/.vortex/docs/content/development/variables.mdx index 24314dfa7..c62f7f262 100644 --- a/.vortex/docs/content/development/variables.mdx +++ b/.vortex/docs/content/development/variables.mdx @@ -388,7 +388,7 @@ The list below is automatically generated with [Shellvar](https://github.com/ale | `VORTEX_PROJECT` | Project name.

Drives internal naming within the codebase. Does not affect the names of containers and development URL - those depend on the project directory and can be overridden with [`$COMPOSE_PROJECT_NAME`](#compose_project_name). | `your_site` | `.env`, `scripts/vortex/info.sh` | | `VORTEX_PROVISION_ACQUIA_SKIP` | Skip Drupal site provisioning in Acquia environment. | `UNDEFINED` | `ACQUIA ENVIRONMENT` | | `VORTEX_PROVISION_CACHE_REBUILD_AFTER_DB_UPDATE_SKIP` | Skip cache rebuild after database updates. | `0` | `scripts/vortex/provision.sh` | -| `VORTEX_PROVISION_CONFIG_IMPORT_REPEAT` | Repeat configuration import after the initial import. Useful when database update hooks introduce new configuration that affects subsequent configuration imports (e.g., new config_split settings). | `0` | `scripts/vortex/provision.sh` | +| `VORTEX_PROVISION_CONFIG_IMPORT_REPEAT` | Repeat configuration import after the initial import. Useful when update hooks introduce new configuration that affects subsequent configuration imports (e.g., new config_split settings). | `0` | `scripts/vortex/provision.sh` | | `VORTEX_PROVISION_DB` | Provision database dump file. If not set, it will be auto-discovered from the VORTEX_DB_DIR directory using the VORTEX_DB_FILE name. | `UNDEFINED` | `scripts/vortex/provision.sh` | | `VORTEX_PROVISION_DB_DIR` | Directory with database dump file. | `./.data` | `scripts/vortex/provision.sh` | | `VORTEX_PROVISION_DB_FILE` | Database dump file name. | `db.sql` | `scripts/vortex/provision.sh` |