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

Porting vm:* commands to Robo. #1337

Merged
merged 11 commits into from
Apr 10, 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ script:
- source ${BLT_DIR}/scripts/blt/ci/internal/create_blt_project.sh
- source ${BLT_DIR}/scripts/blt/ci/internal/run_tests.sh
# Add Drupal VM config to repo.
- blt vm -Dvm.boot='false'
- blt vm --no-boot --no-interaction --yes
# Execute PHP Unit tests.
- ./vendor/bin/phpunit ${BLT_DIR}/tests/phpunit --group blt-project -c ${BLT_DIR}/tests/phpunit/phpunit.xml
- ./vendor/bin/phpunit ${BLT_DIR}/tests/phpunit --group blt-multisite -c ${BLT_DIR}/tests/phpunit/phpunit.xml
Expand Down
5 changes: 4 additions & 1 deletion bin/blt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ $robo_commands = [
'tests:all',
'tests:behat',
'tests:phpunit',
'tests:security-updates'
'tests:security-updates',
'vm',
'vm:config',
'vm:nuke',
];

// Execute command via Robo.
Expand Down
3 changes: 0 additions & 3 deletions phing/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
<!-- Contains acsf tasks. -->
<import file="${phing.dir}/tasks/acsf.xml"/>

<!-- Contains Drupal VM tasks. -->
<import file="${phing.dir}/tasks/vm.xml"/>

<!-- Contains Drupal SimpleSAMLphp tasks. -->
<import file="${phing.dir}/tasks/simplesamlphp.xml"/>

Expand Down
1 change: 1 addition & 0 deletions phing/tasks/ci.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<target name="ci:pipelines:init" description="Initializes default Acquia Pipelines configuration for this project.">
<copy file="${blt.root}/scripts/pipelines/acquia-pipelines.yml" tofile="${repo.root}/acquia-pipelines.yml"/>
<echo>Acquia Pipelines requires PhantomJS in order to run Javascript Behat tests.</echo>
<!-- @todo replace this! -->
<phingcall target="tests:phantomjs:configure"/>
</target>

Expand Down
152 changes: 0 additions & 152 deletions phing/tasks/vm.xml

This file was deleted.

5 changes: 5 additions & 0 deletions src/Robo/Blt.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function __construct(
InputInterface $input = NULL,
OutputInterface $output = NULL
) {

$this->setConfig($config);
$application = new Application('BLT', $config->get('version'));
$container = Robo::createDefaultContainer($input, $output, $application,
Expand Down Expand Up @@ -144,6 +145,10 @@ private function getHooks(
private function addDefaultArgumentsAndOptions(Application $app) {
$app->getDefinition()->addOption(new InputOption('--yes', '-y',
InputOption::VALUE_NONE, 'Answer all confirmations with "yes"'));
$app->getDefinition()
->addOption(
new InputOption('--define', '-D', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Define a configuration item value.', [])
);
}

/**
Expand Down
55 changes: 55 additions & 0 deletions src/Robo/BltTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Robo\Contract\ConfigAwareInterface;
use Robo\Tasks;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand All @@ -24,6 +25,60 @@ class BltTasks extends Tasks implements ConfigAwareInterface, InspectorAwareInte
use IO;
use LoggerAwareTrait;

/**
*
*/
protected function initialize() {

}

/**
* Invokes an array of Symfony commands.
*
* @param array $commands
* An array of Symfony commands to invoke. E.g., 'tests:behat'.
*
* @return int
* The exit code of the command.
*/
public function invokeCommands(array $commands) {
foreach ($commands as $command) {
$returnCode = $this->invokeCommand($command);
// Return if this is non-zero exit code.
if ($returnCode) {
return $returnCode;
}
}
}

/**
* Invokes a single Symfony command.
*
* @param string $command_name
* The name of the command. E.g., 'tests:behat'.
*
* @return int
* The exit code of the command.
*/
public function invokeCommand($command_name) {
/** @var \Robo\Application $application */
$application = $this->getContainer()->get('application');
$command = $application->find($command_name);
$args = [];
$input = new ArrayInput($args);
$this->output->writeln("<comment>$command_name ></comment>");
$returnCode = $command->run($input, $this->output());
$this->output->writeln("");

return $returnCode;
}


/**
* @param $array
* @param string $prefix
* @param int $verbosity
*/
protected function logConfig($array, $prefix = '', $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE) {
if ($this->output()->getVerbosity() >= $verbosity) {
if ($prefix) {
Expand Down
24 changes: 24 additions & 0 deletions src/Robo/Commands/Setup/SettingsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Acquia\Blt\Robo\Commands\Vm;

use Acquia\Blt\Robo\BltTasks;
use Robo\Contract\VerbosityThresholdInterface;

/**
* Defines commands in the "setup:settings" namespace.
*/
class SettingsCommand extends BltTasks {

/**
* @command setup:settings
*/
public function generateDefaultSettingsFiles() {
$this->taskFilesystemStack()
->copy($this->getConfigValue('repo.root') . '/blt/example.project.local.yml', $this->getConfigValue('repo.root') . '/blt/project.local.yml')
->stopOnFail()
->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();
}

}
39 changes: 0 additions & 39 deletions src/Robo/Commands/Tests/AllCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Acquia\Blt\Robo\Commands\Tests;

use Acquia\Blt\Robo\BltTasks;
use Symfony\Component\Console\Input\ArrayInput;

/**
* Defines commands in the "tests" namespace.
Expand All @@ -23,42 +22,4 @@ public function tests() {
]);
}

/**
* Invokes an array of Symfony commands.
*
* @return int
* The exit code of the command.
*/
public function invokeCommands($commands) {
foreach ($commands as $command) {
$returnCode = $this->invokeCommand($command);
// Return if this is non-zero exit code.
if ($returnCode) {
return $returnCode;
}
}
}

/**
* Invokes a single Symfony command.
*
* @param string $command_name
* The name of the command. E.g., 'tests:behat'.
*
* @return int
* The exit code of the command.
*/
public function invokeCommand($command_name) {
/** @var \Robo\Application $application */
$application = $this->getContainer()->get('application');
$command = $application->find($command_name);
$args = [];
$input = new ArrayInput($args);
$this->output->writeln("<comment>$command_name ></comment>");
$returnCode = $command->run($input, $this->output());
$this->output->writeln("");

return $returnCode;
}

}
2 changes: 2 additions & 0 deletions src/Robo/Commands/Tests/BehatCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class BehatCommand extends TestsCommandBase {
* @hook init
*/
public function initialize() {
parent::initialize();

$this->seleniumLogFile = $this->getConfigValue('reports.localDir') . "/selenium2.log";
$this->seleniumUrl = "http://127.0.0.1:4444/wd/hub";
}
Expand Down
2 changes: 2 additions & 0 deletions src/Robo/Commands/Tests/PhpUnitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class PhpUnitCommand extends BltTasks {
* @hook init
*/
public function initialize() {
parent::initialize();

$this->reportsDir = $this->getConfigValue('reports.localDir') . '/phpunit';
$this->reportFile = $this->reportsDir . '/results.xml';
$this->testsDir = $this->getConfigValue('repo.root') . '/tests/phpunit';
Expand Down
Loading