Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions .vortex/docs/content/drupal/provision.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ in every environment, ensuring consistency and eliminating manual steps.

## Rationale

While `drush deploy` is a powerful tool for executing standard Drupal deployment
steps (such as configuration import and database updates), it assumes that the
site is already in a bootstrapped, stable state. In practice, especially during
initial setup or provisioning in dynamic environments (like CI pipelines,
container builds, or multisite setups), additional orchestration is needed.
While Drush provides individual commands for deployment steps (such as
`drush updatedb`, `drush config:import`, and `drush deploy:hook`), using them
directly assumes the site is already in a bootstrapped, stable state. In
practice, especially during initial setup or provisioning in dynamic
environments (like CI pipelines, container builds, or multisite setups),
additional orchestration is needed.

The `provision.sh` script addresses these gaps by:

Expand All @@ -29,13 +30,13 @@ profile.
- **Handling conditional logic:** It accounts for different runtime scenarios, such as skipping provisioning,
enforcing fresh database imports, or using maintenance mode.
- **Enforcing consistency:** The same provisioning logic runs across local, CI, staging, and production
environments, eliminating it works on my machine issues.
environments, eliminating "it works on my machine" issues.
- **Supporting extensibility:** It allows for custom post-provisioning scripts, making it easy to layer in
project-specific logic like enabling test modules or running migrations.

In short, `provision.sh` wraps `drush deploy` in a consistent, repeatable, and
configurable process — turning a manual setup step into a reliable automation
layer.
In short, `provision.sh` orchestrates standalone Drush commands in a consistent,
repeatable, and configurable process — turning a manual setup step into a
reliable automation layer.

## Database import vs full provisioning

Expand All @@ -46,10 +47,11 @@ layer.
Runs the complete provisioning process including:

- Database import from dump or profile installation
- Configuration import via `drush config:import`
- Database updates via `drush updatedb`
- Post-provisioning custom scripts
- Configuration import via `drush config:import` (if config files present)
- Cache rebuilds
- Deployment hooks
- Post-provisioning custom scripts

Use this when you want a fully configured site ready for development or deployment.

