From 4859bc4508a04a0ee19c242d1f18345a48a70249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChandan?= Date: Tue, 26 Mar 2024 12:24:24 +0530 Subject: [PATCH 1/3] ACMS-000: Use Drush::bootstrapManager() instead service. --- src/Drush/Commands/MultisiteDrushCommands.php | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Drush/Commands/MultisiteDrushCommands.php b/src/Drush/Commands/MultisiteDrushCommands.php index 9846683..34ec9ca 100644 --- a/src/Drush/Commands/MultisiteDrushCommands.php +++ b/src/Drush/Commands/MultisiteDrushCommands.php @@ -16,6 +16,7 @@ use Drush\Boot\BootstrapManager; use Drush\Boot\DrupalBootLevels; use Drush\Commands\DrushCommands; +use Drush\Drush; use Psr\Container\ContainerInterface as DrushContainer; /** @@ -28,35 +29,20 @@ class MultisiteDrushCommands extends DrushCommands implements CustomEventAwareIn const VALIDATE_GENERATE_SETTINGS = 'validate-generate-settings'; const POST_GENERATE_SETTINGS = 'post-generate-settings'; - /** - * Construct an object of Multisite commands. - */ - public function __construct(private BootstrapManager $bootstrapManager) { - parent::__construct(); - } - - /** - * {@inheritDoc} - */ - public static function createEarly(DrushContainer $drush_container): self { - return new static( - $drush_container->get('bootstrap.manager') - ); - } - /** * Execute code before pre-validate site:install. */ #[CLI\Hook(type: HookManager::PRE_ARGUMENT_VALIDATOR, target: 'site-install')] public function preValidateSiteInstall(CommandData $commandData): void { + $bootstrapManager = Drush::bootstrapManager(); if ($this->validateGenerateSettings($commandData)) { // Get sites subdir which we set in the hook doGenerateSettings. $sitesSubdir = $commandData->input()->getOption('sites-subdir'); // Try to get any already configured database information. - $this->bootstrapManager->bootstrapMax(DrupalBootLevels::CONFIGURATION, $commandData->annotationData()); + $bootstrapManager->bootstrapMax(DrupalBootLevels::CONFIGURATION, $commandData->annotationData()); // By default, bootstrap manager boot site from default/setting.php // hence remove the database connection if site is other than default. - if (($sitesSubdir && "sites/$sitesSubdir" !== $this->bootstrapManager->bootstrap()->confpath())) { + if (($sitesSubdir && "sites/$sitesSubdir" !== $bootstrapManager->bootstrap()->confpath())) { Database::removeConnection('default'); $db = [ 'database' => 'drupal', From 45afedfa4035f4e5575f43a31b799739946d1e3e Mon Sep 17 00:00:00 2001 From: Vishal Khode Date: Tue, 26 Mar 2024 12:58:03 +0530 Subject: [PATCH 2/3] ACMS-3658: Run PHPUnit tests for Drush 11 as well. --- .github/workflows/drs_ci.yml | 12 ++++++++++-- tests/packages_alter.yml | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/drs_ci.yml b/.github/workflows/drs_ci.yml index 342cf77..e5af8b1 100644 --- a/.github/workflows/drs_ci.yml +++ b/.github/workflows/drs_ci.yml @@ -47,7 +47,7 @@ jobs: ../orca/bin/ci/after_failure.sh ../orca/bin/ci/after_script.sh PHPUNIT_TESTS: - name: "Run PHPUnit tests on PHP: ${{ matrix.php-version }}" + name: "Run PHPUnit tests for CORE: ${{ matrix.orca-job }}, PHP: ${{ matrix.php-version }}" runs-on: ubuntu-latest strategy: matrix: @@ -55,8 +55,16 @@ jobs: - 8.1 - 8.2 - 8.3 + orca-job: + - ISOLATED_TEST_ON_CURRENT + - INTEGRATED_TEST_ON_PREVIOUS_MINOR + exclude: + - orca-job: INTEGRATED_TEST_ON_PREVIOUS_MINOR + php-version: 8.3 + - orca-job: INTEGRATED_TEST_ON_PREVIOUS_MINOR + php-version: 8.2 env: - ORCA_JOB: ISOLATED_TEST_ON_CURRENT + ORCA_JOB: ${{ matrix.orca-job }} CI: TRUE ORCA_TEST_BOOTSTRAP_FILE: ${{ github.workspace }}/tests/src/bootstrap.php steps: diff --git a/tests/packages_alter.yml b/tests/packages_alter.yml index c7ec771..ce3522b 100644 --- a/tests/packages_alter.yml +++ b/tests/packages_alter.yml @@ -1,2 +1,12 @@ acquia/drupal-recommended-settings: type: composer-plugin + +drush/drush: + is_company_package: false + core_matrix: + 10.1.x: + version: 11.x + version_dev: 11.x + '*': + version: 12.x + version_dev: 12.x-dev \ No newline at end of file From 3ba20d5cfcf55c5197ef6c2b39db42582d95f4a6 Mon Sep 17 00:00:00 2001 From: Vishal Khode Date: Tue, 26 Mar 2024 13:44:21 +0530 Subject: [PATCH 3/3] ACMS-000: Run PHPUnit tests for DRS only. --- .github/workflows/drs_ci.yml | 2 +- tests/scripts/ci/script.sh | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 tests/scripts/ci/script.sh diff --git a/.github/workflows/drs_ci.yml b/.github/workflows/drs_ci.yml index e5af8b1..137374a 100644 --- a/.github/workflows/drs_ci.yml +++ b/.github/workflows/drs_ci.yml @@ -85,7 +85,7 @@ jobs: - name: Before Script run: ../orca/bin/ci/before_script.sh - name: Script - run: ../orca/bin/ci/script.sh + run: ./tests/scripts/ci/script.sh - name: After script run: | ../orca/bin/ci/after_success.sh diff --git a/tests/scripts/ci/script.sh b/tests/scripts/ci/script.sh new file mode 100755 index 0000000..2211bc2 --- /dev/null +++ b/tests/scripts/ci/script.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# NAME +# script.sh - Run ORCA tests. +# +# SYNOPSIS +# script.sh +# +# DESCRIPTION +# Runs static code analysis and automated tests. + +cd "$(dirname "$0")" || exit; source ../../../../orca/bin/ci/_includes.sh + +if [[ "$ORCA_ENABLE_NIGHTWATCH" == "TRUE" && "$ORCA_SUT_HAS_NIGHTWATCH_TESTS" && -d "$ORCA_YARN_DIR" ]]; then + ( + cd "$ORCA_YARN_DIR" || exit + orca fixture:run-server & + SERVER_PID=$! + + if [[ "$GITLAB_CI" ]]; then + echo "ChromeDriver initialized via separate container..." + else + # @todo could we set DRUPAL_TEST_CHROMEDRIVER_AUTOSTART instead of launching Chromedriver manually? + chromedriver --disable-dev-shm-usage --disable-extensions --disable-gpu --headless --no-sandbox --port=4444 & + CHROMEDRIVER_PID=$! + fi + + eval "yarn test:nightwatch \\ + --headless \\ + --passWithNoTests \\ + --tag=$ORCA_SUT_MACHINE_NAME" + + kill -0 $SERVER_PID + kill -0 $CHROMEDRIVER_PID + ) +fi + +if [[ "$ORCA_JOB" ]]; then + eval "orca fixture:status" + eval "orca qa:automated-tests --sut=$ORCA_SUT_NAME --sut-only" +fi