mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 01:02:24 +01:00
Fix task(...)->once() with --parallel and --limit (#1784)
* add test to show issue with once() used with --parallel and --limit issue * handle once() in a better way to prevent issue with --parallel and --limit
This commit is contained in:
parent
02f7585af5
commit
f8ecded38c
@ -24,6 +24,7 @@
|
||||
- Fixed Laravel `laravel_version` failure
|
||||
- Fixed parser errors by adding the trim function to the changelog parser tokens
|
||||
- Fixed arguments for rsync to be properly escaped
|
||||
- Prevent multiple execution of task()->once() with --parallel and --limit option [#1419]
|
||||
|
||||
|
||||
## v6.3.0
|
||||
|
@ -126,7 +126,7 @@ class ParallelExecutor implements ExecutorInterface
|
||||
if ($task->shouldBePerformed($host)) {
|
||||
$processes[$host->getHostname()] = $this->getProcess($host, $task);
|
||||
if ($task->isOnce()) {
|
||||
break;
|
||||
$task->setHasRun();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -319,4 +319,14 @@ class Task
|
||||
{
|
||||
return $this->shallow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal this is used by ParallelExecutor and prevent multiple run
|
||||
*/
|
||||
public function setHasRun()
|
||||
{
|
||||
if ($this->isOnce()) {
|
||||
$this->hasRun = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ require 'recipe/common.php';
|
||||
|
||||
// Hosts
|
||||
|
||||
localhost('host[1:2]')
|
||||
localhost('host[1:4]')
|
||||
->set('deploy_path', __DIR__ . '/tmp/localhost');
|
||||
|
||||
|
||||
|
@ -33,5 +33,23 @@ class ParallelOnceTest extends DepCase
|
||||
|
||||
self::assertFileExists(self::$currentPath . '/deployed-host1');
|
||||
self::assertFileNotExists(self::$currentPath . '/deployed-host2');
|
||||
self::assertFileNotExists(self::$currentPath . '/deployed-host3');
|
||||
self::assertFileNotExists(self::$currentPath . '/deployed-host4');
|
||||
}
|
||||
|
||||
public function testOnceWithLimit()
|
||||
{
|
||||
$output = $this->start('deploy', [
|
||||
'--parallel' => true,
|
||||
'--limit' => 2,
|
||||
'--file' => DEPLOYER_FIXTURES . '/recipe/parallel.php'
|
||||
], [
|
||||
'verbosity' => OutputInterface::VERBOSITY_DEBUG
|
||||
]);
|
||||
|
||||
self::assertFileExists(self::$currentPath . '/deployed-host1');
|
||||
self::assertFileNotExists(self::$currentPath . '/deployed-host2');
|
||||
self::assertFileNotExists(self::$currentPath . '/deployed-host3');
|
||||
self::assertFileNotExists(self::$currentPath . '/deployed-host4');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user