diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0ac02e2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,68 @@ +Contributor Guidelines for Magallanes +===================================== +Welcome to Magallanes! We are much appreciated you've decided to contribute to this project! +Please read the following guidelines to make your and our work easier and cleaner. + +**TL;DR** + +1. Write clean code with no mess left +2. Contribute the docs when adding configurable new feature +3. Create your pull request from `nostromo` branch +4. Ensure your code is fully covered by tests + +---------- + +# Reporting Issues +If you have a problem or you've noticed a bug, please feel free to open a new issue. However follow the rules below: +* First, make sure that similar/the same issue doesn't already exists +* If you've already found the solution of the problem you are about to report, please feel free to open a new Pull Request. Then follow the rules below in **Developing Magallanes** section. +* If you are able to, include some test cases or steps to reproduce the bug for us to examine the problem and find a solution. + +## Opening Pull Requests +Pull Request is a very powerful tool, so let's be measured in its usage. Always commit code which has at least 95% of coverage, and if it's a new feature always provide concrete tests. +In order to have the PRs prioritized name them with the following tags. + +``` +[#66] Add new CONTRIBUTING document +[FIX] Set correct permissions on deploy stage +[FEATURE] Create new PermissionsTask +[HOTFIX] Exception not caught on deployment +``` +All Pull Requests must be done to the `nostromo` branch, only exception are Hotfixes. +Remember of square brackets when adding issue number. If you'd forget adding them, your whole message will be a comment! + +# Developing Magallanes +## Branches +The flow is pretty simple. +In most common cases we work on the `nostromo` branch. It's the branch with the main development for the current major version. All Pull Requests must merge with that branch. The `master` branch is used to move the validated code and generate the releases in an orderly fashion, also we could use it for hotfixes. + +If you want to use developing branch in your code, simple pass `dev-nostromo` to dependency version in your `composer.json` file: +```json +{ + "require": { + "andres-montanez/magallanes": "dev-nostromo" + } +} +``` + +## Organization and code quality +We use [PSR2](http://www.php-fig.org/psr/psr-2/) as PHP coding standard. + +### Tools you can use to ensure your code quality + +1. **PHP-CodeSniffer** +2. **PHP Mess Detector** +3. PHP Copy/Paste Detector +4. PHP Dead Code Detector +5. [PHP Coding Standards Fixer](http://cs.sensiolabs.org) + +## Testing and quality +We use PHPUnit to test our code. Most of the project is covered with tests, so if you want your code to be merged push it with proper testing and coverage (at least 95%). To execute the tests with code coverage report: +``` +vendor/bin/phpunit --coverage-text +``` + +Tests structure follow almost the same structure as production code with `Test` suffix in class and file name. Follow the tests already made as guidelines. + +# Last Words +Thank you for using Magallanes, and special thanks for making it better. When adding features always have in mind the main goal *Deploy code from A to B, and run some tasks*, and think if the feature is aiming at that. \ No newline at end of file diff --git a/src/Mage/Task/BuiltIn/Composer/GenerateAutoloadTask.php b/src/Mage/Task/BuiltIn/Composer/DumpAutoloadTask.php similarity index 79% rename from src/Mage/Task/BuiltIn/Composer/GenerateAutoloadTask.php rename to src/Mage/Task/BuiltIn/Composer/DumpAutoloadTask.php index 042411b..f290800 100644 --- a/src/Mage/Task/BuiltIn/Composer/GenerateAutoloadTask.php +++ b/src/Mage/Task/BuiltIn/Composer/DumpAutoloadTask.php @@ -18,25 +18,25 @@ use Mage\Task\AbstractTask; * * @author Andrés Montañez */ -class GenerateAutoloadTask extends AbstractTask +class DumpAutoloadTask extends AbstractTask { public function getName() { - return 'composer/generate-autoload'; + return 'composer/dump-autoload'; } public function getDescription() { - return '[Composer] Generate Autoload'; + return '[Composer] Dump Autoload'; } public function execute() { $options = $this->getOptions(); - $command = $options['path'] . ' dumpautoload ' . $options['flags']; + $command = sprintf('%s dump-autoload %s', $options['path'], $options['flags']); /** @var Process $process */ - $process = $this->runtime->runCommand($command); + $process = $this->runtime->runCommand(trim($command)); return $process->isSuccessful(); } diff --git a/src/Mage/Task/BuiltIn/Composer/InstallTask.php b/src/Mage/Task/BuiltIn/Composer/InstallTask.php index 37d8723..4ecb1e3 100644 --- a/src/Mage/Task/BuiltIn/Composer/InstallTask.php +++ b/src/Mage/Task/BuiltIn/Composer/InstallTask.php @@ -33,10 +33,10 @@ class InstallTask extends AbstractTask public function execute() { $options = $this->getOptions(); - $command = trim($options['path'] . ' install ' . $options['flags']); + $command = sprintf('%s install %s', $options['path'], $options['flags']); /** @var Process $process */ - $process = $this->runtime->runCommand($command); + $process = $this->runtime->runCommand(trim($command)); return $process->isSuccessful(); } @@ -45,7 +45,7 @@ class InstallTask extends AbstractTask { $userOptions = $this->runtime->getConfigOptions('composer', []); $options = array_merge( - ['path' => 'composer', 'flags' => ''], + ['path' => 'composer', 'flags' => '--optimize-autoloader'], (is_array($userOptions) ? $userOptions : []), $this->options ); diff --git a/src/Mage/Task/BuiltIn/Symfony/AsseticDumpTask.php b/src/Mage/Task/BuiltIn/Symfony/AsseticDumpTask.php index 0ec55a9..471a8af 100644 --- a/src/Mage/Task/BuiltIn/Symfony/AsseticDumpTask.php +++ b/src/Mage/Task/BuiltIn/Symfony/AsseticDumpTask.php @@ -33,20 +33,22 @@ class AsseticDumpTask extends AbstractTask public function execute() { $options = $this->getOptions(); - $command = $options['console'] . ' assetic:dump --env=' . $options['env'] . ' ' . $options['flags']; + $command = sprintf('%s assetic:dump --env=%s %s', $options['console'], $options['env'], $options['flags']); /** @var Process $process */ - $process = $this->runtime->runCommand($command); + $process = $this->runtime->runCommand(trim($command)); return $process->isSuccessful(); } protected function getOptions() { - $userOptions = $this->runtime->getConfigOptions('symfony', []); + $userGlobalOptions = $this->runtime->getConfigOptions('symfony', []); + $userEnvironmentOptions = $this->runtime->getEnvironmentConfig('symfony', []); $options = array_merge( ['console' => 'bin/console', 'env' => 'dev', 'flags' => ''], - (is_array($userOptions) ? $userOptions : []), + (is_array($userGlobalOptions) ? $userGlobalOptions : []), + (is_array($userEnvironmentOptions) ? $userEnvironmentOptions : []), $this->options ); diff --git a/src/Mage/Task/BuiltIn/Symfony/AssetsInstallTask.php b/src/Mage/Task/BuiltIn/Symfony/AssetsInstallTask.php index 70de880..7506aca 100644 --- a/src/Mage/Task/BuiltIn/Symfony/AssetsInstallTask.php +++ b/src/Mage/Task/BuiltIn/Symfony/AssetsInstallTask.php @@ -33,20 +33,22 @@ class AssetsInstallTask extends AbstractTask public function execute() { $options = $this->getOptions(); - $command = $options['console'] . ' assets:install --env=' . $options['env'] . ' ' . $options['flags'] . ' ' . $options['target']; + $command = sprintf('%s assets:install %s --env=%s %s', $options['console'], $options['target'], $options['env'], $options['flags']); /** @var Process $process */ - $process = $this->runtime->runCommand($command); + $process = $this->runtime->runCommand(trim($command)); return $process->isSuccessful(); } protected function getOptions() { - $userOptions = $this->runtime->getConfigOptions('symfony', []); + $userGlobalOptions = $this->runtime->getConfigOptions('symfony', []); + $userEnvironmentOptions = $this->runtime->getEnvironmentConfig('symfony', []); $options = array_merge( ['console' => 'bin/console', 'env' => 'dev', 'target' => 'web', 'flags' => '--symlink --relative'], - (is_array($userOptions) ? $userOptions : []), + (is_array($userGlobalOptions) ? $userGlobalOptions : []), + (is_array($userEnvironmentOptions) ? $userEnvironmentOptions : []), $this->options ); diff --git a/src/Mage/Task/BuiltIn/Symfony/CacheClearTask.php b/src/Mage/Task/BuiltIn/Symfony/CacheClearTask.php index ac21018..d712958 100644 --- a/src/Mage/Task/BuiltIn/Symfony/CacheClearTask.php +++ b/src/Mage/Task/BuiltIn/Symfony/CacheClearTask.php @@ -36,17 +36,19 @@ class CacheClearTask extends AbstractTask $command = $options['console'] . ' cache:clear --env=' . $options['env'] . ' ' . $options['flags']; /** @var Process $process */ - $process = $this->runtime->runCommand($command); + $process = $this->runtime->runCommand(trim($command)); return $process->isSuccessful(); } protected function getOptions() { - $userOptions = $this->runtime->getConfigOptions('symfony', []); + $userGlobalOptions = $this->runtime->getConfigOptions('symfony', []); + $userEnvironmentOptions = $this->runtime->getEnvironmentConfig('symfony', []); $options = array_merge( ['console' => 'bin/console', 'env' => 'dev', 'flags' => ''], - (is_array($userOptions) ? $userOptions : []), + (is_array($userGlobalOptions) ? $userGlobalOptions : []), + (is_array($userEnvironmentOptions) ? $userEnvironmentOptions : []), $this->options ); diff --git a/src/Mage/Task/BuiltIn/Symfony/CacheWarmupTask.php b/src/Mage/Task/BuiltIn/Symfony/CacheWarmupTask.php index 4fe2ed4..bdea5ca 100644 --- a/src/Mage/Task/BuiltIn/Symfony/CacheWarmupTask.php +++ b/src/Mage/Task/BuiltIn/Symfony/CacheWarmupTask.php @@ -36,17 +36,19 @@ class CacheWarmupTask extends AbstractTask $command = $options['console'] . ' cache:warmup --env=' . $options['env'] . ' ' . $options['flags']; /** @var Process $process */ - $process = $this->runtime->runCommand($command); + $process = $this->runtime->runCommand(trim($command)); return $process->isSuccessful(); } protected function getOptions() { - $userOptions = $this->runtime->getConfigOptions('symfony', []); + $userGlobalOptions = $this->runtime->getConfigOptions('symfony', []); + $userEnvironmentOptions = $this->runtime->getEnvironmentConfig('symfony', []); $options = array_merge( ['console' => 'bin/console', 'env' => 'dev', 'flags' => ''], - (is_array($userOptions) ? $userOptions : []), + (is_array($userGlobalOptions) ? $userGlobalOptions : []), + (is_array($userEnvironmentOptions) ? $userEnvironmentOptions : []), $this->options ); diff --git a/src/Mage/Tests/Command/BuiltIn/DeployCommandMiscTasksTest.php b/src/Mage/Tests/Command/BuiltIn/DeployCommandMiscTasksTest.php new file mode 100644 index 0000000..9f88af6 --- /dev/null +++ b/src/Mage/Tests/Command/BuiltIn/DeployCommandMiscTasksTest.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Mage\Tests\Command\BuiltIn; + +use Mage\Command\BuiltIn\DeployCommand; +use Mage\Tests\MageApplicationMockup; +use Mage\Command\AbstractCommand; +use Mage\Runtime\Exception\RuntimeException; +use Exception; +use Symfony\Component\Console\Tester\CommandTester; +use PHPUnit_Framework_TestCase as TestCase; + +class DeployCommandMiscTasksTest extends TestCase +{ + public function testSymfonyEnvironmentConfiguration() + { + $application = new MageApplicationMockup(); + $application->configure(__DIR__ . '/../../Resources/symfony-envconf.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 => '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', + 1 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console cache:warmup --env=testenv\\"', + 2 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assets:install web --env=testenv --symlink --relative\\"', + 3 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assetic:dump --env=testenv\\"', + 4 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assetic:dump --env=prod\\"', + ); + + // 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 testComposerFlags() + { + $application = new MageApplicationMockup(); + $application->configure(__DIR__ . '/../../Resources/composer.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 testInvalidTaskName() + { + $application = new MageApplicationMockup(); + $application->configure(__DIR__ . '/../../Resources/invalid-task.yml'); + + /** @var AbstractCommand $command */ + $command = $application->find('deploy'); + $this->assertTrue($command instanceof DeployCommand); + + try { + $tester = new CommandTester($command); + $tester->execute(['command' => $command->getName(), 'environment' => 'test']); + } catch (Exception $exception) { + $this->assertTrue($exception instanceof RuntimeException); + $this->assertEquals('Invalid task name "invalid/task"', $exception->getMessage()); + } + } +} diff --git a/src/Mage/Tests/Command/BuiltIn/DeployCommandMiscTest.php b/src/Mage/Tests/Command/BuiltIn/DeployCommandMiscTest.php index 6223d3f..940ca3d 100644 --- a/src/Mage/Tests/Command/BuiltIn/DeployCommandMiscTest.php +++ b/src/Mage/Tests/Command/BuiltIn/DeployCommandMiscTest.php @@ -36,13 +36,13 @@ class DeployCommandMiscTest extends TestCase 0 => 'git branch | grep "*"', 1 => 'git checkout test', 2 => 'git pull', - 3 => 'composer install', - 4 => 'composer dumpautoload --optimize', + 3 => 'composer install --optimize-autoloader', + 4 => 'composer dump-autoload --optimize', 5 => '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', - 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& sudo bin/console cache:clear --env=dev \\"', - 7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& sudo bin/console cache:warmup --env=dev \\"', - 8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& sudo bin/console assets:install --env=dev --symlink --relative web\\"', - 9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& sudo bin/console assetic:dump --env=dev \\"', + 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& sudo bin/console cache:clear --env=dev\\"', + 7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& sudo bin/console cache:warmup --env=dev\\"', + 8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& sudo bin/console assets:install web --env=dev --symlink --relative\\"', + 9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& sudo bin/console assetic:dump --env=dev\\"', 10 => 'git checkout master', ); @@ -75,12 +75,12 @@ class DeployCommandMiscTest extends TestCase 0 => 'git branch | grep "*"', 1 => 'git checkout maintenance', 2 => 'git pull', - 3 => 'composer install', - 4 => 'composer dumpautoload --optimize', + 3 => 'composer install --optimize-autoloader', + 4 => 'composer dump-autoload --optimize', 5 => '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', - 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console cache:warmup --env=dev \\"', - 7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assets:install --env=dev --symlink --relative web\\"', - 8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assetic:dump --env=dev \\"', + 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console cache:warmup --env=dev\\"', + 7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assets:install web --env=dev --symlink --relative\\"', + 8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assetic:dump --env=dev\\"', 9 => 'git checkout master', ); @@ -111,8 +111,8 @@ class DeployCommandMiscTest extends TestCase $ranCommands = $application->getRuntime()->getRanCommands(); $testCase = array( - 0 => 'composer install', - 1 => 'composer dumpautoload --optimize', + 0 => 'composer install --optimize-autoloader', + 1 => 'composer dump-autoload --optimize', 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', ); @@ -149,8 +149,8 @@ class DeployCommandMiscTest extends TestCase 0 => 'git branch | grep "*"', 1 => 'git checkout test', 2 => 'git pull', - 3 => 'composer install', - 4 => 'composer dumpautoload --optimize', + 3 => 'composer install --optimize-autoloader', + 4 => 'composer dump-autoload --optimize', 5 => 'tar cfz /tmp/mageXYZ --exclude=".git" --exclude="./var/cache/*" --exclude="./var/log/*" --exclude="./web/app_dev.php" ./', 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"mkdir -p /var/www/test/releases/1234567890\\"', 7 => 'scp -P 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/mageXYZ tester@testhost:/var/www/test/releases/1234567890/mageXYZ', @@ -189,8 +189,8 @@ class DeployCommandMiscTest extends TestCase 0 => 'git branch | grep "*"', 1 => 'git checkout test', 2 => 'git pull', - 3 => 'composer install', - 4 => 'composer dumpautoload --optimize', + 3 => 'composer install --optimize-autoloader', + 4 => 'composer dump-autoload --optimize', 5 => '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', 6 => 'git checkout master', ); @@ -225,12 +225,12 @@ class DeployCommandMiscTest extends TestCase $testCase = array( 0 => 'git branch | grep "*"', 1 => 'git pull', - 2 => 'composer install', - 3 => 'composer dumpautoload --optimize', + 2 => 'composer install --optimize-autoloader', + 3 => 'composer dump-autoload --optimize', 4 => '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', - 5 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console cache:warmup --env=dev \\"', - 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assets:install --env=dev --symlink --relative web\\"', - 7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assetic:dump --env=dev \\"', + 5 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console cache:warmup --env=dev\\"', + 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assets:install web --env=dev --symlink --relative\\"', + 7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assetic:dump --env=dev\\"', 8 => 'git branch | grep "*"', ); diff --git a/src/Mage/Tests/Command/BuiltIn/DeployCommandWithReleasesTest.php b/src/Mage/Tests/Command/BuiltIn/DeployCommandWithReleasesTest.php index e643d69..eb6e1fe 100644 --- a/src/Mage/Tests/Command/BuiltIn/DeployCommandWithReleasesTest.php +++ b/src/Mage/Tests/Command/BuiltIn/DeployCommandWithReleasesTest.php @@ -38,16 +38,16 @@ class DeployCommandWithReleasesTest extends TestCase 0 => 'git branch | grep "*"', 1 => 'git checkout test', 2 => 'git pull', - 3 => 'composer install', - 4 => 'composer dumpautoload --optimize', + 3 => 'composer install --optimize-autoloader', + 4 => 'composer dump-autoload --optimize', 5 => 'tar cfz /tmp/mageXYZ --exclude=".git" --exclude="./var/cache/*" --exclude="./var/log/*" --exclude="./web/app_dev.php" ./', 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"mkdir -p /var/www/test/releases/1234567890\\"', 7 => 'scp -P 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/mageXYZ tester@testhost:/var/www/test/releases/1234567890/mageXYZ', 8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test/releases/1234567890 \\&\\& tar xfz mageXYZ\\"', 9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"rm /var/www/test/releases/1234567890/mageXYZ\\"', - 10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test/releases/1234567890 \\&\\& bin/console cache:warmup --env=dev \\"', - 11 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test/releases/1234567890 \\&\\& bin/console assets:install --env=dev --symlink --relative web\\"', - 12 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test/releases/1234567890 \\&\\& bin/console assetic:dump --env=dev \\"', + 10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test/releases/1234567890 \\&\\& bin/console cache:warmup --env=dev\\"', + 11 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test/releases/1234567890 \\&\\& bin/console assets:install web --env=dev --symlink --relative\\"', + 12 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test/releases/1234567890 \\&\\& bin/console assetic:dump --env=dev\\"', 13 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& ln -snf releases/1234567890 current\\"', 14 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"ls -1 /var/www/test/releases\\"', 15 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"rm -rf /var/www/test/releases/20170101015110\\"', diff --git a/src/Mage/Tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php b/src/Mage/Tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php index a7c0913..3c74a32 100644 --- a/src/Mage/Tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php +++ b/src/Mage/Tests/Command/BuiltIn/DeployCommandWithoutReleasesTest.php @@ -36,12 +36,12 @@ class DeployCommandWithoutReleasesTest extends TestCase 0 => 'git branch | grep "*"', 1 => 'git checkout test', 2 => 'git pull', - 3 => 'composer install', - 4 => 'composer dumpautoload --optimize', + 3 => 'composer install --optimize-autoloader', + 4 => 'composer dump-autoload --optimize', 5 => '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', - 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console cache:warmup --env=dev \\"', - 7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assets:install --env=dev --symlink --relative web\\"', - 8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assetic:dump --env=dev \\"', + 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console cache:warmup --env=dev\\"', + 7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assets:install web --env=dev --symlink --relative\\"', + 8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost sh -c \\"cd /var/www/test \\&\\& bin/console assetic:dump --env=dev\\"', 9 => 'git checkout master', ); diff --git a/src/Mage/Tests/Resources/basic.yml b/src/Mage/Tests/Resources/basic.yml index dd4cd8e..a916c32 100644 --- a/src/Mage/Tests/Resources/basic.yml +++ b/src/Mage/Tests/Resources/basic.yml @@ -17,7 +17,7 @@ magephp: pre-deploy: - git/update - composer/install - - composer/generate-autoload + - composer/dump-autoload on-deploy: - symfony/cache-warmup: { env: 'dev' } - symfony/assets-install: { env: 'dev' } diff --git a/src/Mage/Tests/Resources/composer.yml b/src/Mage/Tests/Resources/composer.yml new file mode 100644 index 0000000..f8f1bff --- /dev/null +++ b/src/Mage/Tests/Resources/composer.yml @@ -0,0 +1,17 @@ +magephp: + log_dir: /tmp + composer: + path: /usr/bin/composer.phar + environments: + test: + user: tester + host_path: /var/www/test + exclude: + - ./var/cache/* + - ./var/log/* + - ./web/app_dev.php + hosts: + - testhost + pre-deploy: + - composer/install: { flags: '--prefer-source' } + - composer/dump-autoload: { flags: '--no-scripts' } diff --git a/src/Mage/Tests/Resources/invalid-task.yml b/src/Mage/Tests/Resources/invalid-task.yml new file mode 100644 index 0000000..57dd007 --- /dev/null +++ b/src/Mage/Tests/Resources/invalid-task.yml @@ -0,0 +1,14 @@ +magephp: + log_dir: /tmp + environments: + test: + user: tester + host_path: /var/www/test + exclude: + - ./var/cache/* + - ./var/log/* + - ./web/app_dev.php + hosts: + - testhost + pre-deploy: + - invalid/task diff --git a/src/Mage/Tests/Resources/symfony-envconf.yml b/src/Mage/Tests/Resources/symfony-envconf.yml new file mode 100644 index 0000000..d9c239f --- /dev/null +++ b/src/Mage/Tests/Resources/symfony-envconf.yml @@ -0,0 +1,18 @@ +magephp: + log_dir: /tmp + environments: + test: + symfony: { env: 'testenv' } + user: tester + host_path: /var/www/test + exclude: + - ./var/cache/* + - ./var/log/* + - ./web/app_dev.php + hosts: + - testhost + on-deploy: + - symfony/cache-warmup + - symfony/assets-install + - symfony/assetic-dump + - symfony/assetic-dump: { env: 'prod' } diff --git a/src/Mage/Tests/Resources/testhost-custom-task.yml b/src/Mage/Tests/Resources/testhost-custom-task.yml index 6ca959a..8253e17 100644 --- a/src/Mage/Tests/Resources/testhost-custom-task.yml +++ b/src/Mage/Tests/Resources/testhost-custom-task.yml @@ -12,7 +12,7 @@ magephp: - testhost pre-deploy: - composer/install - - composer/generate-autoload + - composer/dump-autoload on-deploy: - Mage\Tests\Task\CustomTask on-release: diff --git a/src/Mage/Tests/Resources/testhost-skipping.yml b/src/Mage/Tests/Resources/testhost-skipping.yml index c32a50b..e163bd1 100644 --- a/src/Mage/Tests/Resources/testhost-skipping.yml +++ b/src/Mage/Tests/Resources/testhost-skipping.yml @@ -14,7 +14,7 @@ magephp: pre-deploy: - git/update - composer/install - - composer/generate-autoload + - composer/dump-autoload on-deploy: - symfony/cache-warmup: { env: 'dev' } - symfony/assets-install: { env: 'dev' } diff --git a/src/Mage/Tests/Resources/testhost-sudo.yml b/src/Mage/Tests/Resources/testhost-sudo.yml index d323f1c..04fd2e2 100644 --- a/src/Mage/Tests/Resources/testhost-sudo.yml +++ b/src/Mage/Tests/Resources/testhost-sudo.yml @@ -15,7 +15,7 @@ magephp: pre-deploy: - git/update - composer/install - - composer/generate-autoload + - composer/dump-autoload on-deploy: - symfony/cache-clear: { env: 'dev' } - symfony/cache-warmup: { env: 'dev' } diff --git a/src/Mage/Tests/Resources/testhost-with-error.yml b/src/Mage/Tests/Resources/testhost-with-error.yml index e12e3ab..d2dba50 100644 --- a/src/Mage/Tests/Resources/testhost-with-error.yml +++ b/src/Mage/Tests/Resources/testhost-with-error.yml @@ -15,7 +15,7 @@ magephp: pre-deploy: - git/update - composer/install - - composer/generate-autoload + - composer/dump-autoload on-deploy: - deploy/rsync on-release: diff --git a/src/Mage/Tests/Resources/testhost-with-postdeploy-error.yml b/src/Mage/Tests/Resources/testhost-with-postdeploy-error.yml index ba827e2..26e13a2 100644 --- a/src/Mage/Tests/Resources/testhost-with-postdeploy-error.yml +++ b/src/Mage/Tests/Resources/testhost-with-postdeploy-error.yml @@ -14,7 +14,7 @@ magephp: pre-deploy: - git/update - composer/install - - composer/generate-autoload + - composer/dump-autoload on-deploy: - deploy/rsync on-release: diff --git a/src/Mage/Tests/Resources/testhost-without-releases.yml b/src/Mage/Tests/Resources/testhost-without-releases.yml index d3f5810..8c09a74 100644 --- a/src/Mage/Tests/Resources/testhost-without-releases.yml +++ b/src/Mage/Tests/Resources/testhost-without-releases.yml @@ -14,7 +14,7 @@ magephp: pre-deploy: - git/update - composer/install - - composer/generate-autoload + - composer/dump-autoload on-deploy: - symfony/cache-warmup: { env: 'dev' } - symfony/assets-install: { env: 'dev' } diff --git a/src/Mage/Tests/Resources/testhost.yml b/src/Mage/Tests/Resources/testhost.yml index ecfe344..c20a614 100644 --- a/src/Mage/Tests/Resources/testhost.yml +++ b/src/Mage/Tests/Resources/testhost.yml @@ -15,7 +15,7 @@ magephp: pre-deploy: - git/update - composer/install - - composer/generate-autoload + - composer/dump-autoload on-deploy: - symfony/cache-warmup: { env: 'dev' } - symfony/assets-install: { env: 'dev' }