Skip to content
New issue

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

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

Already on GitHub? # to your account

Array support for only #37

Merged
merged 1 commit into from
Aug 12, 2020
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
9 changes: 8 additions & 1 deletion src/Automate/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ private function addCommandsNode($name)
->end()
->children()
->scalarNode('cmd')->isRequired()->cannotBeEmpty()->end()
->scalarNode('only')->defaultNull()->end()
->arrayNode('only')
->defaultValue([])
->beforeNormalization()
->ifString()
->then(function ($v) { return [$v]; })
->end()
->scalarPrototype()->end()
->end()
->end()
->end()
;
Expand Down
4 changes: 2 additions & 2 deletions src/Automate/Context/AbstractContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ public function getReleaseId()
/**
* {@inheritdoc}
*/
public function run($command, $verbose = false, $specificServer = null, $addWorkingDir = true)
public function run($command, $verbose = false, $specificServers = null, $addWorkingDir = true)
{
$servers = $this->platform->getServers();

foreach ($servers as $server) {
if($specificServer && $server->getName() != $specificServer) {
if($specificServers && !in_array($server->getName(), $specificServers)) {
continue;
}
$this->logger->command($command, $verbose);
Expand Down
5 changes: 3 additions & 2 deletions src/Automate/Context/ContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ public function getReleaseId();
* @param string $command
*
* @param bool $verbose
* @param null $specificServer
* @param array|null $specificServers
* @param bool $addWorkingDir
* @return mixed
*/
public function run($command, $verbose = false, $specificServer = null);
public function run($command, $verbose = false, $specificServers = null, $addWorkingDir = true);

/**
* Run on server.
Expand Down
8 changes: 4 additions & 4 deletions src/Automate/Model/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Command
private $cmd;

/**
* @var string
* @var array
*/
private $only;

Expand All @@ -47,19 +47,19 @@ public function setCmd($cmd)
}

/**
* @return string
* @return array
*/
public function getOnly()
{
return $this->only;
}

/**
* @param string $only
* @param array $only
*
* @return Command
*/
public function setOnly($only)
public function setOnly(array $only)
{
$this->only = $only;

Expand Down
9 changes: 6 additions & 3 deletions tests/Automate/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ public function testLoader()
}

$this->assertEquals('php bin/console doctrine:cache:clear-metadata', $project->getPostDeploy()[0]->getCmd());
$this->assertEquals(null , $project->getPostDeploy()[0]->getOnly());
$this->assertEquals([] , $project->getPostDeploy()[0]->getOnly());

$this->assertEquals('php bin/console doctrine:schema:update --force', $project->getPostDeploy()[1]->getCmd());
$this->assertEquals('eddv-exemple-front-01' , $project->getPostDeploy()[1]->getOnly());
$this->assertEquals(['eddv-exemple-front-01'] , $project->getPostDeploy()[1]->getOnly());

$this->assertEquals('php bin/console doctrine:cache:clear-result', $project->getPostDeploy()[2]->getCmd());
$this->assertEquals(null , $project->getPostDeploy()[2]->getOnly());
$this->assertEquals([] , $project->getPostDeploy()[2]->getOnly());

$this->assertEquals('php bin/console messenger:consume', $project->getPostDeploy()[3]->getCmd());
$this->assertEquals(['eddv-exemple-front-01', 'dddv-exemple-front-01'] , $project->getPostDeploy()[3]->getOnly());

$this->assertCount(2, $project->getPlatforms());

Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ post_deploy:
- "php bin/console doctrine:cache:clear-metadata"
- cmd: "php bin/console doctrine:schema:update --force"
only: eddv-exemple-front-01
- "php bin/console doctrine:cache:clear-result"
- "php bin/console doctrine:cache:clear-result"
- cmd: "php bin/console messenger:consume"
only: ["eddv-exemple-front-01", "dddv-exemple-front-01"]