Skip to content

Commit 0c4b396

Browse files
authored
Merge branch 'develop' into imported-magento-magento-cloud-docker-296
2 parents c59c870 + e6784c7 commit 0c4b396

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

tests/functional/Codeception/TestInfrastructure.php

+44-15
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,40 @@ public function addArtifactsRepoToComposer(): bool
303303
*/
304304
public function addDependencyToComposer(string $name, string $version): bool
305305
{
306-
return $this->taskComposerRequire('composer')
307-
->dependency($name, $version)
308-
->noInteraction()
309-
->option('--no-update')
310-
->printOutput($this->_getConfig('printOutput'))
311-
->interactive(false)
312-
->dir($this->getWorkDirPath())
313-
->run()
314-
->wasSuccessful();
306+
return $this->retry(
307+
function () use ($name, $version) {
308+
return $this->taskComposerRequire('composer')
309+
->dependency($name, $version)
310+
->noInteraction()
311+
->option('--no-update')
312+
->printOutput($this->_getConfig('printOutput'))
313+
->interactive(false)
314+
->dir($this->getWorkDirPath())
315+
->run()
316+
->wasSuccessful();
317+
}
318+
);
319+
}
320+
321+
/**
322+
* @param callable $callback
323+
* @param int $retries
324+
* @return bool
325+
*/
326+
private function retry(callable $callback, int $retries = 2): bool
327+
{
328+
$result = false;
329+
330+
for ($i = $retries; $i > 0; $i--) {
331+
$result = $callback();
332+
if ($result) {
333+
return $result;
334+
}
335+
336+
sleep(5);
337+
}
338+
339+
return $result;
315340
}
316341

317342
/**
@@ -507,12 +532,16 @@ public function replaceImagesWithCurrentDockerVersion(): bool
507532
*/
508533
public function composerUpdate(): bool
509534
{
510-
return $this->taskComposerUpdate('composer')
511-
->printOutput($this->_getConfig('printOutput'))
512-
->interactive(false)
513-
->dir($this->getWorkDirPath())
514-
->run()
515-
->wasSuccessful();
535+
return $this->retry(
536+
function () {
537+
return $this->taskComposerUpdate('composer')
538+
->printOutput($this->_getConfig('printOutput'))
539+
->interactive(false)
540+
->dir($this->getWorkDirPath())
541+
->run()
542+
->wasSuccessful();
543+
}
544+
);
516545
}
517546

518547
/**

0 commit comments

Comments
 (0)