Browse Source

Allow Exclude to be defined globally.

pull/1/head
Andrés Montañez 8 years ago
parent
commit
0fe106610a
  1. 1
      CHANGELOG.md
  2. 2
      src/Task/BuiltIn/Deploy/RsyncTask.php
  3. 2
      src/Task/BuiltIn/Deploy/Tar/PrepareTask.php
  4. 30
      tests/Command/BuiltIn/DeployCommandMiscTasksTest.php
  5. 17
      tests/Resources/global-exclude.yml

1
CHANGELOG.md

@ -2,6 +2,7 @@ CHANGELOG for 3.X
================= =================
* 3.2.0 (2017-04-xx) * 3.2.0 (2017-04-xx)
* Allow to define excludes in the global scope.
* Improve code quality, remove duplications on Symfony Tasks. * Improve code quality, remove duplications on Symfony Tasks.
* Improve code quality, remove duplications on Composer Tasks. * Improve code quality, remove duplications on Composer Tasks.
* [PR#364] Allow to define custom timeout to Composer:Install * [PR#364] Allow to define custom timeout to Composer:Install

2
src/Task/BuiltIn/Deploy/RsyncTask.php

@ -54,7 +54,7 @@ class RsyncTask extends AbstractTask
protected function getExcludes() protected function getExcludes()
{ {
$excludes = $this->runtime->getEnvOption('exclude', []); $excludes = $this->runtime->getMergedOption('exclude', []);
$excludes = array_merge(['.git'], array_filter($excludes)); $excludes = array_merge(['.git'], array_filter($excludes));
foreach ($excludes as &$exclude) { foreach ($excludes as &$exclude) {

2
src/Task/BuiltIn/Deploy/Tar/PrepareTask.php

@ -51,7 +51,7 @@ class PrepareTask extends AbstractTask
protected function getExcludes() protected function getExcludes()
{ {
$excludes = $this->runtime->getEnvOption('exclude', []); $excludes = $this->runtime->getMergedOption('exclude', []);
$excludes = array_merge(['.git'], array_filter($excludes)); $excludes = array_merge(['.git'], array_filter($excludes));
foreach ($excludes as &$exclude) { foreach ($excludes as &$exclude) {

30
tests/Command/BuiltIn/DeployCommandMiscTasksTest.php

@ -80,6 +80,36 @@ class DeployCommandMiscTasksTest extends TestCase
$this->assertEquals(0, $tester->getStatusCode()); $this->assertEquals(0, $tester->getStatusCode());
} }
public function testGlobalExcludeFlags()
{
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/global-exclude.yml');
/** @var AbstractCommand $command */
$command = $application->find('deploy');
$this->assertTrue($command instanceof DeployCommand);
$tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$ranCommands = $application->getRuntime()->getRanCommands();
$testCase = array(
0 => '/usr/bin/composer.phar install --prefer-source',
1 => '/usr/bin/composer.phar dump-autoload --no-scripts',
2 => 'rsync -e "ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" -avz --exclude=.git --exclude=./var/cache/* --exclude=./var/log/* --exclude=./web/app_dev.php ./ tester@testhost:/var/www/test',
);
// Check total of Executed Commands
$this->assertEquals(count($testCase), count($ranCommands));
// Check Generated Commands
foreach ($testCase as $index => $command) {
$this->assertEquals($command, $ranCommands[$index]);
}
$this->assertEquals(0, $tester->getStatusCode());
}
public function testComposerEnvFlags() public function testComposerEnvFlags()
{ {
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer-env.yml'); $application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer-env.yml');

17
tests/Resources/global-exclude.yml

@ -0,0 +1,17 @@
magephp:
log_dir: /tmp
composer:
path: /usr/bin/composer.phar
exclude:
- ./var/cache/*
- ./var/log/*
- ./web/app_dev.php
environments:
test:
user: tester
host_path: /var/www/test
hosts:
- testhost
pre-deploy:
- composer/install: { flags: '--prefer-source' }
- composer/dump-autoload: { flags: '--no-scripts' }
Loading…
Cancel
Save