[Nostromo] Rename TarGz tasks to just Tar

This commit is contained in:
Andrés Montañez 2017-01-14 22:36:15 -03:00
parent d7724495a9
commit c2fffa9003
10 changed files with 40 additions and 40 deletions

View file

@ -14,7 +14,7 @@ use Mage\Runtime\Exception\RuntimeException;
use Mage\Runtime\Runtime;
/**
* Strategy for Deployment with Releases, using TarGz and SCP
* Strategy for Deployment with Releases, using Tar and SCP
*
* @author Andrés Montañez <andresmontanez@gmail.com>
*/
@ -44,8 +44,8 @@ class ReleasesStrategy implements StrategyInterface
array_unshift($tasks, 'git/change-branch');
}
if (!$this->runtime->inRollback() && !in_array('deploy/targz/prepare', $tasks)) {
array_push($tasks, 'deploy/targz/prepare');
if (!$this->runtime->inRollback() && !in_array('deploy/tar/prepare', $tasks)) {
array_push($tasks, 'deploy/tar/prepare');
}
return $tasks;
@ -56,8 +56,8 @@ class ReleasesStrategy implements StrategyInterface
$this->checkStage(Runtime::ON_DEPLOY);
$tasks = $this->runtime->getTasks();
if (!$this->runtime->inRollback() && !in_array('deploy/targz/copy', $tasks)) {
array_unshift($tasks, 'deploy/targz/copy');
if (!$this->runtime->inRollback() && !in_array('deploy/tar/copy', $tasks)) {
array_unshift($tasks, 'deploy/tar/copy');
}
if (!$this->runtime->inRollback() && !in_array('deploy/release/prepare', $tasks)) {
@ -96,8 +96,8 @@ class ReleasesStrategy implements StrategyInterface
$this->checkStage(Runtime::POST_DEPLOY);
$tasks = $this->runtime->getTasks();
if (!$this->runtime->inRollback() && !in_array('deploy/targz/cleanup', $tasks)) {
array_unshift($tasks, 'deploy/targz/cleanup');
if (!$this->runtime->inRollback() && !in_array('deploy/tar/cleanup', $tasks)) {
array_unshift($tasks, 'deploy/tar/cleanup');
}
if ($this->runtime->getBranch() && !$this->runtime->inRollback() && !in_array('git/change-branch', $tasks)) {

View file

@ -41,7 +41,7 @@ class RsyncTask extends AbstractTask
$targetDir = rtrim($hostPath, '/');
if ($this->runtime->getEnvOption('releases', false)) {
throw new ErrorException('Can\'t be used with Releases, use "deploy/targz/copy"');
throw new ErrorException('Can\'t be used with Releases, use "deploy/tar/copy"');
}
$excludes = $this->getExcludes();

View file

@ -8,14 +8,14 @@
* file that was distributed with this source code.
*/
namespace Mage\Task\BuiltIn\Deploy\TarGz;
namespace Mage\Task\BuiltIn\Deploy\Tar;
use Mage\Task\Exception\ErrorException;
use Symfony\Component\Process\Process;
use Mage\Task\AbstractTask;
/**
* TarGz Task - Delete temporal Tar
* Tar Task - Delete temporal Tar
*
* @author Andrés Montañez <andresmontanez@gmail.com>
*/
@ -23,12 +23,12 @@ class CleanupTask extends AbstractTask
{
public function getName()
{
return 'deploy/targz/cleanup';
return 'deploy/tar/cleanup';
}
public function getDescription()
{
return '[Deploy] Cleanup TarGZ file';
return '[Deploy] Cleanup Tar file';
}
public function execute()
@ -37,12 +37,12 @@ class CleanupTask extends AbstractTask
throw new ErrorException('This task is only available with releases enabled', 40);
}
$tarGzLocal = $this->runtime->getVar('targz_local');
$tarLocal = $this->runtime->getVar('tar_local');
$cmdDeleteTarGz = sprintf('rm %s', $tarGzLocal);
$cmdDeleteTar = sprintf('rm %s', $tarLocal);
/** @var Process $process */
$process = $this->runtime->runLocalCommand($cmdDeleteTarGz);
$process = $this->runtime->runLocalCommand($cmdDeleteTar);
return $process->isSuccessful();
}
}

View file

@ -8,14 +8,14 @@
* file that was distributed with this source code.
*/
namespace Mage\Task\BuiltIn\Deploy\TarGz;
namespace Mage\Task\BuiltIn\Deploy\Tar;
use Mage\Task\Exception\ErrorException;
use Symfony\Component\Process\Process;
use Mage\Task\AbstractTask;
/**
* TarGz Task - Copy Tar
* Tar Task - Copy Tar
*
* @author Andrés Montañez <andresmontanez@gmail.com>
*/
@ -23,12 +23,12 @@ class CopyTask extends AbstractTask
{
public function getName()
{
return 'deploy/targz/copy';
return 'deploy/tar/copy';
}
public function getDescription()
{
return '[Deploy] Copying files with TarGZ';
return '[Deploy] Copying files with Tar';
}
public function execute()
@ -46,18 +46,18 @@ class CopyTask extends AbstractTask
$flags = $this->runtime->getEnvOption('tar_extract', 'xfzop');
$targetDir = sprintf('%s/releases/%s', $hostPath, $currentReleaseId);
$tarGzLocal = $this->runtime->getVar('targz_local');
$tarGzRemote = basename($tarGzLocal);
$tarLocal = $this->runtime->getVar('tar_local');
$tarRemote = basename($tarLocal);
$cmdCopy = sprintf('scp -P %d %s %s %s@%s:%s/%s', $sshConfig['port'], $sshConfig['flags'], $tarGzLocal, $user, $host, $targetDir, $tarGzRemote);
$cmdCopy = sprintf('scp -P %d %s %s %s@%s:%s/%s', $sshConfig['port'], $sshConfig['flags'], $tarLocal, $user, $host, $targetDir, $tarRemote);
/** @var Process $process */
$process = $this->runtime->runLocalCommand($cmdCopy, 300);
if ($process->isSuccessful()) {
$cmdUnTar = sprintf('cd %s && tar %s %s', $targetDir, $flags, $tarGzRemote);
$cmdUnTar = sprintf('cd %s && tar %s %s', $targetDir, $flags, $tarRemote);
$process = $this->runtime->runRemoteCommand($cmdUnTar, false, 600);
if ($process->isSuccessful()) {
$cmdDelete = sprintf('rm %s/%s', $targetDir, $tarGzRemote);
$cmdDelete = sprintf('rm %s/%s', $targetDir, $tarRemote);
$process = $this->runtime->runRemoteCommand($cmdDelete, false);
return $process->isSuccessful();
}

View file

@ -8,14 +8,14 @@
* file that was distributed with this source code.
*/
namespace Mage\Task\BuiltIn\Deploy\TarGz;
namespace Mage\Task\BuiltIn\Deploy\Tar;
use Mage\Task\Exception\ErrorException;
use Symfony\Component\Process\Process;
use Mage\Task\AbstractTask;
/**
* TarGz Task - Create temporal Tar
* Tar Task - Create temporal Tar
*
* @author Andrés Montañez <andresmontanez@gmail.com>
*/
@ -23,12 +23,12 @@ class PrepareTask extends AbstractTask
{
public function getName()
{
return 'deploy/targz/prepare';
return 'deploy/tar/prepare';
}
public function getDescription()
{
return '[Deploy] Preparing TarGz file';
return '[Deploy] Preparing Tar file';
}
public function execute()
@ -37,15 +37,15 @@ class PrepareTask extends AbstractTask
throw new ErrorException('This task is only available with releases enabled', 40);
}
$tarGzLocal = $this->runtime->getTempFile();
$this->runtime->setVar('targz_local', $tarGzLocal);
$tarLocal = $this->runtime->getTempFile();
$this->runtime->setVar('tar_local', $tarLocal);
$excludes = $this->getExcludes();
$flags = $this->runtime->getEnvOption('tar_create', 'cfzop');
$cmdTarGz = sprintf('tar %s %s %s ./', $flags, $tarGzLocal, $excludes);
$cmdTar = sprintf('tar %s %s %s ./', $flags, $tarLocal, $excludes);
/** @var Process $process */
$process = $this->runtime->runLocalCommand($cmdTarGz, 300);
$process = $this->runtime->runLocalCommand($cmdTar, 300);
return $process->isSuccessful();
}

View file

@ -129,7 +129,7 @@ class DeployCommandWithReleasesTest extends TestCase
$tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$this->assertContains('Copying files with TarGZ ... FAIL', $tester->getDisplay());
$this->assertContains('Copying files with Tar ... FAIL', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode());
}
@ -187,7 +187,7 @@ class DeployCommandWithReleasesTest extends TestCase
$this->assertEquals($command, $ranCommands[$index]);
}
$this->assertContains('Running [Deploy] Copying files with TarGZ ... FAIL', $tester->getDisplay());
$this->assertContains('Running [Deploy] Copying files with Tar ... FAIL', $tester->getDisplay());
$this->assertContains('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode());
}
@ -229,7 +229,7 @@ class DeployCommandWithReleasesTest extends TestCase
$this->assertEquals($command, $ranCommands[$index]);
}
$this->assertContains('Running [Deploy] Copying files with TarGZ ... FAIL', $tester->getDisplay());
$this->assertContains('Running [Deploy] Copying files with Tar ... FAIL', $tester->getDisplay());
$this->assertContains('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode());
}
@ -283,7 +283,7 @@ class DeployCommandWithReleasesTest extends TestCase
$this->assertEquals($command, $ranCommands[$index]);
}
$this->assertContains('Running [Deploy] Cleanup TarGZ file ... FAIL', $tester->getDisplay());
$this->assertContains('Running [Deploy] Cleanup Tar file ... FAIL', $tester->getDisplay());
$this->assertContains('Stage "Post Deploy" did not finished successfully, halting command.', $tester->getDisplay());
$this->assertNotEquals(0, $tester->getStatusCode());
}

View file

@ -12,4 +12,4 @@ magephp:
hosts:
- host2
pre-deploy:
- deploy/targz/prepare
- deploy/tar/prepare

View file

@ -12,4 +12,4 @@ magephp:
hosts:
- host2
on-deploy:
- deploy/targz/copy
- deploy/tar/copy

View file

@ -12,4 +12,4 @@ magephp:
hosts:
- host2
post-deploy:
- deploy/targz/cleanup
- deploy/tar/cleanup

View file

@ -20,4 +20,4 @@ magephp:
on-release:
post-release:
post-deploy:
- deploy/targz/cleanup
- deploy/tar/cleanup