Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Fixes #1004: Configurable test steps for fresh installs and live dbs. #1818

Merged
merged 1 commit into from
Jul 19, 2017
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
5 changes: 5 additions & 0 deletions bin/blt-robo-run.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
$processor->extend($loader->load($config->get('blt.root') . '/config/build.yml'));
$processor->extend($loader->load($config->get('repo.root') . '/blt/project.yml'));
$processor->extend($loader->load($config->get('repo.root') . '/blt/project.local.yml'));

if ($input->hasArgument('environment')) {
$processor->extend($loader->load($config->get('repo.root') . '/blt/' . $input->getArgument('environment') . '.yml'));
}

$config->import($processor->export());
$config->populateHelperConfig();

Expand Down
14 changes: 9 additions & 5 deletions config/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ deploy:
failOnDirty: true

# File and Directory locations.
docroot.relative: ${repo.root.relative}/docroot
docroot: ${repo.root}/docroot

# Drupal Account Credentials. These are used for installing Drupal.
Expand Down Expand Up @@ -116,8 +115,6 @@ phpcs:
- files.php.tests
- files.php.custom.themes
- files.frontend.custom.themes
haltonerror: true
haltonwarning: true

#$ @todo Move to subkey of fix.
phpcbf:
Expand All @@ -140,9 +137,16 @@ project:
local:
uri: ${project.local.protocol}://${project.local.hostname}

setup:
# Valid values are install, sync, import.
strategy: install
sync: false
# If setup.strategy is import, this file will be imported.
dump-file: null

sync:
# By default, files are not synced during local:sync.
# Set this value to 'true' or pass -Dsync.files=true
# By default, files are not synced during sync:refresh.
# Set this value to 'true' or pass -D sync.files=true
# to override this behavior.
files: false

Expand Down
44 changes: 32 additions & 12 deletions readme/extending-blt.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ To replace a BLT command with your own custom version, implement the [replace co

Please note that when you do this, you take responsibility for maintaining your custom command. Your command may break when changes are made to the upstream version of the command in BLT itself.

## Overriding a variable value:

You can override the value of any configuration variable used by BLT by either:

1. Adding the variable to your project.yml file:

behat.tags: @mytags

2. Specifying the variable value in your `blt` command using argument syntax `-D [key]=[value]`, e.g.,

blt tests:behat -D behat.tags='@mytags'

## Disabling a command

You may disable any BLT command. This will cause the target to be skipped during the normal build process. To disable a target, add a `disable-targets` key to your project.yml file:
Expand Down Expand Up @@ -70,6 +58,38 @@ This snippet would cause the `validate:phpcs` target to be skipped during BLT bu

BLT configuration can be customized by overriding the value of default variable values. You can find the default value of any BLT variable in [build.yml](https://github.com/acquia/blt/blob/8.x/config/build.yml).

### Overriding a variable value:

Configuration values are loaded, in this order, from the following list of YAML files:

- blt/project.yml
- blt/[environment].yml
- blt/project.local.yml

Values loaded from the later files will overwrite values in earlier files.

### Overriding project-wide

You can override any variable value by adding an entry for that variable to your `project.yml` file. This change will be committed to your repository and shared by all developers for the project. For example:

behat.tags: @mytags

### Overriding locally

You can override a variable value for your local machine by adding an entry for that variable to your `project.local.yml file`. This change will not be committed to your repository.

### Overriding in specific environments

You may override a variable value for specific environments, such as a the `ci` environment, by adding an entry for that variable to a file named in the pattern [environment].yml. For instance, ci.yml.

At present, only the CI environment is automatically detected.

### Overriding at runtime

You may overwrite a variable value at runtime by specifying the variable value in your `blt` command using argument syntax `-D [key]=[value]`, e.g.,

blt tests:behat -D behat.tags='@mytags'

Listed below are some of the more commonly customized BLT targets.

### deploy:*
Expand Down
3 changes: 2 additions & 1 deletion src/Robo/Commands/Blt/ConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class ConfigCommand extends BltTasks {
*
* @command config:get
*
* @param string $key The key for the configuration item to get.
* @param string $key
* The key for the configuration item to get.
*
* @throws \Acquia\Blt\Robo\Exceptions\BltException
*/
Expand Down
48 changes: 48 additions & 0 deletions src/Robo/Commands/Setup/AllCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Acquia\Blt\Robo\Commands\Setup;

use Acquia\Blt\Robo\BltTasks;

/**
* Defines commands in the "setup:all" namespace.
*/
class AllCommand extends BltTasks {

/**
* Install dependencies, builds docroot, installs Drupal.
*
* @command setup
*
* @aliases setup:all
*/
public function setup() {
$this->say("Setting up local environment for site '{$this->getConfigValue('site')}' using drush alias @{$this->getConfigValue('drush.alias')}");

$commands = [
'setup:build',
'setup:hash-salt',
];

switch ($this->getConfigValue('setup.strategy')) {
case 'install':
$commands[] = 'setup:drupal:install';
break;

case 'sync':
$commands[] = 'setup:refresh';
break;

case 'import':
$commands[] = 'setup:import';
$commands[] = 'setup:update';
break;
}

$commands[] = 'setup:toggle-modules';
$commands[] = 'install-alias';

$this->invokeCommands($commands);
}

}
30 changes: 30 additions & 0 deletions src/Robo/Commands/Setup/ImportCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Acquia\Blt\Robo\Commands\Sync;

use Acquia\Blt\Robo\BltTasks;
use Acquia\Blt\Robo\Exceptions\BltException;

/**
* Defines commands in the "setup:import" namespace.
*/
class ImportCommand extends BltTasks {

/**
* Imports a .sql file into the Drupal database.
*
* @command setup:import
*/
public function import() {
$task = $this->taskDrush()
->drush('sql-drop')
->drush('sql-cli < ' . $this->getConfigValue('setup.dump-file'));
$result = $task->run();
$exit_code = $result->getExitCode();

if ($exit_code) {
throw new BltException("Unable to import setup.dump-file.");
}
}

}
1 change: 0 additions & 1 deletion src/Robo/Commands/Vm/VmCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ protected function requireDrupalVm() {
*
* @return bool
* TRUE if it is present already and matches version constraint.
*
*/
protected function isDrupalVmRequired() {
$composer_json = json_decode($this->getConfigValue('repo.root') . '/composer.json', TRUE);
Expand Down
4 changes: 4 additions & 0 deletions src/Robo/Inspector/Inspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ protected function setDrupalVmStatus() {

/**
* Gets the Operating system type.
*
* @return int
*/
public function isOsx() {
Expand All @@ -661,6 +662,9 @@ public function getCurrentSchemaVersion() {
return $version;
}

/**
*
*/
public function isSchemaVersionUpToDate() {
return $this->getCurrentSchemaVersion() == $this->getContainer()->get('updater')->getLatestUpdateMethodVersion();
}
Expand Down
3 changes: 3 additions & 0 deletions template/blt/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# If false, the setup task will re-install Drupal. If true, it will call
# the sync command and copy a db from @drush.aliases.remote.
# setup.strategy: sync