Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #45: Site:install command fails with Drush 11. #48

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/drs_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,24 @@ 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:
php-version:
- 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:
Expand All @@ -77,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
Expand Down
22 changes: 4 additions & 18 deletions src/Drush/Commands/MultisiteDrushCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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',
Expand Down
10 changes: 10 additions & 0 deletions tests/packages_alter.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions tests/scripts/ci/script.sh
Original file line number Diff line number Diff line change
@@ -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