Skip to content

Commit

Permalink
Adding allowed failure
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan goswami committed Nov 8, 2023
1 parent fd2d142 commit 893474d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/Console/Command/Ci/CiRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Acquia\Orca\Enum\StatusCodeEnum;
use Acquia\Orca\Event\CiEvent;
use Acquia\Orca\Exception\OrcaInvalidArgumentException;
use Acquia\Orca\Helper\EnvFacade;
use Acquia\Orca\Options\CiRunOptionsFactory;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -46,6 +47,13 @@ class CiRunCommand extends Command {
*/
private $eventDispatcher;

/**
* The environment facade.
*
* @var \Acquia\Orca\Helper\EnvFacade
*/
private EnvFacade $env;

/**
* Constructs an instance.
*
Expand All @@ -55,11 +63,14 @@ class CiRunCommand extends Command {
* The CI run options factory.
* @param \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher
* The event dispatcher service.
* @param \Acquia\Orca\Helper\EnvFacade $env
* The environment facade.
*/
public function __construct(CiJobFactory $job_factory, CiRunOptionsFactory $ci_run_options_factory, EventDispatcher $eventDispatcher) {
public function __construct(CiJobFactory $job_factory, CiRunOptionsFactory $ci_run_options_factory, EventDispatcher $eventDispatcher, EnvFacade $env) {
$this->ciJobFactory = $job_factory;
$this->ciRunOptionsFactory = $ci_run_options_factory;
$this->eventDispatcher = $eventDispatcher;
$this->env = $env;
parent::__construct(self::$defaultName);
}

Expand Down Expand Up @@ -131,6 +142,7 @@ public function execute(InputInterface $input, OutputInterface $output): int {
$data['status'] = 'FAIL';
$job = $this->ciJobFactory->create($options->getJob());
$data['version'] = $job->getDrupalCoreVersion();
$data['allowedToFail'] = $this->env->get("ORCA_IS_ALLOWED_FAILURE") ?? FALSE;
$job->run($options);

}
Expand Down
11 changes: 10 additions & 1 deletion tests/Console/Command/Ci/CiRunCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Acquia\Orca\Enum\CiJobPhaseEnum;
use Acquia\Orca\Enum\StatusCodeEnum;
use Acquia\Orca\Exception\OrcaInvalidArgumentException;
use Acquia\Orca\Helper\EnvFacade;
use Acquia\Orca\Options\CiRunOptions;
use Acquia\Orca\Options\CiRunOptionsFactory;
use Acquia\Orca\Tests\Console\Command\CommandTestBase;
Expand All @@ -24,6 +25,8 @@
* @property \Acquia\Orca\Domain\Ci\Job\AbstractCiJob|\Prophecy\Prophecy\ObjectProphecy $ciJob
* @property \Acquia\Orca\Options\CiRunOptionsFactory|\Prophecy\Prophecy\ObjectProphecy $ciRunOptionsFactory
* @property \Acquia\Orca\Options\CiRunOptions|\Prophecy\Prophecy\ObjectProphecy $ciRunOptions
* @property \Symfony\Component\EventDispatcher\EventDispatcher|\Prophecy\Prophecy\ObjectProphecy $eventDispatcher
* @property \Acquia\Orca\Helper\EnvFacade|\Prophecy\Prophecy\ObjectProphecy $env
* @coversDefaultClass \Acquia\Orca\Console\Command\Ci\CiRunCommand
*/
class CiRunCommandTest extends CommandTestBase {
Expand All @@ -35,6 +38,7 @@ class CiRunCommandTest extends CommandTestBase {
protected CiRunOptionsFactory|ObjectProphecy $ciRunOptionsFactory;
protected CiRunOptions|ObjectProphecy $ciRunOptions;
protected EventDispatcher|ObjectProphecy $eventDispatcher;
protected EnvFacade|ObjectProphecy $env;

protected function setUp(): void {
$this->ciRunOptions = $this->prophesize(CiRunOptions::class);
Expand All @@ -54,13 +58,18 @@ protected function setUp(): void {
$this->eventDispatcher
->dispatch(Argument::cetera())
->willReturn(new \stdClass());
$this->env = $this->prophesize(EnvFacade::class);
$this->env
->get(Argument::any())
->willReturn();
}

protected function createCommand(): Command {
$ci_run_options_factory = $this->ciRunOptionsFactory->reveal();
$ci_job_factory = $this->ciJobFactory->reveal();
$event_dispatcher = $this->eventDispatcher->reveal();
return new CiRunCommand($ci_job_factory, $ci_run_options_factory, $event_dispatcher);
$env = $this->env->reveal();
return new CiRunCommand($ci_job_factory, $ci_run_options_factory, $event_dispatcher, $env);
}

private function validSutName(): string {
Expand Down

0 comments on commit 893474d

Please sign in to comment.