Skip to content

Commit

Permalink
Domo Improvements (acquia#438)
Browse files Browse the repository at this point in the history
* Adding allowed failure

* add sheet2

* add sheet2

* revert sheet 1

* add branch

* Update script.sh

* formatting

* Update tests/Console/Command/Ci/CiRunCommandTest.php

Co-authored-by: Travis Carden <[email protected]>

* adding a last line

* Update src/Console/Command/Ci/CiRunCommand.php

Co-authored-by: Travis Carden <[email protected]>

* move to sheet1

* fix tests

* testing

* check return values

* add debug message

* add debug 5

* add trap

* missing dollar sign

* bash fix

* change to SIGINT

* new approach

* final fix

---------

Co-authored-by: Travis Carden <[email protected]>
  • Loading branch information
Sayan Goswami and TravisCarden authored Nov 28, 2023
1 parent bca6236 commit 598ef3c
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 10 deletions.
4 changes: 1 addition & 3 deletions .idea/orca.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/php-test-framework.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion bin/ci/_includes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,17 @@ allowed_failures=(
"INTEGRATED_TEST_ON_NEXT_MAJOR_LATEST_MINOR_BETA_OR_LATER"
)
if [[ " ${allowed_failures[*]} " =~ " ${ORCA_JOB} " ]]; then
set +e
export ORCA_IS_ALLOWED_FAILURE="TRUE"
notice "This job is allowed to fail and will report as passing regardless of outcome."
fi

function shutdown() {
if [[ "$ORCA_IS_ALLOWED_FAILURE" == "TRUE" ]]; then
exit 0
fi
}

trap shutdown ERR

# Make the shell print all lines in the script before executing them.
set -v
9 changes: 5 additions & 4 deletions bin/ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

cd "$(dirname "$0")" || exit; source _includes.sh

if [[ "$ORCA_JOB" ]]; then
eval "orca ci:run $ORCA_JOB script $ORCA_SUT_NAME"
fi

if [[ "$ORCA_ENABLE_NIGHTWATCH" == "TRUE" && "$ORCA_SUT_HAS_NIGHTWATCH_TESTS" && -d "$ORCA_YARN_DIR" ]]; then
(
cd "$ORCA_YARN_DIR" || exit
Expand All @@ -34,3 +30,8 @@ if [[ "$ORCA_ENABLE_NIGHTWATCH" == "TRUE" && "$ORCA_SUT_HAS_NIGHTWATCH_TESTS" &&
kill -0 $CHROMEDRIVER_PID
)
fi

if [[ "$ORCA_JOB" ]]; then
eval "orca ci:run $ORCA_JOB script $ORCA_SUT_NAME"
fi

15 changes: 14 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,8 @@ 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);
$data['branch'] = $this->env->get("ORCA_SUT_BRANCH", FALSE);
$job->run($options);

}
Expand Down
2 changes: 2 additions & 0 deletions src/Helper/Log/GoogleApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public function postData(array $data): void {
$data['version'],
PHP_VERSION,
$data['status'],
$data['allowedToFail'],
$data['branch'],
],
],
],
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(), FALSE)
->willReturn(NULL);
}

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
4 changes: 4 additions & 0 deletions tests/Helper/Log/GoogleApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public function testPostDataWithNullVersion(): void {
'sut' => 'drupal/example',
'status' => 'PASS',
'version' => NULL,
'allowedToFail' => TRUE,
'branch' => 'main',
];
$this->version
->resolvePredefined(Argument::any())
Expand All @@ -99,6 +101,8 @@ public function testPostDataWithLatestDrupalVersion(): void {
'sut' => 'drupal/example',
'status' => 'PASS',
'version' => DrupalCoreVersionEnum::CURRENT(),
'allowedToFail' => TRUE,
'branch' => 'main',
];
$this->version
->existsPredefined(Argument::any())
Expand Down

0 comments on commit 598ef3c

Please sign in to comment.