Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for config_split. #1102

Merged
merged 15 commits into from
Mar 21, 2017
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ script:
- source ${BLT_DIR}/scripts/blt/ci/internal/smoke_tests.sh
- source ${BLT_DIR}/scripts/blt/ci/internal/create_blt_project.sh
- source ${BLT_DIR}/scripts/travis/run_tests
# Test core cm.
- drush config-export --root=docroot -y
- yaml-cli update:value blt/project.yml cm.strategy core-only
- blt setup:config-import
# Test config split.
- drush en config_split --root=docroot -y
- drush config-export --root=docroot -y
- mv ${BLT_DIR}/scripts/blt/ci/internal/config_split.config_split.ci.yml config/default/
- yaml-cli update:value blt/project.yml cm.strategy config-split
- blt setup:config-import
# Run BLT Doctor.
- source ${BLT_DIR}/scripts/blt/ci/internal/doctor.sh
# Execute PHP Unit tests.
- phpunit ${BLT_DIR}/tests/phpunit --group blt-project -c ${BLT_DIR}/tests/phpunit/phpunit.xml
- phpunit ${BLT_DIR}/tests/phpunit --group blt-multisite -c ${BLT_DIR}/tests/phpunit/phpunit.xml
# Deploy build artifact.
Expand Down
3 changes: 2 additions & 1 deletion composer.required.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"require": {
"drupal/core": "^8.0",
"drupal/features": "^3.0.0",
"drush/drush": "^8.1.8"
"drupal/config_split": "^1.0.0-beta4",
"drush/drush": "^8.1.10"
},
"require-dev": {
"behat/behat": "^3.1",
Expand Down
3 changes: 2 additions & 1 deletion phing/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<echo level="verbose">Setting memory allocation to ${php.memory_limit}</echo>
<php expression="ini_set('memory_limit', '${php.memory_limit}');" level="verbose"/>

<!--@todo Warn if Windows is being used.-->
<!-- Add environment variables to "env." namespace. -->
<property environment="env" />

<!-- Include task partials -->

Expand Down
21 changes: 14 additions & 7 deletions phing/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,22 @@ composer:
bin: ${repo.root}/${bin.path}

cm:
# Possible values: core-only, config_split, features.
strategy: features
core:
config-dir:
# The parent directory for configuration directories.
path: ${repo.root}/config
# The default config key to use for imports. This is the key used in Drupal's global $config_directories variable.
# E.g., $config_directories['sync']. It must have a corresponding key in cm.core.dirs. E.g., `cm.core.dirs.sync`.
key: sync
# A different config key is used by the deploy:update step, which is executed on Acquia Cloud.
deploy-key: vcs
dirs:
# Corresponding values are defined in default.local.settings.php.
key: sync
path: ${repo.root}/config/default
# A different config key is used by the deploy:update step, which is executed on Acquia Cloud.
deploy-key: vcs
partial: true

sync:
path: ${cm.core.path}/default
features:
no-overrides: true

deploy:
# If true, dependencies will be built during deploy. If false, you should commit dependencies directly.
Expand Down
2 changes: 1 addition & 1 deletion phing/tasks/deploy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
<phingcall target="setup:update">
<!-- Drush fails to include some files. @see https://github.com/drush-ops/drush/issues/2497#issuecomment-279049111 -->
<property name="drush.bin" value="${drush.bin} --include=../drush" override="true" />
<!-- Environment parameter is used to determine which modules to toggle. On ACE, will be overridden by one of dev/stage/prod. -->
<!-- Environment parameter is used to determine which modules to toggle. On ACE, will be overridden by one of dev/stage/prod via cloud hooks. -->
<param name="environment" value="deploy"/>
<!-- Disable alias since we are targeting specific uri. -->
<property name="drush.alias" value=""/>
Expand Down
51 changes: 41 additions & 10 deletions phing/tasks/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@

<echo>Installing Drupal...</echo>
<if>
<equals arg1="${cm.core.partial}" arg2="true"/>
<!-- We do not define the config-dir option if features is being used. -->
<equals arg1="${cm.strategy}" arg2="features"/>
<then>
<drush command="site-install">
<option name="site-name">"${project.human_name}"</option>
Expand All @@ -195,7 +196,7 @@
<option name="account-pass">"${drupal.account.password}"</option>
<option name="account-mail">"${drupal.account.mail}"</option>
<option name="locale">"${drupal.locale}"</option>
<option name="config-dir">${cm.core.config-dir.path}</option>
<option name="config-dir">${cm.core.dirs.${cm.core.key}.path}</option>
<param>"${project.profile.name}"</param>
<param>"install_configure_form.update_status_module='array(FALSE,FALSE)'"</param>
</drush>
Expand Down Expand Up @@ -245,21 +246,49 @@
<option name="entity-updates"></option>
</drush>

<!-- Import configuration. -->
<!-- This will call one of the following:
setup:config-import:features
setup:config-import:core-only
setup:config-import:config-split
-->
<phingcall target="setup:config-import:${cm.strategy}"/>

<!-- Rebuild caches. -->
<drush command="cr" alias="${drush.alias}" passthru="false"/>
</target>

<target name="setup:config-import:core-only">
<drush command="config-import" assume="yes" alias="${drush.alias}" passthru="false">
<param>${cm.core.key}</param>
</drush>
</target>

<target name="setup:config-import:config-split">
<drush command="en" assume="yes" alias="${drush.alias}" passthru="false">
<param>config_split</param>
</drush>
<if>
<equals arg1="${cm.core.partial}" arg2="true"/>
<and>
<isset property="env.AH_SITE_ENVIRONMENT"/>
<available file="${cm.core.path}/${env.AH_SITE_ENVIRONMENT}"/>
</and>
<then>
<drush command="config-import" assume="yes" alias="${drush.alias}" passthru="false">
<option name="partial"></option>
<param>${cm.core.config-dir.key}</param>
<drush command="config-import" assume="yes" alias="${drush.alias}">
<!-- Cloud environments require vcs parameter. -->
<param>vcs</param>
</drush>
</then>
<else>
<drush command="config-import" assume="yes" alias="${drush.alias}" passthru="false">
<param>${cm.core.config-dir.key}</param>
</drush>
<drush command="config-import" assume="yes" alias="${drush.alias}"></drush>
</else>
</if>
</target>

<target name="setup:config-import:features">
<drush command="config-import" assume="yes" alias="${drush.alias}" passthru="false">
<option name="partial"></option>
<param>${cm.core.key}</param>
</drush>

<if>
<isset property="cm.features.bundle"/>
Expand All @@ -286,11 +315,13 @@
</if>
</then>
</if>

<!-- Rebuild caches. -->
<drush command="cr" alias="${drush.alias}" passthru="false"/>
<phingcall target="target-hook:invoke">
<property name="hook-name" value="post-config-import"/>
</phingcall>

</target>

<target name="setup:git-hooks" description="Installs git hooks to local .git/hooks directory from version controlled scripts/git-hooks directory.">
Expand Down
14 changes: 14 additions & 0 deletions scripts/blt/ci/internal/config_split.config_split.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: 439a15f4-c89c-4267-b673-f8855b5bb0bf
langcode: en
status: true
dependencies: { }
id: ci
label: CI
folder: ../config/ci
module: { }
theme: { }
blacklist: { }
graylist: { }
graylist_dependents: true
graylist_skip_equal: true
weight: 1
3 changes: 3 additions & 0 deletions settings/blt.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
// Includes caching configuration.
require __DIR__ . '/cache.settings.php';

// Includes configuratoin management settings.
require __DIR__ . '/config.settings.php';

// Includes logging configuration.
require __DIR__ . '/logging.settings.php';

Expand Down
25 changes: 25 additions & 0 deletions settings/config.settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

// Ensure the appropriate config split is enabled.
$config['config_split.config_split.local']['status'] = FALSE;
$config['config_split.config_split.dev']['status'] = FALSE;
$config['config_split.config_split.stage']['status'] = FALSE;
$config['config_split.config_split.prod']['status'] = FALSE;
$config['config_split.config_split.ci']['status'] = FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

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

@grasmash - There are no extra settings for RA (many subscriptions have an ra environment as well). Do you think that might be something to add? Or just note that people should add an ra-specific split in their own settings.php if they need it?

One other note—for my sites I'm currently using a test split (not stage) to match the fact that Acquia Cloud still uses test as the machine name for the Stage environment... for those projects who are already set up using this kind of naming convention, I'll try to document how to switch the split name correctly. Just wanted to put that out there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also using test (mainly because that's what canary does... I haven't tested to see how it works yet).

Besides RA, a project could have any number of custom environments (typically dev1, dev2, etc... but they could be named anything). I think it would be awesome if we could create this configuration automatically, or as part of a wizard (i.e. "here are the typical environments, do you have any others?"). Short of that, just documenting it would be good.

Copy link
Contributor

Choose a reason for hiding this comment

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

@danepowell - Also, ODE could throw a wrinkle depending on how you structure your config... it might be nice to say "any non-prod environment gets split xyz"...

Copy link
Contributor

Choose a reason for hiding this comment

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

Also see my notes-in-progress here: #965 (comment)

if ($is_local_env) {
if (getenv('TRAVIS')) {
$config['config_split.config_split.ci']['status'] = TRUE;
}
else {
$config['config_split.config_split.local']['status'] = TRUE;
}
}
elseif ($is_ah_dev_env) {
$config['config_split.config_split.dev']['status'] = TRUE;
}
elseif ($is_ah_stage_env) {
$config['config_split.config_split.stage']['status'] = TRUE;
}
elseif ($is_ah_prod_env) {
$config['config_split.config_split.prod']['status'] = TRUE;
}