Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions recipe/deploy/update_code.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@

if ($strategy === 'local_archive') {
$gitRoot = runLocally("git rev-parse --show-toplevel");
runLocally("git -C " . quote($gitRoot) . " archive $targetWithDir -o archive.tar");
upload("$gitRoot/archive.tar", '{{release_path}}/archive.tar');
$archive = tempnam(sys_get_temp_dir(), 'deployer_archive_');
runLocally("git -C " . quote($gitRoot) . " archive $targetWithDir -o " . quote($archive));
upload($archive, '{{release_path}}/archive.tar');
run("tar -xf {{release_path}}/archive.tar -C {{release_path}}");
run("rm {{release_path}}/archive.tar");
unlink("$gitRoot/archive.tar");
unlink($archive);

$rev = quote(runLocally("git rev-list $target -1"));
} else {
Expand Down
46 changes: 46 additions & 0 deletions tests/spec/LocalArchiveTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Deployer;

use spec\SpecTest;
use Symfony\Component\Console\Output\Output;

class LocalArchiveTest extends SpecTest
{
public const RECIPE = __DIR__ . '/recipe/local_archive.php';

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
putenv('DEPLOYER_LOCAL_WORKER=false');
}

public static function tearDownAfterClass(): void
{
putenv('DEPLOYER_LOCAL_WORKER=true');
parent::tearDownAfterClass();
}

public function testParallelLocalArchiveDeploy()
{
$this->init(self::RECIPE);
$this->tester->run([
'deploy',
'selector' => 'all',
'-f' => self::RECIPE,
], [
'verbosity' => Output::VERBOSITY_VERBOSE,
]);

$display = $this->tester->getDisplay();
self::assertEquals(0, $this->tester->getStatusCode(), $display);

foreach ($this->deployer->hosts as $host) {
$deployPath = $host->get('deploy_path');
self::assertFileExists($deployPath . '/current/README.md', $display);
}

$gitRoot = trim((string) shell_exec('git rev-parse --show-toplevel'));
self::assertFileDoesNotExist($gitRoot . '/archive.tar');
}
}
14 changes: 14 additions & 0 deletions tests/spec/recipe/local_archive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Deployer;

require 'recipe/common.php';

set('update_code_strategy', 'local_archive');
set('deploy_path', sys_get_temp_dir() . '/deployer/{{hostname}}');
set('sub_directory', 'tests/fixtures/repository');
set('keep_releases', 1);

localhost('alpha');
localhost('beta');
localhost('gamma');