diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c812b74e..dcc2fd09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,11 +41,11 @@ jobs: build_test: strategy: matrix: - drupal-version: [ 9, 8 ] + drupal-version: [ 9, 10 ] fail-fast: false runs-on: ubuntu-latest container: - image: quay.io/pantheon-public/build-tools-ci:8.x-php7.4 + image: quay.io/pantheon-public/build-tools-ci:8.x-php8.1 options: --user root name: Build and test (Drupal ${{ matrix.drupal-version }}) env: diff --git a/README.md b/README.md index a87cced4..54dd00dd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Search API Pantheon version 8.0 (for solr 8 & Drupal 8/9) +# Search API Pantheon version 8.0 (for solr 8 & Drupal 9/10) [![Search API Pantheon](https://github.com/pantheon-systems/search_api_pantheon/actions/workflows/ci.yml/badge.svg?branch=8.x)](https://github.com/pantheon-systems/search_api_pantheon/actions/workflows/ci.yml) [![Limited Availability](https://img.shields.io/badge/Pantheon-Limited_Availability-yellow?logo=pantheon&color=FFDC28)](https://pantheon.io/docs/oss-support-levels#limited-availability) @@ -10,7 +10,7 @@ This module is for you if you meet the following requirements: -* Using Drupal 8.8/9.2+ +* Using Drupal 9.4/10 * Hosting the Drupal site on Pantheon's platform @@ -49,7 +49,7 @@ Composer is the way you should be managing your drupal module requirements. This - [Search API Solr](https://www.drupal.org/project/search_api_solr). Search API Solr makes search API work with Apache Solr. Composer will manage which version. -- [Guzzle](https://docs.guzzlephp.org/en/stable/). Guzzle version 6 is standard with Drupal Core `8.x | 9.x` (read 8.x OR 9.x). +- [Guzzle](https://docs.guzzlephp.org/en/stable/). Guzzle version 6 is standard with Drupal Core `9.x | 10.x` (read 9.x OR 10.x). ## Install @@ -233,4 +233,4 @@ with the concept usage in a Solr context: * `drush search-api-pantheon:force-cleanup` (`sapfc`) This command will delete all of the contents for the given - Solr server (no matter if hash or index_id have changed). \ No newline at end of file + Solr server (no matter if hash or index_id have changed). diff --git a/RoboFile.php b/RoboFile.php index e0cdcc64..f2e8f46a 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -80,11 +80,13 @@ public function testFull(int $drupal_version = 9, string $site_name = NULL) { $this->testCreateSite($site_name, $options); $this->testConnectionGit($site_name, 'dev', 'git'); $this->testCloneSite($site_name); - $this->testAllowPlugins($site_name); + $this->testAllowPlugins($site_name, $drupal_version); + $this->testPhpVersion($site_name); - // If received Drupal 8, downgrade the recently created site to Drupal 8. - if ($drupal_version === 8) { - $this->testDowngradeToDrupal8($site_name); + // If received Drupal 10, upgrade the recently created site to Drupal 10. + if ($drupal_version === 10) { + // @todo Make it downgrade to Drupal 9 when Drupal 10 becomes the default version. + $this->testUpgradeToDrupal10($site_name); } // Composer require the corresponding modules, push to Pantheon and install the site. @@ -180,7 +182,7 @@ public function testCreateSite(string $site_name, array $options = ['org' => NUL if (empty($site_info)) { $home = $_SERVER['HOME']; $toReturn = $this->taskExec(static::$TERMINUS_EXE) - ->args('site:create', $site_name, $site_name, 'drupal9'); + ->args('site:create', $site_name, $site_name, 'drupal-composer-managed'); if ( !empty( $options['org'] ) ) { $toReturn->option('org', $options['org']); } @@ -308,26 +310,101 @@ public function testCloneSite(string $site_name) { * * @param string $site_name * The machine name of the site to add the allow plugins section to. + * @param int $drupal_version + * The major version of Drupal to use. */ - public function testAllowPlugins(string $site_name) { - $site_folder = $this->getSiteFolder($site_name); - chdir($site_folder); + public function testAllowPlugins(string $site_name, int $drupal_version) { $plugins = [ - 'composer/installers', - 'drupal/core-composer-scaffold', - 'cweagans/composer-patches', + 'drupal/core-project-message', ]; + if ($drupal_version === 10) { + $plugins[] = 'phpstan/extension-installer'; + // @todo Remove once all of the modules have been correctly upgraded. + $plugins[] = 'mglaman/composer-drupal-lenient'; + } + if (count($plugins)) { + $site_folder = $this->getSiteFolder($site_name); + chdir($site_folder); + + foreach ($plugins as $plugin_name) { + $this->taskExec('composer') + ->args( + 'config', + '--no-interaction', + 'allow-plugins.' . $plugin_name, + 'true' + ) + ->run(); + } + } + } + + /** + * Upgrade given site to Drupal 10. + * + * @param string $site_name + * The machine name of the site to downgrade. + */ + public function testUpgradeToDrupal10(string $site_name) { + $site_folder = $this->getSiteFolder($site_name); + chdir($site_folder); + + // Remove composer lock. + $this->taskExec('rm') + ->args('composer.lock') + ->run(); + + $this->taskExec('composer') + ->args( + 'config', + 'minimum-stability', + 'dev' + ) + ->run(); + + $this->taskExec('composer') + ->args( + 'config', + 'platform.php', + '8.1' + ) + ->run(); + + $this->taskExec('composer') + ->args( + 'require', + '--no-update', + 'drupal/core-recommended:^10', + 'drupal/core-project-message:^10', + 'drupal/core-composer-scaffold:^10', + 'pantheon-systems/drupal-integrations:^10', + 'mglaman/composer-drupal-lenient' + ) + ->run(); + + $this->taskExec('composer') + ->args( + 'require', + '--no-update', + '--dev', + 'drupal/core-dev:^10' + ) + ->run(); - foreach ($plugins as $plugin_name) { - $this->taskExec('composer') + $this->taskExec('composer') + ->args('update') + ->run(); + + $this->taskExec('composer') ->args( 'config', - '--no-interaction', - 'allow-plugins.' . $plugin_name, - 'true' + '--merge', + '--json', + 'extra.drupal-lenient.allowed-list', + '["drupal/search_api_pantheon"]' ) ->run(); - } + return ResultData::EXITCODE_OK; } /** @@ -373,11 +450,18 @@ public function testDowngradeToDrupal8(string $site_name) { public function testRequireSolr(string $site_name, string $constraint = '^8') { $site_folder = $this->getSiteFolder($site_name); chdir($site_folder); + // Always test again latest version of search_api_solr. $this->taskExec('composer') ->args( - 'require', - 'pantheon-systems/search_api_pantheon ' . $constraint, - ) + 'require', + 'drupal/search_api_solr:dev-4.x', + ) + ->run(); + $this->taskExec('composer') + ->args( + 'require', + 'pantheon-systems/search_api_pantheon ' . $constraint, + ) ->run(); return ResultData::EXITCODE_OK; } @@ -648,6 +732,21 @@ protected function siteInfo(string $site_name) { return NULL; } + /** + * Set correct PHP version for the given site. + * + * @param string $site_name + * The machine name of the site to set the Solr version for. + */ + public function testPhpVersion(string $site_name) { + $site_folder = $this->getSiteFolder($site_name); + $pantheon_yml_contents = Yaml::parseFile($site_folder . '/pantheon.yml'); + $pantheon_yml_contents['php_version'] = 8.1; + $pantheon_yml_contents = Yaml::dump($pantheon_yml_contents); + file_put_contents($site_folder . '/pantheon.yml', $pantheon_yml_contents); + $this->output->writeln($pantheon_yml_contents); + } + /** * Set correct Solr version for the given site. * @@ -679,7 +778,7 @@ public function testSolrIndexCreate(string $site_name, string $env = 'dev') { '--', 'cim', '--partial', - '--source=modules/composer/search_api_pantheon/.ci/config', + '--source=modules/contrib/search_api_pantheon/.ci/config', '-y' ) ->run(); diff --git a/composer.json b/composer.json index 33391e19..c2ee5268 100644 --- a/composer.json +++ b/composer.json @@ -42,12 +42,11 @@ "ext-json": "*", "ext-zip": "*", "drupal/search_api_solr": "^4.2", - "guzzlehttp/guzzle": "^6.5.2", + "guzzlehttp/guzzle": "^6.5.2|^7.4", "http-interop/http-factory-guzzle": "^1.0", "kint-php/kint": "^4.1", - "php-http/guzzle6-adapter": "^2.0", "psr/event-dispatcher": "^1.0", - "symfony/finder": "^4|^5" + "symfony/finder": "^4.4|^5|^6" }, "require-dev": { "consolidation/robo": "^3.0", diff --git a/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml b/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml index ed8b21b6..55910169 100644 --- a/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml +++ b/modules/search_api_pantheon_admin/search_api_pantheon_admin.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon Admin type: module description: Administer a Pantheon Search server -core_version_requirement: ^8.8 || ^9 +core_version_requirement: ^9.4 || ^10 package: Search dependencies: - search_api_solr:search_api_solr diff --git a/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml b/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml index 6103488f..dbf6b77e 100644 --- a/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml +++ b/modules/search_api_pantheon_examples/search_api_pantheon_examples.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon Examples type: module description: Contains some examples of things you could do with Search API Pantheon module. This module should not be enabled in prod. -core_version_requirement: ^8.8 || ^9 +core_version_requirement: ^9.4 || ^10 package: Search dependencies: - search_api_pantheon:search_api_pantheon diff --git a/search_api_pantheon.info.yml b/search_api_pantheon.info.yml index 650d0c9d..46e2f95a 100644 --- a/search_api_pantheon.info.yml +++ b/search_api_pantheon.info.yml @@ -1,7 +1,7 @@ name: Search API Pantheon type: module description: Search API + Solr + Pantheon integration -core_version_requirement: ^8.8 || ^9 +core_version_requirement: ^9.4 || ^10 package: Search dependencies: - search_api_solr:search_api_solr diff --git a/src/Plugin/SolrConnector/PantheonSolrConnector.php b/src/Plugin/SolrConnector/PantheonSolrConnector.php index 2f87711e..05bd5882 100644 --- a/src/Plugin/SolrConnector/PantheonSolrConnector.php +++ b/src/Plugin/SolrConnector/PantheonSolrConnector.php @@ -8,8 +8,6 @@ use Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase; use Drupal\search_api_solr\SolrConnectorInterface; use Drupal\search_api_pantheon\Services\Endpoint as PantheonEndpoint; -use Psr\Log\LoggerAwareInterface; -use Psr\Log\LoggerAwareTrait; use Solarium\Client as SolariumClient; use Solarium\Core\Client\Endpoint; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -31,9 +29,7 @@ class PantheonSolrConnector extends SolrConnectorPluginBase implements SolrConnectorInterface, PluginFormInterface, - ContainerFactoryPluginInterface, - LoggerAwareInterface { - use LoggerAwareTrait; + ContainerFactoryPluginInterface { /** * @var object|null diff --git a/src/Solarium/EventDispatcher/EventProxy.php b/src/Solarium/EventDispatcher/EventProxy.php index 1a76e1bc..dd6543a4 100644 --- a/src/Solarium/EventDispatcher/EventProxy.php +++ b/src/Solarium/EventDispatcher/EventProxy.php @@ -2,7 +2,7 @@ namespace Drupal\search_api_pantheon\Solarium\EventDispatcher; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; /** * A proxy for events defined by symfony contracts to be used with older Drupal. diff --git a/src/Solarium/EventDispatcher/Psr14Bridge.php b/src/Solarium/EventDispatcher/Psr14Bridge.php index 572012d3..bf797de2 100644 --- a/src/Solarium/EventDispatcher/Psr14Bridge.php +++ b/src/Solarium/EventDispatcher/Psr14Bridge.php @@ -4,7 +4,7 @@ use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; use Psr\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; /** * A helper to decorate the legacy EventDispatcherInterface::dispatch().