mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	[Nostromo] Rename TarGz tasks to just Tar
This commit is contained in:
		
							parent
							
								
									d7724495a9
								
							
						
					
					
						commit
						c2fffa9003
					
				@ -14,7 +14,7 @@ use Mage\Runtime\Exception\RuntimeException;
 | 
				
			|||||||
use Mage\Runtime\Runtime;
 | 
					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>
 | 
					 * @author Andrés Montañez <andresmontanez@gmail.com>
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@ -44,8 +44,8 @@ class ReleasesStrategy implements StrategyInterface
 | 
				
			|||||||
            array_unshift($tasks, 'git/change-branch');
 | 
					            array_unshift($tasks, 'git/change-branch');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$this->runtime->inRollback() && !in_array('deploy/targz/prepare', $tasks)) {
 | 
					        if (!$this->runtime->inRollback() && !in_array('deploy/tar/prepare', $tasks)) {
 | 
				
			||||||
            array_push($tasks, 'deploy/targz/prepare');
 | 
					            array_push($tasks, 'deploy/tar/prepare');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $tasks;
 | 
					        return $tasks;
 | 
				
			||||||
@ -56,8 +56,8 @@ class ReleasesStrategy implements StrategyInterface
 | 
				
			|||||||
        $this->checkStage(Runtime::ON_DEPLOY);
 | 
					        $this->checkStage(Runtime::ON_DEPLOY);
 | 
				
			||||||
        $tasks = $this->runtime->getTasks();
 | 
					        $tasks = $this->runtime->getTasks();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$this->runtime->inRollback() && !in_array('deploy/targz/copy', $tasks)) {
 | 
					        if (!$this->runtime->inRollback() && !in_array('deploy/tar/copy', $tasks)) {
 | 
				
			||||||
            array_unshift($tasks, 'deploy/targz/copy');
 | 
					            array_unshift($tasks, 'deploy/tar/copy');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$this->runtime->inRollback() && !in_array('deploy/release/prepare', $tasks)) {
 | 
					        if (!$this->runtime->inRollback() && !in_array('deploy/release/prepare', $tasks)) {
 | 
				
			||||||
@ -96,8 +96,8 @@ class ReleasesStrategy implements StrategyInterface
 | 
				
			|||||||
        $this->checkStage(Runtime::POST_DEPLOY);
 | 
					        $this->checkStage(Runtime::POST_DEPLOY);
 | 
				
			||||||
        $tasks = $this->runtime->getTasks();
 | 
					        $tasks = $this->runtime->getTasks();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$this->runtime->inRollback() && !in_array('deploy/targz/cleanup', $tasks)) {
 | 
					        if (!$this->runtime->inRollback() && !in_array('deploy/tar/cleanup', $tasks)) {
 | 
				
			||||||
            array_unshift($tasks, 'deploy/targz/cleanup');
 | 
					            array_unshift($tasks, 'deploy/tar/cleanup');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($this->runtime->getBranch() && !$this->runtime->inRollback() && !in_array('git/change-branch', $tasks)) {
 | 
					        if ($this->runtime->getBranch() && !$this->runtime->inRollback() && !in_array('git/change-branch', $tasks)) {
 | 
				
			||||||
 | 
				
			|||||||
@ -41,7 +41,7 @@ class RsyncTask extends AbstractTask
 | 
				
			|||||||
        $targetDir = rtrim($hostPath, '/');
 | 
					        $targetDir = rtrim($hostPath, '/');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($this->runtime->getEnvOption('releases', false)) {
 | 
					        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();
 | 
					        $excludes = $this->getExcludes();
 | 
				
			||||||
 | 
				
			|||||||
@ -8,14 +8,14 @@
 | 
				
			|||||||
 * file that was distributed with this source code.
 | 
					 * 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 Mage\Task\Exception\ErrorException;
 | 
				
			||||||
use Symfony\Component\Process\Process;
 | 
					use Symfony\Component\Process\Process;
 | 
				
			||||||
use Mage\Task\AbstractTask;
 | 
					use Mage\Task\AbstractTask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * TarGz Task - Delete temporal Tar
 | 
					 * Tar Task - Delete temporal Tar
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author Andrés Montañez <andresmontanez@gmail.com>
 | 
					 * @author Andrés Montañez <andresmontanez@gmail.com>
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@ -23,12 +23,12 @@ class CleanupTask extends AbstractTask
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public function getName()
 | 
					    public function getName()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return 'deploy/targz/cleanup';
 | 
					        return 'deploy/tar/cleanup';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getDescription()
 | 
					    public function getDescription()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return '[Deploy] Cleanup TarGZ file';
 | 
					        return '[Deploy] Cleanup Tar file';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function execute()
 | 
					    public function execute()
 | 
				
			||||||
@ -37,12 +37,12 @@ class CleanupTask extends AbstractTask
 | 
				
			|||||||
            throw new ErrorException('This task is only available with releases enabled', 40);
 | 
					            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 */
 | 
					        /** @var Process $process */
 | 
				
			||||||
        $process = $this->runtime->runLocalCommand($cmdDeleteTarGz);
 | 
					        $process = $this->runtime->runLocalCommand($cmdDeleteTar);
 | 
				
			||||||
        return $process->isSuccessful();
 | 
					        return $process->isSuccessful();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -8,14 +8,14 @@
 | 
				
			|||||||
 * file that was distributed with this source code.
 | 
					 * 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 Mage\Task\Exception\ErrorException;
 | 
				
			||||||
use Symfony\Component\Process\Process;
 | 
					use Symfony\Component\Process\Process;
 | 
				
			||||||
use Mage\Task\AbstractTask;
 | 
					use Mage\Task\AbstractTask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * TarGz Task - Copy Tar
 | 
					 * Tar Task - Copy Tar
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author Andrés Montañez <andresmontanez@gmail.com>
 | 
					 * @author Andrés Montañez <andresmontanez@gmail.com>
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@ -23,12 +23,12 @@ class CopyTask extends AbstractTask
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public function getName()
 | 
					    public function getName()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return 'deploy/targz/copy';
 | 
					        return 'deploy/tar/copy';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getDescription()
 | 
					    public function getDescription()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return '[Deploy] Copying files with TarGZ';
 | 
					        return '[Deploy] Copying files with Tar';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function execute()
 | 
					    public function execute()
 | 
				
			||||||
@ -46,18 +46,18 @@ class CopyTask extends AbstractTask
 | 
				
			|||||||
        $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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $tarGzLocal = $this->runtime->getVar('targz_local');
 | 
					        $tarLocal = $this->runtime->getVar('tar_local');
 | 
				
			||||||
        $tarGzRemote = basename($tarGzLocal);
 | 
					        $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 */
 | 
					        /** @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, $tarGzRemote);
 | 
					            $cmdUnTar = sprintf('cd %s && tar %s %s', $targetDir, $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, $tarGzRemote);
 | 
					                $cmdDelete = sprintf('rm %s/%s', $targetDir, $tarRemote);
 | 
				
			||||||
                $process = $this->runtime->runRemoteCommand($cmdDelete, false);
 | 
					                $process = $this->runtime->runRemoteCommand($cmdDelete, false);
 | 
				
			||||||
                return $process->isSuccessful();
 | 
					                return $process->isSuccessful();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -8,14 +8,14 @@
 | 
				
			|||||||
 * file that was distributed with this source code.
 | 
					 * 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 Mage\Task\Exception\ErrorException;
 | 
				
			||||||
use Symfony\Component\Process\Process;
 | 
					use Symfony\Component\Process\Process;
 | 
				
			||||||
use Mage\Task\AbstractTask;
 | 
					use Mage\Task\AbstractTask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * TarGz Task - Create temporal Tar
 | 
					 * Tar Task - Create temporal Tar
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author Andrés Montañez <andresmontanez@gmail.com>
 | 
					 * @author Andrés Montañez <andresmontanez@gmail.com>
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@ -23,12 +23,12 @@ class PrepareTask extends AbstractTask
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public function getName()
 | 
					    public function getName()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return 'deploy/targz/prepare';
 | 
					        return 'deploy/tar/prepare';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getDescription()
 | 
					    public function getDescription()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return '[Deploy] Preparing TarGz file';
 | 
					        return '[Deploy] Preparing Tar file';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function execute()
 | 
					    public function execute()
 | 
				
			||||||
@ -37,15 +37,15 @@ class PrepareTask extends AbstractTask
 | 
				
			|||||||
            throw new ErrorException('This task is only available with releases enabled', 40);
 | 
					            throw new ErrorException('This task is only available with releases enabled', 40);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $tarGzLocal = $this->runtime->getTempFile();
 | 
					        $tarLocal = $this->runtime->getTempFile();
 | 
				
			||||||
        $this->runtime->setVar('targz_local', $tarGzLocal);
 | 
					        $this->runtime->setVar('tar_local', $tarLocal);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $excludes = $this->getExcludes();
 | 
					        $excludes = $this->getExcludes();
 | 
				
			||||||
        $flags = $this->runtime->getEnvOption('tar_create', 'cfzop');
 | 
					        $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 */
 | 
					        /** @var Process $process */
 | 
				
			||||||
        $process = $this->runtime->runLocalCommand($cmdTarGz, 300);
 | 
					        $process = $this->runtime->runLocalCommand($cmdTar, 300);
 | 
				
			||||||
        return $process->isSuccessful();
 | 
					        return $process->isSuccessful();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -129,7 +129,7 @@ class DeployCommandWithReleasesTest extends TestCase
 | 
				
			|||||||
        $tester = new CommandTester($command);
 | 
					        $tester = new CommandTester($command);
 | 
				
			||||||
        $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
 | 
					        $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());
 | 
					        $this->assertNotEquals(0, $tester->getStatusCode());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -187,7 +187,7 @@ class DeployCommandWithReleasesTest extends TestCase
 | 
				
			|||||||
            $this->assertEquals($command, $ranCommands[$index]);
 | 
					            $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->assertContains('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay());
 | 
				
			||||||
        $this->assertNotEquals(0, $tester->getStatusCode());
 | 
					        $this->assertNotEquals(0, $tester->getStatusCode());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -229,7 +229,7 @@ class DeployCommandWithReleasesTest extends TestCase
 | 
				
			|||||||
            $this->assertEquals($command, $ranCommands[$index]);
 | 
					            $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->assertContains('Stage "On Deploy" did not finished successfully, halting command.', $tester->getDisplay());
 | 
				
			||||||
        $this->assertNotEquals(0, $tester->getStatusCode());
 | 
					        $this->assertNotEquals(0, $tester->getStatusCode());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -283,7 +283,7 @@ class DeployCommandWithReleasesTest extends TestCase
 | 
				
			|||||||
            $this->assertEquals($command, $ranCommands[$index]);
 | 
					            $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->assertContains('Stage "Post Deploy" did not finished successfully, halting command.', $tester->getDisplay());
 | 
				
			||||||
        $this->assertNotEquals(0, $tester->getStatusCode());
 | 
					        $this->assertNotEquals(0, $tester->getStatusCode());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -12,4 +12,4 @@ magephp:
 | 
				
			|||||||
            hosts:
 | 
					            hosts:
 | 
				
			||||||
                - host2
 | 
					                - host2
 | 
				
			||||||
            pre-deploy:
 | 
					            pre-deploy:
 | 
				
			||||||
                - deploy/targz/prepare
 | 
					                - deploy/tar/prepare
 | 
				
			||||||
@ -12,4 +12,4 @@ magephp:
 | 
				
			|||||||
            hosts:
 | 
					            hosts:
 | 
				
			||||||
                - host2
 | 
					                - host2
 | 
				
			||||||
            on-deploy:
 | 
					            on-deploy:
 | 
				
			||||||
                - deploy/targz/copy
 | 
					                - deploy/tar/copy
 | 
				
			||||||
@ -12,4 +12,4 @@ magephp:
 | 
				
			|||||||
            hosts:
 | 
					            hosts:
 | 
				
			||||||
                - host2
 | 
					                - host2
 | 
				
			||||||
            post-deploy:
 | 
					            post-deploy:
 | 
				
			||||||
                - deploy/targz/cleanup
 | 
					                - deploy/tar/cleanup
 | 
				
			||||||
@ -20,4 +20,4 @@ magephp:
 | 
				
			|||||||
            on-release:
 | 
					            on-release:
 | 
				
			||||||
            post-release:
 | 
					            post-release:
 | 
				
			||||||
            post-deploy:
 | 
					            post-deploy:
 | 
				
			||||||
                - deploy/targz/cleanup
 | 
					                - deploy/tar/cleanup
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user