mirror of
https://github.com/hauke68/Magallanes.git
synced 2025-08-24 20:40:16 +02:00
Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
139c1eedb0 | ||
|
04cf5d8ce7 | ||
|
94d0f96998 | ||
|
27755a8790 | ||
|
7163a6dcb8 | ||
|
04eda76635 | ||
|
a7e1a8856c | ||
|
23ab91faa4 | ||
|
47b0274008 | ||
|
eb561f9a0b | ||
|
b0a54cfdc2 | ||
|
604089dcb3 | ||
|
cc430f229f | ||
|
0a851adae0 | ||
|
3caff9e873 | ||
|
e30de6b719 | ||
|
6563efb077 | ||
|
e73b97270c | ||
|
b4f613067e | ||
|
3dc7acf3d4 | ||
|
83110941eb | ||
|
05d9cf0b80 | ||
|
23dae99c1a | ||
|
27923f3e76 | ||
|
5fa99c68f5 | ||
|
7860fea425 | ||
|
b5f181bb18 | ||
|
50ddf081fb | ||
|
4232059d7e | ||
|
bab5e164a5 | ||
|
ceb07a306f | ||
|
1c654e4eac | ||
|
8db7a005f6 | ||
|
b13b3f92b6 | ||
|
3ed4c758c0 | ||
|
621bb8e8df | ||
|
b62ae49bb0 | ||
|
c8d8689622 | ||
|
4735f0c51e | ||
|
26150f4e60 | ||
|
dbbb35fa70 | ||
|
3a2c00dbcb | ||
|
66191b7088 | ||
|
21bcdf76cc | ||
|
280f48cd18 | ||
|
46684ea649 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
/vendor/
|
/vendor/
|
||||||
/build
|
/build
|
||||||
composer.lock
|
composer.lock
|
||||||
|
.mage.yml
|
||||||
|
12
.travis.yml
12
.travis.yml
@ -1,9 +1,13 @@
|
|||||||
language: php
|
language: php
|
||||||
php:
|
php:
|
||||||
- '5.5'
|
- '7.2'
|
||||||
- '5.6'
|
- '7.3'
|
||||||
- '7.0'
|
- '7.4'
|
||||||
- '7.1'
|
|
||||||
|
jobs:
|
||||||
|
fast_finish: true
|
||||||
|
allow_failures:
|
||||||
|
- php: 7.1
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- composer install
|
- composer install
|
||||||
|
31
CHANGELOG.md
31
CHANGELOG.md
@ -1,26 +1,9 @@
|
|||||||
CHANGELOG for 3.X
|
CHANGELOG for 4.X
|
||||||
=================
|
=================
|
||||||
|
|
||||||
* 3.2.0 (2017-04-14)
|
* 4.0.0 (2018-04-02)
|
||||||
* Allow to pre-register Custom Tasks
|
* v4 series release
|
||||||
* [PR#365] New option "from" to define deployment start point
|
* Refactored for Symfony 4 and PHP 7.1
|
||||||
* Allow to define excludes in the global scope.
|
* Symfony Pool Clear task added
|
||||||
* Improve code quality, remove duplications on Symfony Tasks.
|
* Symfony Pool Prune task added
|
||||||
* Improve code quality, remove duplications on Composer Tasks.
|
* Symfony Assetic task removed
|
||||||
* [PR#364] Allow to define custom timeout to Composer:Install
|
|
||||||
|
|
||||||
* 3.1.0 (2017-02-25)
|
|
||||||
* Add new Exec task to execute arbitrary shell commands
|
|
||||||
* Add new Composer task, to update phar (composer/self-update)
|
|
||||||
* [#344] Allow to flag Filesystem tasks
|
|
||||||
* [PR#346] Add new File System task, to change file's modes (fs/chmod)
|
|
||||||
* [BUGFIX] [PR#342] Ignore empty exclude lines
|
|
||||||
* [PR#330] Allow Composer task options to be overwritten at environment level
|
|
||||||
* [PR#330] Add new method Runtime::getMergedOption to merge ConfigOption and EnvOption
|
|
||||||
* [Documentation] [PR#333] Improve example config file
|
|
||||||
|
|
||||||
* 3.0.1 (2017-01-10)
|
|
||||||
* [BUGFIX] [#350] [#353] Fix escape issue when commands are sent through SSH
|
|
||||||
|
|
||||||
* 3.0.0 (2017-01-31)
|
|
||||||
* v3 series release
|
|
||||||
|
17
README.md
17
README.md
@ -1,4 +1,4 @@
|
|||||||
# Magallanes #
|
# Magallanes
|
||||||
[](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56)
|
[](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56)
|
||||||
[](https://travis-ci.org/andres-montanez/Magallanes)
|
[](https://travis-ci.org/andres-montanez/Magallanes)
|
||||||
[](https://coveralls.io/github/andres-montanez/Magallanes?branch=master)
|
[](https://coveralls.io/github/andres-montanez/Magallanes?branch=master)
|
||||||
@ -8,15 +8,15 @@
|
|||||||
[](https://packagist.org/packages/andres-montanez/magallanes)
|
[](https://packagist.org/packages/andres-montanez/magallanes)
|
||||||
[](https://packagist.org/packages/andres-montanez/magallanes)
|
[](https://packagist.org/packages/andres-montanez/magallanes)
|
||||||
|
|
||||||
### What's Magallanes? ###
|
### What's Magallanes?
|
||||||
**Magallanes** is a deployment tool for made with PHP for PHP applications; it's quite simple to use and manage. For more information and documentation please visit http://magephp.com
|
**Magallanes** is a deployment tool for made with PHP for PHP applications; it's quite simple to use and manage. For more information and documentation please visit https://magephp.com
|
||||||
|
|
||||||
### Installing ###
|
### Installing
|
||||||
Simply add the following dependency to your project’s composer.json file:
|
Simply add the following dependency to your project’s composer.json file:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"require": {
|
"require": {
|
||||||
"andres-montanez/magallanes": "^3.0"
|
"andres-montanez/magallanes": "^4.0"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Finally you can use **Magallanes** from the vendor's bin:
|
Finally you can use **Magallanes** from the vendor's bin:
|
||||||
@ -25,8 +25,5 @@ Finally you can use **Magallanes** from the vendor's bin:
|
|||||||
$ vendor/bin/mage version
|
$ vendor/bin/mage version
|
||||||
```
|
```
|
||||||
|
|
||||||
### What happend to version 2? ###
|
### Codename Discovery One
|
||||||
There is no version 2. I've skipped it and jumpped stright from v1 to v3. This new version of **Magallanes** is quite radical and different from it's successor. The whole application has been rewritten using **_Symfony3 Components_**, so naming it v3 makes a lot of sense.
|
Each new mayor version of **Magallanes** will have a codename (like Ubuntu), version 3 was _Nostromo_, and in the current version it is **_Discovery One_**, in homage to the spaceship from the ground breaking film *2001: A Space Odyssey (1968)*.
|
||||||
|
|
||||||
### Codename Nostromo ###
|
|
||||||
Each new mayor version of **Magallanes** will have a codename (like Ubuntu), and in the current version it is **_Nostromo_**, like the spaceship from the movie *Alien (1979)*.
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "andres-montanez/magallanes",
|
"name": "hauke68/magallanes",
|
||||||
"description": "The Deployment Tool for PHP Applications",
|
"description": "The Deployment Tool for PHP Applications",
|
||||||
"homepage": "http://magephp.com",
|
"homepage": "https://magephp.com",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"keywords": ["deployment"],
|
"keywords": ["deployment"],
|
||||||
@ -9,21 +9,25 @@
|
|||||||
{
|
{
|
||||||
"name": "Andrés Montañez",
|
"name": "Andrés Montañez",
|
||||||
"email": "andresmontanez@gmail.com"
|
"email": "andresmontanez@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hauke Zühl",
|
||||||
|
"email": "hzuehl@web.de"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.9",
|
"php": "^7.2.5",
|
||||||
"monolog/monolog": "^1.0",
|
"monolog/monolog": "~1.11||^2.0",
|
||||||
"symfony/console": "^3.0",
|
"symfony/console": "^5.0",
|
||||||
"symfony/filesystem": "^3.0",
|
"symfony/filesystem": "^5.0",
|
||||||
"symfony/event-dispatcher": "^3.0",
|
"symfony/event-dispatcher": "^5.0",
|
||||||
"symfony/finder": "^3.0",
|
"symfony/finder": "^5.0",
|
||||||
"symfony/yaml": "^3.0",
|
"symfony/yaml": "^5.0",
|
||||||
"symfony/process": "^3.0"
|
"symfony/process": "^5.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "4.8.*",
|
"phpunit/phpunit": "^7.0",
|
||||||
"satooshi/php-coveralls": "~1.0"
|
"satooshi/php-coveralls": "^2.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
@ -38,8 +42,8 @@
|
|||||||
"bin": ["bin/mage"],
|
"bin": ["bin/mage"],
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.0.x-dev",
|
"dev-master": "4.0.x-dev",
|
||||||
"dev-nostromo": "3.x-dev"
|
"dev-discovery-one": "4.x-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
docs/dockers/docker-compose.yml
Normal file
19
docs/dockers/docker-compose.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
php5:
|
||||||
|
container_name: mage-php5
|
||||||
|
build: ./php5
|
||||||
|
volumes:
|
||||||
|
- ../../:/home/magephp
|
||||||
|
|
||||||
|
php7.0:
|
||||||
|
container_name: mage-php7.0
|
||||||
|
build: ./php7.0
|
||||||
|
volumes:
|
||||||
|
- ../../:/home/magephp
|
||||||
|
|
||||||
|
php7.1:
|
||||||
|
container_name: mage-php7.1
|
||||||
|
build: ./php7.1
|
||||||
|
volumes:
|
||||||
|
- ../../:/home/magephp
|
9
docs/dockers/php5/Dockerfile
Normal file
9
docs/dockers/php5/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM ubuntu:14.04
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get upgrade -y
|
||||||
|
RUN apt-get install -y vim curl git unzip
|
||||||
|
RUN apt-get install -y php5-cli php5-curl
|
||||||
|
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
|
||||||
|
|
||||||
|
WORKDIR /home/magephp
|
9
docs/dockers/php7.0/Dockerfile
Normal file
9
docs/dockers/php7.0/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get upgrade -y
|
||||||
|
RUN apt-get install -y vim curl git unzip
|
||||||
|
RUN apt-get install -y php7.0-cli php-zip php7.0-curl php7.0-xml
|
||||||
|
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
|
||||||
|
|
||||||
|
WORKDIR /home/magephp
|
9
docs/dockers/php7.1/Dockerfile
Normal file
9
docs/dockers/php7.1/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM ubuntu:17.10
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get upgrade -y
|
||||||
|
RUN apt-get install -y vim curl git unzip
|
||||||
|
RUN apt-get install -y php7.1-cli php-zip php7.1-curl php7.1-xml php7.1-mbstring
|
||||||
|
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
|
||||||
|
|
||||||
|
WORKDIR /home/magephp
|
@ -143,6 +143,9 @@ class DeployCommand extends AbstractCommand
|
|||||||
protected function runOnHosts(OutputInterface $output, $tasks)
|
protected function runOnHosts(OutputInterface $output, $tasks)
|
||||||
{
|
{
|
||||||
$hosts = $this->runtime->getEnvOption('hosts');
|
$hosts = $this->runtime->getEnvOption('hosts');
|
||||||
|
if (!is_array($hosts) && !$hosts instanceof \Countable) {
|
||||||
|
$hosts = [];
|
||||||
|
}
|
||||||
if (count($hosts) == 0) {
|
if (count($hosts) == 0) {
|
||||||
$output->writeln(sprintf(' No hosts defined, skipping %s tasks', $this->getStageName()));
|
$output->writeln(sprintf(' No hosts defined, skipping %s tasks', $this->getStageName()));
|
||||||
$output->writeln('');
|
$output->writeln('');
|
||||||
@ -175,8 +178,8 @@ class DeployCommand extends AbstractCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->runtime->getWorkingHost() !== null) {
|
if ($this->runtime->getHostName() !== null) {
|
||||||
$output->writeln(sprintf(' Starting <fg=black;options=bold>%s</> tasks on host <fg=black;options=bold>%s</>:', $this->getStageName(), $this->runtime->getWorkingHost()));
|
$output->writeln(sprintf(' Starting <fg=black;options=bold>%s</> tasks on host <fg=black;options=bold>%s</>:', $this->getStageName(), $this->runtime->getHostName()));
|
||||||
} else {
|
} else {
|
||||||
$output->writeln(sprintf(' Starting <fg=black;options=bold>%s</> tasks:', $this->getStageName()));
|
$output->writeln(sprintf(' Starting <fg=black;options=bold>%s</> tasks:', $this->getStageName()));
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,9 @@ class ListCommand extends AbstractCommand
|
|||||||
$output->writeln('');
|
$output->writeln('');
|
||||||
|
|
||||||
$hosts = $this->runtime->getEnvOption('hosts');
|
$hosts = $this->runtime->getEnvOption('hosts');
|
||||||
|
if (!is_array($hosts) && !$hosts instanceof \Countable) {
|
||||||
|
$hosts = [];
|
||||||
|
}
|
||||||
if (count($hosts) == 0) {
|
if (count($hosts) == 0) {
|
||||||
$output->writeln('No hosts defined');
|
$output->writeln('No hosts defined');
|
||||||
$output->writeln('');
|
$output->writeln('');
|
||||||
|
@ -17,6 +17,6 @@ namespace Mage;
|
|||||||
*/
|
*/
|
||||||
class Mage
|
class Mage
|
||||||
{
|
{
|
||||||
const VERSION = '3.2';
|
const VERSION = '4.0.0';
|
||||||
const CODENAME = 'Nostromo';
|
const CODENAME = 'Discovery One';
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ use Symfony\Component\Finder\SplFileInfo;
|
|||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Monolog\Handler\StreamHandler;
|
use Monolog\Handler\StreamHandler;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
|
use Symfony\Component\Console\Event\ConsoleErrorEvent;
|
||||||
use Symfony\Component\Console\ConsoleEvents;
|
use Symfony\Component\Console\ConsoleEvents;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Yaml\Parser;
|
use Symfony\Component\Yaml\Parser;
|
||||||
@ -46,12 +46,12 @@ class MageApplication extends Application
|
|||||||
$dispatcher = new EventDispatcher();
|
$dispatcher = new EventDispatcher();
|
||||||
$this->setDispatcher($dispatcher);
|
$this->setDispatcher($dispatcher);
|
||||||
|
|
||||||
$dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
|
$dispatcher->addListener(ConsoleEvents::ERROR, function (ConsoleErrorEvent $event) {
|
||||||
$output = $event->getOutput();
|
$output = $event->getOutput();
|
||||||
$command = $event->getCommand();
|
$command = $event->getCommand();
|
||||||
$output->writeln(sprintf('Oops, exception thrown while running command <info>%s</info>', $command->getName()));
|
$output->writeln(sprintf('Oops, exception thrown while running command <info>%s</info>', $command->getName()));
|
||||||
$exitCode = $event->getExitCode();
|
$exitCode = $event->getExitCode();
|
||||||
$event->setException(new \LogicException('Caught exception', $exitCode, $event->getException()));
|
$event->setError(new \LogicException('Caught exception', $exitCode, $event->getError()));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->runtime = $this->instantiateRuntime();
|
$this->runtime = $this->instantiateRuntime();
|
||||||
@ -84,6 +84,9 @@ class MageApplication extends Application
|
|||||||
|
|
||||||
$logger = new Logger('magephp');
|
$logger = new Logger('magephp');
|
||||||
$logger->pushHandler(new StreamHandler($logfile));
|
$logger->pushHandler(new StreamHandler($logfile));
|
||||||
|
|
||||||
|
} elseif (array_key_exists('log_dir', $config['magephp']) && !is_dir($config['magephp']['log_dir'])) {
|
||||||
|
throw new RuntimeException(sprintf('The configured log_dir "%s" does not exists or is not a directory.', $config['magephp']['log_dir']));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->runtime->setConfiguration($config['magephp']);
|
$this->runtime->setConfiguration($config['magephp']);
|
||||||
|
@ -405,7 +405,7 @@ class Runtime
|
|||||||
{
|
{
|
||||||
$this->log($cmd, LogLevel::INFO);
|
$this->log($cmd, LogLevel::INFO);
|
||||||
|
|
||||||
$process = new Process($cmd);
|
$process = Process::fromShellCommandline($cmd);
|
||||||
$process->setTimeout($timeout);
|
$process->setTimeout($timeout);
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ class Runtime
|
|||||||
{
|
{
|
||||||
$user = $this->getEnvOption('user', $this->getCurrentUser());
|
$user = $this->getEnvOption('user', $this->getCurrentUser());
|
||||||
$sudo = $this->getEnvOption('sudo', false);
|
$sudo = $this->getEnvOption('sudo', false);
|
||||||
$host = $this->getWorkingHost();
|
$host = $this->getHostName();
|
||||||
$sshConfig = $this->getSSHConfig();
|
$sshConfig = $this->getSSHConfig();
|
||||||
|
|
||||||
$cmdDelegate = $cmd;
|
$cmdDelegate = $cmd;
|
||||||
@ -457,7 +457,11 @@ class Runtime
|
|||||||
*/
|
*/
|
||||||
public function getSSHConfig()
|
public function getSSHConfig()
|
||||||
{
|
{
|
||||||
$sshConfig = $this->getEnvOption('ssh', ['port' => '22', 'flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']);
|
$sshConfig = $this->getEnvOption('ssh', ['port' => 22, 'flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']);
|
||||||
|
|
||||||
|
if ($this->getHostPort() !== null) {
|
||||||
|
$sshConfig['port'] = $this->getHostPort();
|
||||||
|
}
|
||||||
|
|
||||||
if (!array_key_exists('port', $sshConfig)) {
|
if (!array_key_exists('port', $sshConfig)) {
|
||||||
$sshConfig['port'] = '22';
|
$sshConfig['port'] = '22';
|
||||||
@ -470,6 +474,32 @@ class Runtime
|
|||||||
return $sshConfig;
|
return $sshConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Host Port or default ssh port
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getHostPort()
|
||||||
|
{
|
||||||
|
$info = explode(':', $this->getWorkingHost());
|
||||||
|
return isset($info[1]) ? $info[1] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Host Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getHostName()
|
||||||
|
{
|
||||||
|
if (strpos($this->getWorkingHost(), ':') === false) {
|
||||||
|
return $this->getWorkingHost();
|
||||||
|
}
|
||||||
|
|
||||||
|
$info = explode(':', $this->getWorkingHost());
|
||||||
|
return $info[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a Temporal File name
|
* Gets a Temporal File name
|
||||||
*
|
*
|
||||||
|
@ -44,7 +44,7 @@ class ReleaseTask extends AbstractTask implements ExecuteOnRollbackInterface
|
|||||||
$cmdLinkRelease = sprintf('cd %s && ln -snf releases/%s current', $hostPath, $releaseId);
|
$cmdLinkRelease = sprintf('cd %s && ln -snf releases/%s current', $hostPath, $releaseId);
|
||||||
|
|
||||||
/** @var Process $process */
|
/** @var Process $process */
|
||||||
$process = $this->runtime->runRemoteCommand($cmdLinkRelease, false);
|
$process = $this->runtime->runRemoteCommand($cmdLinkRelease, false, null);
|
||||||
return $process->isSuccessful();
|
return $process->isSuccessful();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class RsyncTask extends AbstractTask
|
|||||||
$flags = $this->runtime->getEnvOption('rsync', '-avz');
|
$flags = $this->runtime->getEnvOption('rsync', '-avz');
|
||||||
$sshConfig = $this->runtime->getSSHConfig();
|
$sshConfig = $this->runtime->getSSHConfig();
|
||||||
$user = $this->runtime->getEnvOption('user', $this->runtime->getCurrentUser());
|
$user = $this->runtime->getEnvOption('user', $this->runtime->getCurrentUser());
|
||||||
$host = $this->runtime->getWorkingHost();
|
$host = $this->runtime->getHostName();
|
||||||
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
|
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
|
||||||
$targetDir = rtrim($hostPath, '/');
|
$targetDir = rtrim($hostPath, '/');
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class RsyncTask extends AbstractTask
|
|||||||
$cmdRsync = sprintf('rsync -e "ssh -p %d %s" %s %s %s %s@%s:%s', $sshConfig['port'], $sshConfig['flags'], $flags, $excludes, $from, $user, $host, $targetDir);
|
$cmdRsync = sprintf('rsync -e "ssh -p %d %s" %s %s %s %s@%s:%s', $sshConfig['port'], $sshConfig['flags'], $flags, $excludes, $from, $user, $host, $targetDir);
|
||||||
|
|
||||||
/** @var Process $process */
|
/** @var Process $process */
|
||||||
$process = $this->runtime->runLocalCommand($cmdRsync, 600);
|
$process = $this->runtime->runLocalCommand($cmdRsync, null);
|
||||||
return $process->isSuccessful();
|
return $process->isSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,11 +38,12 @@ class CopyTask extends AbstractTask
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->runtime->getEnvOption('user', $this->runtime->getCurrentUser());
|
$user = $this->runtime->getEnvOption('user', $this->runtime->getCurrentUser());
|
||||||
$host = $this->runtime->getWorkingHost();
|
$host = $this->runtime->getHostName();
|
||||||
$sshConfig = $sshConfig = $this->runtime->getSSHConfig();
|
$sshConfig = $sshConfig = $this->runtime->getSSHConfig();
|
||||||
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
|
$hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
|
||||||
$currentReleaseId = $this->runtime->getReleaseId();
|
$currentReleaseId = $this->runtime->getReleaseId();
|
||||||
|
|
||||||
|
$tarPath = $this->runtime->getEnvOption('tar_extract_path', 'tar');
|
||||||
$flags = $this->runtime->getEnvOption('tar_extract', 'xfzop');
|
$flags = $this->runtime->getEnvOption('tar_extract', 'xfzop');
|
||||||
$targetDir = sprintf('%s/releases/%s', $hostPath, $currentReleaseId);
|
$targetDir = sprintf('%s/releases/%s', $hostPath, $currentReleaseId);
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ class CopyTask extends AbstractTask
|
|||||||
/** @var Process $process */
|
/** @var Process $process */
|
||||||
$process = $this->runtime->runLocalCommand($cmdCopy, 300);
|
$process = $this->runtime->runLocalCommand($cmdCopy, 300);
|
||||||
if ($process->isSuccessful()) {
|
if ($process->isSuccessful()) {
|
||||||
$cmdUnTar = sprintf('cd %s && tar %s %s', $targetDir, $flags, $tarRemote);
|
$cmdUnTar = sprintf('cd %s && %s %s %s', $targetDir, $tarPath, $flags, $tarRemote);
|
||||||
$process = $this->runtime->runRemoteCommand($cmdUnTar, false, 600);
|
$process = $this->runtime->runRemoteCommand($cmdUnTar, false, 600);
|
||||||
if ($process->isSuccessful()) {
|
if ($process->isSuccessful()) {
|
||||||
$cmdDelete = sprintf('rm %s/%s', $targetDir, $tarRemote);
|
$cmdDelete = sprintf('rm %s/%s', $targetDir, $tarRemote);
|
||||||
|
@ -41,9 +41,10 @@ class PrepareTask extends AbstractTask
|
|||||||
$this->runtime->setVar('tar_local', $tarLocal);
|
$this->runtime->setVar('tar_local', $tarLocal);
|
||||||
|
|
||||||
$excludes = $this->getExcludes();
|
$excludes = $this->getExcludes();
|
||||||
|
$tarPath = $this->runtime->getEnvOption('tar_create_path', 'tar');
|
||||||
$flags = $this->runtime->getEnvOption('tar_create', 'cfzp');
|
$flags = $this->runtime->getEnvOption('tar_create', 'cfzp');
|
||||||
$from = $this->runtime->getEnvOption('from', './');
|
$from = $this->runtime->getEnvOption('from', './');
|
||||||
$cmdTar = sprintf('tar %s %s %s %s', $flags, $tarLocal, $excludes, $from);
|
$cmdTar = sprintf('%s %s %s %s %s', $tarPath, $flags, $tarLocal, $excludes, $from);
|
||||||
|
|
||||||
/** @var Process $process */
|
/** @var Process $process */
|
||||||
$process = $this->runtime->runLocalCommand($cmdTar, 300);
|
$process = $this->runtime->runLocalCommand($cmdTar, 300);
|
||||||
|
@ -61,8 +61,8 @@ abstract class AbstractFileTask extends AbstractTask
|
|||||||
'%environment%' => $this->runtime->getEnvironment(),
|
'%environment%' => $this->runtime->getEnvironment(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->runtime->getWorkingHost() !== null) {
|
if ($this->runtime->getHostName() !== null) {
|
||||||
$mapping['%host%'] = $this->runtime->getWorkingHost();
|
$mapping['%host%'] = $this->runtime->getHostName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->runtime->getReleaseId() !== null) {
|
if ($this->runtime->getReleaseId() !== null) {
|
||||||
|
@ -10,30 +10,35 @@
|
|||||||
|
|
||||||
namespace Mage\Task\BuiltIn\Symfony;
|
namespace Mage\Task\BuiltIn\Symfony;
|
||||||
|
|
||||||
|
use Mage\Task\Exception\ErrorException;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
use Mage\Task\AbstractTask;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Symfony Task - Dump Assetics
|
* Symfony Task - Cache Pool Clear
|
||||||
*
|
*
|
||||||
* @author Andrés Montañez <andresmontanez@gmail.com>
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||||
*/
|
*/
|
||||||
class AsseticDumpTask extends AbstractTask
|
class CachePoolClearTask extends AbstractSymfonyTask
|
||||||
{
|
{
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return 'symfony/assetic-dump';
|
return 'symfony/cache-pool-clear';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription()
|
public function getDescription()
|
||||||
{
|
{
|
||||||
return '[Symfony] Assetic Dump';
|
return '[Symfony] Cache Pool Clear';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$options = $this->getOptions();
|
$options = $this->getOptions();
|
||||||
$command = sprintf('%s assetic:dump --env=%s %s', $options['console'], $options['env'], $options['flags']);
|
|
||||||
|
if (!$options['pools']) {
|
||||||
|
throw new ErrorException('Parameter "pools" is not defined');
|
||||||
|
}
|
||||||
|
|
||||||
|
$command = $options['console'] . ' cache:pool:clear ' . $options['pools'] . ' --env=' . $options['env'] . ' ' . $options['flags'];
|
||||||
|
|
||||||
/** @var Process $process */
|
/** @var Process $process */
|
||||||
$process = $this->runtime->runCommand(trim($command));
|
$process = $this->runtime->runCommand(trim($command));
|
||||||
@ -41,14 +46,8 @@ class AsseticDumpTask extends AbstractTask
|
|||||||
return $process->isSuccessful();
|
return $process->isSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getOptions()
|
protected function getSymfonyOptions()
|
||||||
{
|
{
|
||||||
$options = array_merge(
|
return ['pools' => null];
|
||||||
['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
|
|
||||||
$this->runtime->getMergedOption('symfony'),
|
|
||||||
$this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
return $options;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
42
src/Task/BuiltIn/Symfony/CachePoolPruneTask.php
Normal file
42
src/Task/BuiltIn/Symfony/CachePoolPruneTask.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of the Magallanes package.
|
||||||
|
*
|
||||||
|
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Mage\Task\BuiltIn\Symfony;
|
||||||
|
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Symfony Task - Cache Pool Prune
|
||||||
|
*
|
||||||
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||||||
|
*/
|
||||||
|
class CachePoolPruneTask extends AbstractSymfonyTask
|
||||||
|
{
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'symfony/cache-pool-prune';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return '[Symfony] Cache Pool Prune';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute()
|
||||||
|
{
|
||||||
|
$options = $this->getOptions();
|
||||||
|
$command = $options['console'] . ' cache:pool:prune --env=' . $options['env'] . ' ' . $options['flags'];
|
||||||
|
|
||||||
|
/** @var Process $process */
|
||||||
|
$process = $this->runtime->runCommand(trim($command));
|
||||||
|
|
||||||
|
return $process->isSuccessful();
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\Config\DumpCommand;
|
|||||||
use Mage\Command\AbstractCommand;
|
use Mage\Command\AbstractCommand;
|
||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class DumpCommandTest extends TestCase
|
class DumpCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\Config\EnvironmentsCommand;
|
|||||||
use Mage\Command\AbstractCommand;
|
use Mage\Command\AbstractCommand;
|
||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class EnvironmentsCommandTest extends TestCase
|
class EnvironmentsCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\DeployCommand;
|
|||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use Mage\Command\AbstractCommand;
|
use Mage\Command\AbstractCommand;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class DeployCommandMiscTasksTest extends TestCase
|
class DeployCommandMiscTasksTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -35,8 +35,10 @@ class DeployCommandMiscTasksTest extends TestCase
|
|||||||
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',
|
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 "cd /var/www/test && bin/console cache:warmup --env=testenv"',
|
1 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:warmup --env=testenv"',
|
||||||
2 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console assets:install web --env=testenv --symlink --relative"',
|
2 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test && bin/console assetic:dump --env=testenv"',
|
3 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:pool:prune --env=testenv"',
|
||||||
4 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console assetic:dump --env=prod"',
|
4 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:pool:prune --env=prod"',
|
||||||
|
5 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:pool:clear main --env=testenv"',
|
||||||
|
6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:pool:clear main --env=prod"',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check total of Executed Commands
|
// Check total of Executed Commands
|
||||||
|
@ -11,10 +11,11 @@
|
|||||||
namespace Mage\Tests\Command\BuiltIn;
|
namespace Mage\Tests\Command\BuiltIn;
|
||||||
|
|
||||||
use Mage\Command\BuiltIn\DeployCommand;
|
use Mage\Command\BuiltIn\DeployCommand;
|
||||||
|
use Mage\Runtime\Exception\RuntimeException;
|
||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use Mage\Command\AbstractCommand;
|
use Mage\Command\AbstractCommand;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class DeployCommandMiscTest extends TestCase
|
class DeployCommandMiscTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -36,6 +37,24 @@ class DeployCommandMiscTest extends TestCase
|
|||||||
$this->assertEquals(0, $tester->getStatusCode());
|
$this->assertEquals(0, $tester->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testInvalidLog()
|
||||||
|
{
|
||||||
|
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/invalid-log.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 (RuntimeException $exception) {
|
||||||
|
$this->assertEquals('The configured log_dir "/no-temp" does not exists or is not a directory.', $exception->getMessage());
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
$this->assertFalse(true, sprintf('Exception "%s" catched, message: "%s"', get_class($exception), $exception->getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function testDeploymentWithSudo()
|
public function testDeploymentWithSudo()
|
||||||
{
|
{
|
||||||
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-sudo.yml');
|
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-sudo.yml');
|
||||||
@ -59,7 +78,7 @@ class DeployCommandMiscTest extends TestCase
|
|||||||
6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && sudo bin/console cache:clear --env=dev"',
|
6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test && sudo bin/console cache:warmup --env=dev"',
|
7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test && sudo bin/console assets:install web --env=dev --symlink --relative"',
|
8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test && sudo bin/console assetic:dump --env=dev"',
|
9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && sudo bin/console cache:pool:prune --env=dev"',
|
||||||
10 => 'git checkout master',
|
10 => 'git checkout master',
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -96,7 +115,7 @@ class DeployCommandMiscTest extends TestCase
|
|||||||
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',
|
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 "cd /var/www/test && bin/console cache:warmup --env=dev"',
|
6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:warmup --env=dev"',
|
||||||
7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "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 "cd /var/www/test && bin/console assetic:dump --env=dev"',
|
8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:pool:prune --env=dev"',
|
||||||
9 => 'git checkout master',
|
9 => 'git checkout master',
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -240,7 +259,7 @@ class DeployCommandMiscTest extends TestCase
|
|||||||
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',
|
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 "cd /var/www/test && bin/console cache:warmup --env=dev"',
|
5 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:warmup --env=dev"',
|
||||||
6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console assets:install web --env=dev --symlink --relative"',
|
6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test && bin/console assetic:dump --env=dev"',
|
7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:pool:prune --env=dev"',
|
||||||
8 => 'git branch | grep "*"',
|
8 => 'git branch | grep "*"',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\DeployCommand;
|
|||||||
use Mage\Command\AbstractCommand;
|
use Mage\Command\AbstractCommand;
|
||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class DeployCommandWithReleasesTest extends TestCase
|
class DeployCommandWithReleasesTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ class DeployCommandWithReleasesTest extends TestCase
|
|||||||
9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm /var/www/test/releases/1234567890/mageXYZ"',
|
9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm /var/www/test/releases/1234567890/mageXYZ"',
|
||||||
10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:warmup --env=dev"',
|
10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test/releases/1234567890 && bin/console assets:install web --env=dev --symlink --relative"',
|
11 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test/releases/1234567890 && bin/console assetic:dump --env=dev"',
|
12 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:pool:prune --env=dev"',
|
||||||
13 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && ln -snf releases/1234567890 current"',
|
13 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && ln -snf releases/1234567890 current"',
|
||||||
14 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"',
|
14 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"',
|
||||||
15 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015110"',
|
15 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015110"',
|
||||||
@ -68,6 +68,56 @@ class DeployCommandWithReleasesTest extends TestCase
|
|||||||
$this->assertEquals(0, $tester->getStatusCode());
|
$this->assertEquals(0, $tester->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDeploymentWithReleasesWithPortCommands()
|
||||||
|
{
|
||||||
|
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-port.yml');
|
||||||
|
|
||||||
|
$application->getRuntime()->setReleaseId('20170101015120');
|
||||||
|
|
||||||
|
/** @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 => 'git branch | grep "*"',
|
||||||
|
1 => 'git checkout test',
|
||||||
|
2 => 'git pull',
|
||||||
|
3 => 'composer install --optimize-autoloader',
|
||||||
|
4 => 'composer dump-autoload --optimize',
|
||||||
|
5 => 'tar cfzp /tmp/mageXYZ --exclude=".git" --exclude="./var/cache/*" --exclude="./var/log/*" --exclude="./web/app_dev.php" ./',
|
||||||
|
6 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "mkdir -p /var/www/test/releases/1234567890"',
|
||||||
|
7 => 'scp -P 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/mageXYZ tester@testhost:/var/www/test/releases/1234567890/mageXYZ',
|
||||||
|
8 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && tar xfzop mageXYZ"',
|
||||||
|
9 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm /var/www/test/releases/1234567890/mageXYZ"',
|
||||||
|
10 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:warmup --env=prod"',
|
||||||
|
11 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console assets:install web --env=prod --symlink --relative"',
|
||||||
|
12 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:pool:prune --env=prod"',
|
||||||
|
13 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && ln -snf releases/1234567890 current"',
|
||||||
|
14 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"',
|
||||||
|
15 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015110"',
|
||||||
|
16 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015111"',
|
||||||
|
17 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015112"',
|
||||||
|
18 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015113"',
|
||||||
|
19 => 'rm /tmp/mageXYZ',
|
||||||
|
20 => 'git checkout master',
|
||||||
|
);
|
||||||
|
|
||||||
|
// 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 testDeploymentWithReleasesWithFromCommands()
|
public function testDeploymentWithReleasesWithFromCommands()
|
||||||
{
|
{
|
||||||
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-from.yml');
|
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-with-from.yml');
|
||||||
@ -96,7 +146,7 @@ class DeployCommandWithReleasesTest extends TestCase
|
|||||||
9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm /var/www/test/releases/1234567890/mageXYZ"',
|
9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm /var/www/test/releases/1234567890/mageXYZ"',
|
||||||
10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:warmup --env=dev"',
|
10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test/releases/1234567890 && bin/console assets:install web --env=dev --symlink --relative"',
|
11 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test/releases/1234567890 && bin/console assetic:dump --env=dev"',
|
12 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:pool:prune --env=dev"',
|
||||||
13 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && ln -snf releases/1234567890 current"',
|
13 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && ln -snf releases/1234567890 current"',
|
||||||
14 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"',
|
14 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"',
|
||||||
15 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015110"',
|
15 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015110"',
|
||||||
@ -306,7 +356,7 @@ class DeployCommandWithReleasesTest extends TestCase
|
|||||||
9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm /var/www/test/releases/1234567890/mageXYZ"',
|
9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm /var/www/test/releases/1234567890/mageXYZ"',
|
||||||
10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:warmup --env=dev"',
|
10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test/releases/1234567890 && bin/console assets:install web --env=dev --symlink --relative"',
|
11 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test/releases/1234567890 && bin/console assetic:dump --env=dev"',
|
12 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:pool:prune --env=dev"',
|
||||||
13 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && ln -snf releases/1234567890 current"',
|
13 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && ln -snf releases/1234567890 current"',
|
||||||
14 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"',
|
14 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"',
|
||||||
15 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015110"',
|
15 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm -rf /var/www/test/releases/20170101015110"',
|
||||||
@ -359,7 +409,7 @@ class DeployCommandWithReleasesTest extends TestCase
|
|||||||
9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm /var/www/test/releases/1234567890/mageXYZ"',
|
9 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "rm /var/www/test/releases/1234567890/mageXYZ"',
|
||||||
10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:warmup --env=dev"',
|
10 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test/releases/1234567890 && bin/console assets:install web --env=dev --symlink --relative"',
|
11 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "cd /var/www/test/releases/1234567890 && bin/console assetic:dump --env=dev"',
|
12 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && bin/console cache:pool:prune --env=dev"',
|
||||||
13 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && ln -snf releases/1234567890 current"',
|
13 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && ln -snf releases/1234567890 current"',
|
||||||
14 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"',
|
14 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"',
|
||||||
);
|
);
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\DeployCommand;
|
|||||||
use Mage\Command\AbstractCommand;
|
use Mage\Command\AbstractCommand;
|
||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class DeployCommandWithoutReleasesTest extends TestCase
|
class DeployCommandWithoutReleasesTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -40,7 +40,44 @@ class DeployCommandWithoutReleasesTest extends TestCase
|
|||||||
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',
|
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 "cd /var/www/test && bin/console cache:warmup --env=dev"',
|
6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:warmup --env=dev"',
|
||||||
7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "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 "cd /var/www/test && bin/console assetic:dump --env=dev"',
|
8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:pool:prune --env=dev"',
|
||||||
|
9 => 'git checkout master',
|
||||||
|
);
|
||||||
|
|
||||||
|
// 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 testDeploymentWithoutReleasesWithPortCommands()
|
||||||
|
{
|
||||||
|
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/testhost-without-releases-with-port.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 => 'git branch | grep "*"',
|
||||||
|
1 => 'git checkout test',
|
||||||
|
2 => 'git pull',
|
||||||
|
3 => 'composer install --optimize-autoloader',
|
||||||
|
4 => 'composer dump-autoload --optimize',
|
||||||
|
5 => 'rsync -e "ssh -p 202 -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 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:warmup --env=dev"',
|
||||||
|
7 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console assets:install web --env=dev --symlink --relative"',
|
||||||
|
8 => 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:pool:prune --env=dev"',
|
||||||
9 => 'git checkout master',
|
9 => 'git checkout master',
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -77,7 +114,7 @@ class DeployCommandWithoutReleasesTest extends TestCase
|
|||||||
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 ./dist tester@testhost:/var/www/test',
|
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 ./dist tester@testhost:/var/www/test',
|
||||||
6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:warmup --env=dev"',
|
6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:warmup --env=dev"',
|
||||||
7 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "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 "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 "cd /var/www/test && bin/console assetic:dump --env=dev"',
|
8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test && bin/console cache:pool:prune --env=dev"',
|
||||||
9 => 'git checkout master',
|
9 => 'git checkout master',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\Releases\ListCommand;
|
|||||||
use Mage\Command\AbstractCommand;
|
use Mage\Command\AbstractCommand;
|
||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ListCommandTest extends TestCase
|
class ListCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Command\BuiltIn\Releases\RollbackCommand;
|
|||||||
use Mage\Command\AbstractCommand;
|
use Mage\Command\AbstractCommand;
|
||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class RollbackCommandTest extends TestCase
|
class RollbackCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ use Mage\Command\BuiltIn\VersionCommand;
|
|||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use Mage\Mage;
|
use Mage\Mage;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class VersionCommandTest extends TestCase
|
class VersionCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ use Mage\Deploy\Strategy\RsyncStrategy;
|
|||||||
use Mage\Runtime\Exception\RuntimeException;
|
use Mage\Runtime\Exception\RuntimeException;
|
||||||
use Mage\Runtime\Runtime;
|
use Mage\Runtime\Runtime;
|
||||||
use Exception;
|
use Exception;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class StrategyTest extends TestCase
|
class StrategyTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\MageApplication;
|
|||||||
use Mage\Runtime\Exception\RuntimeException;
|
use Mage\Runtime\Exception\RuntimeException;
|
||||||
use Symfony\Component\Console\Tester\ApplicationTester;
|
use Symfony\Component\Console\Tester\ApplicationTester;
|
||||||
use Exception;
|
use Exception;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class MageApplicationTest extends TestCase
|
class MageApplicationTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ magephp:
|
|||||||
on-deploy:
|
on-deploy:
|
||||||
- symfony/cache-warmup: { env: 'dev' }
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
- symfony/assets-install: { env: 'dev' }
|
- symfony/assets-install: { env: 'dev' }
|
||||||
- symfony/assetic-dump: { env: 'dev' }
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
on-release:
|
on-release:
|
||||||
post-release:
|
post-release:
|
||||||
post-deploy:
|
post-deploy:
|
27
tests/Resources/invalid-log.yml
Normal file
27
tests/Resources/invalid-log.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
magephp:
|
||||||
|
log_dir: /no-temp
|
||||||
|
environments:
|
||||||
|
production:
|
||||||
|
user: app
|
||||||
|
branch: master
|
||||||
|
host_path: /var/www/myapp
|
||||||
|
releases: 4
|
||||||
|
exclude:
|
||||||
|
- ./var/cache/*
|
||||||
|
- ./var/log/*
|
||||||
|
- ./web/app_dev.php
|
||||||
|
hosts:
|
||||||
|
- webserver1
|
||||||
|
- webserver2
|
||||||
|
- webserver3
|
||||||
|
pre-deploy:
|
||||||
|
- git/update
|
||||||
|
- composer/install
|
||||||
|
- composer/dump-autoload
|
||||||
|
on-deploy:
|
||||||
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
|
- symfony/assets-install: { env: 'dev' }
|
||||||
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
|
on-release:
|
||||||
|
post-release:
|
||||||
|
post-deploy:
|
@ -17,7 +17,7 @@ magephp:
|
|||||||
on-deploy:
|
on-deploy:
|
||||||
- symfony/cache-warmup: { env: 'dev' }
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
- symfony/assets-install: { env: 'dev' }
|
- symfony/assets-install: { env: 'dev' }
|
||||||
- symfony/assetic-dump: { env: 'dev' }
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
on-release:
|
on-release:
|
||||||
post-release:
|
post-release:
|
||||||
post-deploy:
|
post-deploy:
|
@ -14,5 +14,7 @@ magephp:
|
|||||||
on-deploy:
|
on-deploy:
|
||||||
- symfony/cache-warmup
|
- symfony/cache-warmup
|
||||||
- symfony/assets-install
|
- symfony/assets-install
|
||||||
- symfony/assetic-dump
|
- symfony/cache-pool-prune
|
||||||
- symfony/assetic-dump: { env: 'prod' }
|
- symfony/cache-pool-prune: { env: 'prod' }
|
||||||
|
- symfony/cache-pool-clear: { pools: 'main' }
|
||||||
|
- symfony/cache-pool-clear: { env: 'prod', pools: 'main' }
|
||||||
|
@ -18,7 +18,7 @@ magephp:
|
|||||||
on-deploy:
|
on-deploy:
|
||||||
- symfony/cache-warmup: { env: 'dev' }
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
- symfony/assets-install: { env: 'dev' }
|
- symfony/assets-install: { env: 'dev' }
|
||||||
- symfony/assetic-dump: { env: 'dev' }
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
on-release:
|
on-release:
|
||||||
post-release:
|
post-release:
|
||||||
post-deploy:
|
post-deploy:
|
@ -20,7 +20,7 @@ magephp:
|
|||||||
- symfony/cache-clear: { env: 'dev' }
|
- symfony/cache-clear: { env: 'dev' }
|
||||||
- symfony/cache-warmup: { env: 'dev' }
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
- symfony/assets-install: { env: 'dev' }
|
- symfony/assets-install: { env: 'dev' }
|
||||||
- symfony/assetic-dump: { env: 'dev' }
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
on-release:
|
on-release:
|
||||||
post-release:
|
post-release:
|
||||||
post-deploy:
|
post-deploy:
|
@ -22,7 +22,7 @@ magephp:
|
|||||||
on-deploy:
|
on-deploy:
|
||||||
- symfony/cache-warmup: { env: 'dev' }
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
- symfony/assets-install: { env: 'dev' }
|
- symfony/assets-install: { env: 'dev' }
|
||||||
- symfony/assetic-dump: { env: 'dev' }
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
on-release:
|
on-release:
|
||||||
post-release:
|
post-release:
|
||||||
post-deploy:
|
post-deploy:
|
27
tests/Resources/testhost-with-port.yml
Normal file
27
tests/Resources/testhost-with-port.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
magephp:
|
||||||
|
log_dir: /tmp
|
||||||
|
environments:
|
||||||
|
test:
|
||||||
|
user: tester
|
||||||
|
branch: test
|
||||||
|
host_path: /var/www/test
|
||||||
|
releases: 4
|
||||||
|
exclude:
|
||||||
|
- ./var/cache/*
|
||||||
|
- ./var/log/*
|
||||||
|
- ./web/app_dev.php
|
||||||
|
-
|
||||||
|
-
|
||||||
|
hosts:
|
||||||
|
- testhost:202
|
||||||
|
pre-deploy:
|
||||||
|
- git/update
|
||||||
|
- composer/install
|
||||||
|
- composer/dump-autoload
|
||||||
|
on-deploy:
|
||||||
|
- symfony/cache-warmup: { env: 'prod' }
|
||||||
|
- symfony/assets-install: { env: 'prod' }
|
||||||
|
- symfony/cache-pool-prune: { env: 'prod' }
|
||||||
|
on-release:
|
||||||
|
post-release:
|
||||||
|
post-deploy:
|
@ -19,7 +19,7 @@ magephp:
|
|||||||
on-deploy:
|
on-deploy:
|
||||||
- symfony/cache-warmup: { env: 'dev' }
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
- symfony/assets-install: { env: 'dev' }
|
- symfony/assets-install: { env: 'dev' }
|
||||||
- symfony/assetic-dump: { env: 'dev' }
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
on-release:
|
on-release:
|
||||||
post-release:
|
post-release:
|
||||||
post-deploy:
|
post-deploy:
|
24
tests/Resources/testhost-without-releases-with-port.yml
Normal file
24
tests/Resources/testhost-without-releases-with-port.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
magephp:
|
||||||
|
log_dir: /tmp
|
||||||
|
environments:
|
||||||
|
test:
|
||||||
|
user: tester
|
||||||
|
branch: test
|
||||||
|
host_path: /var/www/test
|
||||||
|
exclude:
|
||||||
|
- ./var/cache/*
|
||||||
|
- ./var/log/*
|
||||||
|
- ./web/app_dev.php
|
||||||
|
hosts:
|
||||||
|
- testhost:202
|
||||||
|
pre-deploy:
|
||||||
|
- git/update
|
||||||
|
- composer/install
|
||||||
|
- composer/dump-autoload
|
||||||
|
on-deploy:
|
||||||
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
|
- symfony/assets-install: { env: 'dev' }
|
||||||
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
|
on-release:
|
||||||
|
post-release:
|
||||||
|
post-deploy:
|
@ -18,7 +18,7 @@ magephp:
|
|||||||
on-deploy:
|
on-deploy:
|
||||||
- symfony/cache-warmup: { env: 'dev' }
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
- symfony/assets-install: { env: 'dev' }
|
- symfony/assets-install: { env: 'dev' }
|
||||||
- symfony/assetic-dump: { env: 'dev' }
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
on-release:
|
on-release:
|
||||||
post-release:
|
post-release:
|
||||||
post-deploy:
|
post-deploy:
|
@ -21,7 +21,7 @@ magephp:
|
|||||||
on-deploy:
|
on-deploy:
|
||||||
- symfony/cache-warmup: { env: 'dev' }
|
- symfony/cache-warmup: { env: 'dev' }
|
||||||
- symfony/assets-install: { env: 'dev' }
|
- symfony/assets-install: { env: 'dev' }
|
||||||
- symfony/assetic-dump: { env: 'dev' }
|
- symfony/cache-pool-prune: { env: 'dev' }
|
||||||
on-release:
|
on-release:
|
||||||
post-release:
|
post-release:
|
||||||
post-deploy:
|
post-deploy:
|
@ -19,7 +19,7 @@ class ProcessMockup extends Process
|
|||||||
protected $timeout;
|
protected $timeout;
|
||||||
protected $success = true;
|
protected $success = true;
|
||||||
|
|
||||||
public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
|
public function __construct($commandline, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
|
||||||
{
|
{
|
||||||
$this->commandline = $commandline;
|
$this->commandline = $commandline;
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ class ProcessMockup extends Process
|
|||||||
$this->timeout = $timeout;
|
$this->timeout = $timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run($callback = null)
|
public function run(callable $callback = null, array $env = array()): int
|
||||||
{
|
{
|
||||||
if (in_array($this->commandline, $this->forceFail)) {
|
if (in_array($this->commandline, $this->forceFail)) {
|
||||||
$this->success = false;
|
$this->success = false;
|
||||||
@ -50,6 +50,12 @@ class ProcessMockup extends Process
|
|||||||
if ($this->commandline == 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@hostdemo2 "ls -1 /var/www/test/releases"') {
|
if ($this->commandline == 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@hostdemo2 "ls -1 /var/www/test/releases"') {
|
||||||
$this->success = false;
|
$this->success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->success) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSuccessful()
|
public function isSuccessful()
|
||||||
@ -99,6 +105,14 @@ class ProcessMockup extends Process
|
|||||||
return '/var/www/test/releases/20170101015117';
|
return '/var/www/test/releases/20170101015117';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->commandline == 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "ls -1 /var/www/test/releases"') {
|
||||||
|
return implode(PHP_EOL, ['20170101015110', '20170101015111', '20170101015112', '20170101015113', '20170101015114', '20170101015115', '20170101015116', '20170101015117']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->commandline == 'ssh -p 202 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "readlink -f /var/www/test/current"') {
|
||||||
|
return '/var/www/test/releases/20170101015117';
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->commandline == 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@host1 "ls -1 /var/www/test/releases"') {
|
if ($this->commandline == 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@host1 "ls -1 /var/www/test/releases"') {
|
||||||
return implode(PHP_EOL, ['20170101015110', '20170101015111', '20170101015112', '20170101015113', '20170101015114', '20170101015115', '20170101015116', '20170101015117']);
|
return implode(PHP_EOL, ['20170101015110', '20170101015111', '20170101015112', '20170101015113', '20170101015114', '20170101015115', '20170101015116', '20170101015117']);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Component\Process\Process;
|
|||||||
class RuntimeMockup extends Runtime
|
class RuntimeMockup extends Runtime
|
||||||
{
|
{
|
||||||
protected $ranCommands = [];
|
protected $ranCommands = [];
|
||||||
|
protected $ranCommandTimeouts = [];
|
||||||
protected $forceFail = [];
|
protected $forceFail = [];
|
||||||
|
|
||||||
public function getRanCommands()
|
public function getRanCommands()
|
||||||
@ -23,6 +24,11 @@ class RuntimeMockup extends Runtime
|
|||||||
return $this->ranCommands;
|
return $this->ranCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRanCommandTimeoutFor($cmd)
|
||||||
|
{
|
||||||
|
return isset($this->ranCommandTimeouts[$cmd]) ? $this->ranCommandTimeouts[$cmd] : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the Release ID
|
* Generate the Release ID
|
||||||
*
|
*
|
||||||
@ -44,6 +50,7 @@ class RuntimeMockup extends Runtime
|
|||||||
public function runLocalCommand($cmd, $timeout = 120)
|
public function runLocalCommand($cmd, $timeout = 120)
|
||||||
{
|
{
|
||||||
$this->ranCommands[] = $cmd;
|
$this->ranCommands[] = $cmd;
|
||||||
|
$this->ranCommandTimeouts[$cmd] = $timeout;
|
||||||
|
|
||||||
$process = new ProcessMockup($cmd);
|
$process = new ProcessMockup($cmd);
|
||||||
$process->forceFail = $this->forceFail;
|
$process->forceFail = $this->forceFail;
|
||||||
|
@ -15,7 +15,7 @@ use Mage\Runtime\Runtime;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Monolog\Handler\TestHandler;
|
use Monolog\Handler\TestHandler;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
@ -119,6 +119,20 @@ class RuntimeTest extends TestCase
|
|||||||
$this->assertEquals('-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no', $sshConfig['flags']);
|
$this->assertEquals('-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no', $sshConfig['flags']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSSHConfigPortDefinedInHostNotation()
|
||||||
|
{
|
||||||
|
$runtime = new Runtime();
|
||||||
|
$runtime->setWorkingHost('223.12.24.64:1056');
|
||||||
|
$sshConfig = $runtime->getSSHConfig();
|
||||||
|
|
||||||
|
$this->assertEquals('1056', $sshConfig['port']);
|
||||||
|
|
||||||
|
$runtime->setWorkingHost('223.12.24.64');
|
||||||
|
$sshConfig = $runtime->getSSHConfig();
|
||||||
|
|
||||||
|
$this->assertEquals('22', $sshConfig['port']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testSSHConfigEmptyOptions()
|
public function testSSHConfigEmptyOptions()
|
||||||
{
|
{
|
||||||
$runtime = new Runtime();
|
$runtime = new Runtime();
|
||||||
|
@ -12,7 +12,7 @@ namespace Mage\Tests\Task;
|
|||||||
|
|
||||||
use Mage\Task\Exception\ErrorException;
|
use Mage\Task\Exception\ErrorException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class AbstractTaskTest extends TestCase
|
class AbstractTaskTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Mage\Tests\Task\BuiltIn\Composer;
|
namespace Mage\Tests\Task\BuiltIn\Composer;
|
||||||
|
|
||||||
use Mage\Tests\Runtime\RuntimeMockup;
|
use Mage\Tests\Runtime\RuntimeMockup;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class BasicComposerTaskTest extends TestCase
|
class BasicComposerTaskTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ use Mage\Tests\Runtime\RuntimeMockup;
|
|||||||
use Mage\Task\BuiltIn\Composer\SelfUpdateTask;
|
use Mage\Task\BuiltIn\Composer\SelfUpdateTask;
|
||||||
use Mage\Task\Exception\SkipException;
|
use Mage\Task\Exception\SkipException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class SelfUpdateTaskTest extends TestCase
|
class SelfUpdateTaskTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException;
|
|||||||
use Mage\Task\BuiltIn\ExecTask;
|
use Mage\Task\BuiltIn\ExecTask;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Mage\Tests\Runtime\RuntimeMockup;
|
use Mage\Tests\Runtime\RuntimeMockup;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ExecTest extends TestCase
|
class ExecTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException;
|
|||||||
use Mage\Task\BuiltIn\FS\ChangeModeTask;
|
use Mage\Task\BuiltIn\FS\ChangeModeTask;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Mage\Tests\Runtime\RuntimeMockup;
|
use Mage\Tests\Runtime\RuntimeMockup;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ChangeModeTest extends TestCase
|
class ChangeModeTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException;
|
|||||||
use Mage\Task\BuiltIn\FS\CopyTask;
|
use Mage\Task\BuiltIn\FS\CopyTask;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Mage\Tests\Runtime\RuntimeMockup;
|
use Mage\Tests\Runtime\RuntimeMockup;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class CopyTaskTest extends TestCase
|
class CopyTaskTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException;
|
|||||||
use Mage\Task\BuiltIn\FS\LinkTask;
|
use Mage\Task\BuiltIn\FS\LinkTask;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Mage\Tests\Runtime\RuntimeMockup;
|
use Mage\Tests\Runtime\RuntimeMockup;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class LinkTaskTest extends TestCase
|
class LinkTaskTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException;
|
|||||||
use Mage\Task\BuiltIn\FS\MoveTask;
|
use Mage\Task\BuiltIn\FS\MoveTask;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Mage\Tests\Runtime\RuntimeMockup;
|
use Mage\Tests\Runtime\RuntimeMockup;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class MoveTaskTest extends TestCase
|
class MoveTaskTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use Mage\Task\Exception\ErrorException;
|
|||||||
use Mage\Task\BuiltIn\FS\RemoveTask;
|
use Mage\Task\BuiltIn\FS\RemoveTask;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Mage\Tests\Runtime\RuntimeMockup;
|
use Mage\Tests\Runtime\RuntimeMockup;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class RemoveTaskTest extends TestCase
|
class RemoveTaskTest extends TestCase
|
||||||
{
|
{
|
||||||
|
38
tests/Task/BuiltIn/Symfony/CachePoolClearTaskTest.php
Normal file
38
tests/Task/BuiltIn/Symfony/CachePoolClearTaskTest.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Mage\tests\Task\BuiltIn\Symfony;
|
||||||
|
|
||||||
|
|
||||||
|
use Mage\Task\BuiltIn\Symfony\CachePoolClearTask;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Mage\Tests\Runtime\RuntimeMockup;
|
||||||
|
use Mage\Task\Exception\ErrorException;
|
||||||
|
|
||||||
|
class CachePoolClearTaskTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var RuntimeMockup
|
||||||
|
*/
|
||||||
|
private $runtime;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->runtime = new RuntimeMockup();
|
||||||
|
$this->runtime->setConfiguration(['environments' => ['test' => []]]);
|
||||||
|
$this->runtime->setEnvironment('test');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAsseticDumpTask()
|
||||||
|
{
|
||||||
|
$task = new CachePoolClearTask();
|
||||||
|
$task->setOptions(['env' => 'test']);
|
||||||
|
$task->setRuntime($this->runtime);
|
||||||
|
$this->assertEquals('[Symfony] Cache Pool Clear', $task->getDescription());
|
||||||
|
|
||||||
|
try {
|
||||||
|
$task->execute();
|
||||||
|
} catch (ErrorException $exception) {
|
||||||
|
$this->assertEquals('Parameter "pools" is not defined', $exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@ use Mage\Runtime\Runtime;
|
|||||||
use Mage\Runtime\Exception\RuntimeException;
|
use Mage\Runtime\Exception\RuntimeException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Mage\Tests\MageApplicationMockup;
|
use Mage\Tests\MageApplicationMockup;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
|
||||||
class TaskFactoryTest extends TestCase
|
class TaskFactoryTest extends TestCase
|
||||||
|
@ -13,7 +13,7 @@ namespace Mage\Tests;
|
|||||||
use Mage\Utils;
|
use Mage\Utils;
|
||||||
use Mage\Runtime\Runtime;
|
use Mage\Runtime\Runtime;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class UtilsTest extends TestCase
|
class UtilsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user