Expand Down Expand Up @@ -128,14 +130,14 @@ section.
│ No
⑥ 🚧 Enable maintenance mode
⬇️ Import configuration
🔄 Run DB updates
⬇️ Import configuration (if config files present)
🧹 Rebuild caches
🔄 Run deployment operations
🔄 Run deployment hooks
⑦ 😷 Run DB sanitization
Expand Down
103 changes: 54 additions & 49 deletions .vortex/tests/bats/unit/provision.bats
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ assert_provision_info() {

# Deployment and configuration updates.
"- Updated site UUID from the configuration with"
"- Running deployment operations via 'drush deploy'."
"- Importing configuration."
"- Importing config_split configuration."

# Database updates.
Expand All @@ -118,10 +118,10 @@ assert_provision_info() {
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"Running deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment operations via 'drush deploy:hook'."
"Completed deployment hooks."

# Database sanitization.
"Sanitizing database."
Expand Down Expand Up @@ -239,7 +239,7 @@ assert_provision_info() {

# Deployment and configuration updates.
"- Updated site UUID from the configuration with"
"- Running deployment operations via 'drush deploy'."
"- Importing configuration."
"- Importing config_split configuration."

# Database updates.
Expand All @@ -252,10 +252,10 @@ assert_provision_info() {
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"Running deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment operations via 'drush deploy:hook'."
"Completed deployment hooks."

# Database sanitization.
"- Sanitizing database."
Expand Down Expand Up @@ -374,7 +374,7 @@ assert_provision_info() {

# Deployment and configuration updates.
"- Updated site UUID from the configuration with"
"- Running deployment operations via 'drush deploy'."
"- Importing configuration."
"- Importing config_split configuration."

# Database updates.
Expand All @@ -387,10 +387,10 @@ assert_provision_info() {
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"Running deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment operations via 'drush deploy:hook'."
"Completed deployment hooks."

# Database sanitization.
"Sanitizing database."
Expand Down Expand Up @@ -513,28 +513,33 @@ assert_provision_info() {
"@drush -y maint:set 1"
"Enabled maintenance mode."

# Deployment and configuration updates.
# UUID setup.
"@drush -y config-set system.site uuid ${mocked_uuid}"
"Updated site UUID from the configuration with ${mocked_uuid}"
"Running deployment operations via 'drush deploy'."
"@drush -y deploy"
"Completed deployment operations via 'drush deploy'."

# Database updates.
"Running database updates."
"@drush -y updatedb --no-cache-clear"
"Completed running database updates."

# Configuration import.
"Importing configuration."
"@drush -y config:import"
"Completed configuration import."
"@drush -y pm:list --status=enabled # config_split"
"Importing config_split configuration."
"@drush -y config:import"
"Completed config_split configuration import."

# Database updates.
"- Running database updates."
"- Completed running database updates."

# Cache rebuild.
"- Rebuilding cache."
"- Cache was rebuilt."
"Rebuilding cache."
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"- Running deployment operations via 'drush deploy:hook'."
"- Completed deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment hooks."

# Database sanitization.
"Sanitizing database."
Expand Down Expand Up @@ -657,7 +662,7 @@ assert_provision_info() {

# Deployment and configuration updates.
"- Updated site UUID from the configuration with"
"- Running deployment operations via 'drush deploy'."
"- Importing configuration."
"- Importing config_split configuration."

# Database updates.
Expand All @@ -670,10 +675,10 @@ assert_provision_info() {
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"Running deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment operations via 'drush deploy:hook'."
"Completed deployment hooks."

# Database sanitization.
"Sanitizing database."
Expand Down Expand Up @@ -794,7 +799,7 @@ assert_provision_info() {

# Deployment and configuration updates.
"- Updated site UUID from the configuration with"
"- Running deployment operations via 'drush deploy'."
"- Importing configuration."
"- Importing config_split configuration."

# Database updates.
Expand All @@ -807,10 +812,10 @@ assert_provision_info() {
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"Running deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment operations via 'drush deploy:hook'."
"Completed deployment hooks."

# Database sanitization.
"- Sanitizing database."
Expand Down Expand Up @@ -930,7 +935,7 @@ assert_provision_info() {

# Deployment and configuration updates.
"- Updated site UUID from the configuration with"
"- Running deployment operations via 'drush deploy'."
"- Importing configuration."
"- Importing config_split configuration."

# Database updates.
Expand All @@ -943,10 +948,10 @@ assert_provision_info() {
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"Running deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment operations via 'drush deploy:hook'."
"Completed deployment hooks."

# Database sanitization.
"Sanitizing database."
Expand Down Expand Up @@ -1066,7 +1071,7 @@ assert_provision_info() {

# Deployment and configuration updates.
"- Updated site UUID from the configuration with"
"- Running deployment operations via 'drush deploy'."
"- Importing configuration."
"- Importing config_split configuration."

# Database updates.
Expand All @@ -1079,10 +1084,10 @@ assert_provision_info() {
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"Running deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment operations via 'drush deploy:hook'."
"Completed deployment hooks."

# Database sanitization.
"Sanitizing database."
Expand Down Expand Up @@ -1233,7 +1238,7 @@ assert_provision_info() {

# Deployment and configuration updates.
"- Updated site UUID from the configuration with"
"- Running deployment operations via drush deploy."
"- Importing configuration."
"- Importing config_split configuration."

# Database updates.
Expand All @@ -1246,10 +1251,10 @@ assert_provision_info() {
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"Running deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment operations via 'drush deploy:hook'."
"Completed deployment hooks."

# Database sanitization.
"Sanitizing database."
Expand Down Expand Up @@ -1370,7 +1375,7 @@ assert_provision_info() {

# Deployment and configuration updates.
"- Updated site UUID from the configuration with"
"- Running deployment operations via drush deploy."
"- Importing configuration."
"- Importing config_split configuration."

# Database updates.
Expand All @@ -1383,10 +1388,10 @@ assert_provision_info() {
"@drush -y cache:rebuild"
"Cache was rebuilt."

# Post configuration import updates.
"Running deployment operations via 'drush deploy:hook'."
# Deployment hooks.
"Running deployment hooks."
"@drush -y deploy:hook"
"Completed deployment operations via 'drush deploy:hook'."
"Completed deployment hooks."

# Database sanitization.
"Sanitizing database."
Expand Down
11 changes: 5 additions & 6 deletions .vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ protected function subtestAhoyProvision(): void {
'ahoy provision',
[
'Provisioning site from the database dump file.',
"Running deployment operations via 'drush deploy:hook'.",
'Running database updates.',
'Running deployment hooks.',
],
'Initial provision should complete successfully'
);
Expand All @@ -230,8 +230,7 @@ protected function subtestAhoyProvision(): void {
'ahoy provision',
[
'* Provisioning site from the database dump file.',
// @note 'drush deploy:hook' runs only if config files exist.
"* Running deployment operations via 'drush deploy'.",
'* Importing configuration.',
'! Import the listed configuration changes',
'* There are no changes to import',
],
Expand All @@ -253,7 +252,7 @@ protected function subtestAhoyProvision(): void {
'ahoy provision',
[
'Provisioning site from the database dump file.',
"Running deployment operations via 'drush deploy'.",
'Importing configuration.',
'Import the listed configuration changes',
],
'Provision with updated config should complete successfully'
Expand All @@ -267,7 +266,7 @@ protected function subtestAhoyProvision(): void {
'ahoy provision',
[
'Provisioning site from the database dump file.',
"Running deployment operations via 'drush deploy'.",
'Importing configuration.',
],
'Provision without DB should complete successfully'
);
Expand Down Expand Up @@ -326,7 +325,7 @@ protected function subtestAhoyImportDb(string $filename = ''): void {
arg: $has_argument ? [$filename] : [],
out: [
'* Provisioning site from the database dump file.',
"! Running deployment operations via 'drush deploy:hook'.",
'! Running deployment hooks.',
'! Running database updates.',
],
txt: 'Import database dump ' . ($has_argument ? sprintf("from file '%s'", $filename) : 'from the default file')
Expand Down
Loading