Verified Commit d21d1b47 authored by godotislate's avatar godotislate
Browse files

task: #3642228 Update to Symfony 8.2.0 and remove unhelpful minimum stability test coverage

By: longwave
By: alexpott
By: xjm
By: catch
By: godotislate
parent 1f8a5194
Loading
Loading
Loading
Loading
Loading
+142 −128

File changed.

Preview size limit exceeded, changes collapsed.

+20 −20
Changes for composer/Metapackage/CoreRecommended/composer.json: 20 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -27,30 +27,30 @@
        "psr/http-factory": "~1.1.0",
        "psr/log": "~3.0.2",
        "revolt/event-loop": "~v1.0.9",
        "symfony/console": "~v8.2.0-RC1",
        "symfony/dependency-injection": "~v8.2.0-RC1",
        "symfony/console": "~v8.2.0",
        "symfony/dependency-injection": "~v8.2.0",
        "symfony/deprecation-contracts": "~v3.8.1",
        "symfony/error-handler": "~v8.2.0-BETA1",
        "symfony/event-dispatcher": "~v8.2.0-BETA1",
        "symfony/error-handler": "~v8.2.0",
        "symfony/event-dispatcher": "~v8.2.0",
        "symfony/event-dispatcher-contracts": "~v3.8.1",
        "symfony/filesystem": "~v8.2.0-RC1",
        "symfony/finder": "~v8.2.0-RC1",
        "symfony/http-foundation": "~v8.2.0-RC1",
        "symfony/http-kernel": "~v8.2.0-RC1",
        "symfony/mailer": "~v8.2.0-RC1",
        "symfony/mime": "~v8.2.0-RC1",
        "symfony/process": "~v8.2.0-RC1",
        "symfony/psr-http-message-bridge": "~v8.2.0-RC1",
        "symfony/routing": "~v8.2.0-RC1",
        "symfony/runtime": "~v8.2.0-BETA2",
        "symfony/serializer": "~v8.2.0-RC1",
        "symfony/filesystem": "~v8.2.0",
        "symfony/finder": "~v8.2.0",
        "symfony/http-foundation": "~v8.2.0",
        "symfony/http-kernel": "~v8.2.0",
        "symfony/mailer": "~v8.2.0",
        "symfony/mime": "~v8.2.0",
        "symfony/process": "~v8.2.0",
        "symfony/psr-http-message-bridge": "~v8.2.0",
        "symfony/routing": "~v8.2.0",
        "symfony/runtime": "~v8.2.0",
        "symfony/serializer": "~v8.2.0",
        "symfony/service-contracts": "~v3.8.1",
        "symfony/string": "~v8.2.0-RC1",
        "symfony/string": "~v8.2.0",
        "symfony/translation-contracts": "~v3.8.1",
        "symfony/validator": "~v8.2.0-RC1",
        "symfony/var-dumper": "~v8.2.0-BETA2",
        "symfony/var-exporter": "~v8.2.0-BETA1",
        "symfony/yaml": "~v8.2.0-RC1"
        "symfony/validator": "~v8.2.0",
        "symfony/var-dumper": "~v8.2.0",
        "symfony/var-exporter": "~v8.2.0",
        "symfony/yaml": "~v8.2.0"
    },
    "extra": {
        "branch-alias": {
+1 −1
Changes for core/.phpstan-baseline.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -58531,7 +58531,7 @@
in drupal\\:11\\.4\\.0 and is removed from drupal\\:13\\.0\\.0\\. Access
  \\$this\\-\\>root directly\\.$#',
	'identifier' => 'method.deprecated',
	'count' => 4,
	'count' => 2,
	'path' => __DIR__ . '/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php',
];
$ignoreErrors[] = [
+1 −139
Changes for core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php: 1 added line, 139 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
namespace Drupal\BuildTests\Composer\Template;

use Composer\Json\JsonFile;
use Composer\Semver\VersionParser;
use Drupal\BuildTests\Composer\ComposerBuildTestBase;
use Drupal\Composer\Composer;
use PHPUnit\Framework\Attributes\CoversNothing;
@@ -34,15 +33,7 @@ class ComposerProjectTemplatesTest extends ComposerBuildTestBase {
   *
   * @see https://getcomposer.org/doc/04-schema.md#minimum-stability
   */
  protected const MINIMUM_STABILITY = 'beta';

  /**
   * The order of stability strings from least stable to most stable.
   *
   * This only includes normalized stability strings: i.e., ones that are
   * returned by \Composer\Semver\VersionParser::parseStability().
   */
  protected const STABILITY_ORDER = ['dev', 'alpha', 'beta', 'RC', 'stable'];
  protected const MINIMUM_STABILITY = 'stable';

  /**
   * Get Composer items that we want to be path repos, from within a directory.
@@ -84,70 +75,6 @@ public static function provideTemplateCreateProject(): array {
    ];
  }

  /**
   * Make sure that static::MINIMUM_STABILITY is sufficiently strict.
   */
  public function testMinimumStabilityStrictness(): void {
    // Ensure that static::MINIMUM_STABILITY is not less stable than the
    // current core stability. For example, if we've already released a beta on
    // the branch, ensure that we no longer allow alpha dependencies.
    $this->assertGreaterThanOrEqual(array_search($this->getCoreStability(), static::STABILITY_ORDER), array_search(static::MINIMUM_STABILITY, static::STABILITY_ORDER));

    // Ensure that static::MINIMUM_STABILITY is the same as the least stable
    // dependency.
    // - We can't set it stricter than our least stable dependency.
    // - We don't want to set it looser than we need to, because we don't want
    //   to in the future accidentally commit a dependency that regresses our
    //   actual stability requirement without us explicitly changing this
    //   constant.
    $root = $this->getDrupalRoot();
    $process = $this->executeCommand("composer --working-dir=$root info --format=json");
    $this->assertCommandSuccessful();
    $installed = json_decode($process->getOutput(), TRUE);

    // A lookup of the numerical position of each of the stability terms.
    $stability_order_indexes = array_flip(static::STABILITY_ORDER);

    $minimum_stability_order_index = $stability_order_indexes[static::MINIMUM_STABILITY];

    $project_stabilities = [];
    $exclude = [
      'drupal/core',
      'drupal/core-composer-scaffold',
      'drupal/core-recipe-unpack',
      'drupal/core-project-message',
      'drupal/core-vendor-hardening',
    ];
    foreach ($installed['installed'] as $project) {
      // Exclude dependencies that are required with "self.version", since
      // those stabilities will automatically match the corresponding Drupal
      // release.
      if (in_array($project['name'], $exclude, TRUE)) {
        continue;
      }

      // VersionParser::parseStability doesn't play nice with (mostly dev-)
      // versions ending with the first seven characters of the commit ID as
      // returned by "composer info". Let's strip those suffixes here.
      $version = preg_replace('/ [0-9a-f]{7}$/i', '', $project['version']);

      $project_stability = VersionParser::parseStability($version);
      $project_stability_order_index = $stability_order_indexes[$project_stability];

      $project_stabilities[$project['name']] = $project_stability;

      $this->assertGreaterThanOrEqual($minimum_stability_order_index, $project_stability_order_index, sprintf(
        "Dependency %s with stability %s does not meet minimum stability %s.",
        $project['name'],
        $project_stability,
        static::MINIMUM_STABILITY,
      ));
    }

    // At least one project should be at the minimum stability.
    $this->assertContains(static::MINIMUM_STABILITY, $project_stabilities);
  }

  /**
   * Make sure we've accounted for all the templates.
   */
@@ -404,69 +331,4 @@ protected function makeVendorPackage($repository_path): void {
    file_put_contents($repository_path, $json);
  }

  /**
   * Returns the stability of the current core version.
   *
   * If the current core version is a tagged release (not a "-dev" version),
   * this returns the stability of that version.
   *
   * If the current core version is a "-dev" version, but not a "x.y.0-dev"
   * version, this returns "stable", because it means that the corresponding
   * "x.y.0" has already been released, and only stable changes are now
   * permitted on the branch.
   *
   * If the current core version is a "x.y.0-dev" version, then this returns
   * the stability of the latest tag that matches "x.y.0-*". For example, if
   * we've already released "x.y.0-alpha1" but have not yet released
   * "x.y.0-beta1", then the current stability is "alpha". If there aren't any
   * matching tags, this returns "dev", because it means that an "alpha1" has
   * not yet been released.
   *
   * @return string
   *   One of: "dev", "alpha", "beta", "RC", "stable".
   */
  protected function getCoreStability() {
    $version = \Drupal::VERSION;
    // If the current version is x.y-dev then this is the equivalent of the main
    // branch and should be treated as a dev release.
    if (preg_match('/^(\d)+\.(\d)+-dev$/', $version)) {
      return 'dev';
    }
    $stability = VersionParser::parseStability($version);
    if ($stability === 'dev') {
      // Strip off "-dev".
      $version_towards = substr($version, 0, -4);

      if (!str_ends_with($version_towards, '.0')) {
        // If the current version is developing towards an x.y.z release where
        // z is not 0, it means that the x.y.0 has already been released, and
        // only stable changes are permitted on the branch.
        $stability = 'stable';
      }
      else {
        // If the current version is developing towards an x.y.0 release, there
        // might be tagged pre-releases. "git describe" identifies the latest
        // one.
        $root = $this->getDrupalRoot();
        $process = $this->executeCommand("git -C \"$root\" describe --abbrev=0 --match=\"$version_towards-*\"");

        // If there aren't any tagged pre-releases for this version yet, return
        // 'dev'. Ensure that any other error from "git describe" causes a test
        // failure.
        if (!$process->isSuccessful()) {
          $this->assertErrorOutputContains('No names found, cannot describe anything.');
          return 'dev';
        }

        // We expect a pre-release, because:
        // - A tag should not be of "dev" stability.
        // - After a "stable" release is made, \Drupal::VERSION is incremented,
        //   so there should not be a stable release on that new version.
        $stability = VersionParser::parseStability(trim($process->getOutput()));
        $this->assertContains($stability, ['alpha', 'beta', 'RC']);
      }
    }
    return $stability;
  }

}