Skip to content

Commit

Permalink
[Nostromo] Rename TarGz tasks to just Tar
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-montanez committed Jan 15, 2017
1 parent d772449 commit c2fffa9
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 40 deletions.
14 changes: 7 additions & 7 deletions src/Deploy/Strategy/ReleasesStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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>
*/
Expand Down Expand Up @@ -44,8 +44,8 @@ public function getPreDeployTasks()
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;
Expand All @@ -56,8 +56,8 @@ public function getOnDeployTasks()
$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)) {
Expand Down Expand Up @@ -96,8 +96,8 @@ public function getPostDeployTasks()
$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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Task/BuiltIn/Deploy/RsyncTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function execute()
$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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
* 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>
*/
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()
Expand All @@ -37,12 +37,12 @@ public function execute()
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
* 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>
*/
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()
Expand All @@ -46,18 +46,18 @@ public function execute()
$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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
* 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>
*/
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()
Expand All @@ -37,15 +37,15 @@ public function execute()
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();
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Command/BuiltIn/DeployCommandWithReleasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function testDeploymentFailCopyCommands()
$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());
}

Expand Down Expand Up @@ -187,7 +187,7 @@ public function testDeploymentFailToExtract()
$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());
}
Expand Down Expand Up @@ -229,7 +229,7 @@ public function testDeploymentFailToCopy()
$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());
}
Expand Down Expand Up @@ -283,7 +283,7 @@ public function testDeploymentFailCleanup()
$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());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Resources/testhost-force-tar1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ magephp:
hosts:
- host2
pre-deploy:
- deploy/targz/prepare
- deploy/tar/prepare
2 changes: 1 addition & 1 deletion tests/Resources/testhost-force-tar2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ magephp:
hosts:
- host2
on-deploy:
- deploy/targz/copy
- deploy/tar/copy
2 changes: 1 addition & 1 deletion tests/Resources/testhost-force-tar3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ magephp:
hosts:
- host2
post-deploy:
- deploy/targz/cleanup
- deploy/tar/cleanup
2 changes: 1 addition & 1 deletion tests/Resources/testhost-with-postdeploy-error.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ magephp:
on-release:
post-release:
post-deploy:
- deploy/targz/cleanup
- deploy/tar/cleanup

0 comments on commit c2fffa9

Please sign in to comment.