Problem/Motivation
The module declares core_version_requirement: ^10.2 || ^11 || ^12, but only Drupal 11 is actually tested. .gitlab-ci.yml opts in to the previous major and next major variants, but the drupal.org GitLab templates make every variant except the current one manual by default (all _AUTORUN_* variables default to 'none'), so the Drupal 10 and Drupal 12 composer jobs wait for a manual start and their phpunit and phpstan jobs are always skipped. See https://project.pages.drupalcode.org/gitlab_templates/info/variants/#aut...
The test metadata is also not read consistently across the supported versions. Most test classes only use docblock annotations (@group, @dataProvider). PHPUnit 11 (Drupal 11) ignores the class docblock as soon as a class has any attribute, so the 29 kernel and functional classes that carry #[RunTestsInSeparateProcesses] are not in the audit group there: "phpunit --group audit" finds 3341 of the 3731 test cases on Drupal 11. PHPUnit 12 (Drupal 12) no longer reads docblock annotations at all, so the groups and the 60 data providers would be ignored there.
In addition, the .gitlab-ci.yml comment says the pipeline fails on coding standards violations, but _PHPCS_ALLOW_FAILURE is not set, and the phpstan and cspell jobs currently fail without failing the pipeline.
Steps to reproduce
Open the latest 1.x pipeline: the previous major and next major jobs are manual or skipped, and the phpstan and cspell jobs fail. On a Drupal 11 site, compare "phpunit --list-tests" with "phpunit --group audit --list-tests" on the module directory.
Proposed resolution
- Set _AUTORUN_PREVIOUS_MAJOR and _AUTORUN_NEXT_MAJOR to 'push-and-mr', so Drupal 10 and Drupal 12 run automatically on pushes and merge requests.
- Set _PHPCS_ALLOW_FAILURE: 0, as the existing comment intends.
- Add the #[Group] and #[DataProvider] attributes next to the existing docblock annotations in every test class, and the @runTestsInSeparateProcesses docblock tag where the attribute is already used, so the same metadata is read on PHPUnit 9, 11 and 12.
- Ignore the "Attribute class PHPUnit\Framework\Attributes\... does not exist." PHPStan message in the tests directories, since those classes do not exist in PHPUnit 9 on Drupal 10.
- Fix the PHPStan errors reported by the current phpstan job: the queue workers declared private readonly promoted properties, which DependencySerializationTrait does not support, so they are now protected; EntityAnalyzer read the revision count through an untyped object and now uses fetchField(); and the functional tests keep their assert() on the created account, which is required on Drupal 10 where createUser() can return FALSE, with that always-true report ignored in tests.
- Add jpegoptim, optipng, pngquant and smush to the cspell project words.
- Fix two analyzer bugs found by tests that failed on sites with more custom code: CacheAnalyzer counted informational context findings as notices in the summary, and StatusAnalyzer reported session.use_strict_mode depending on whether the session service had been created yet. Drupal's SessionManager extends Symfony's NativeSessionStorage, which always enables strict mode at runtime, so that check is removed.
- Fix any further failures reported by the Drupal 10 and Drupal 12 jobs.
Remaining tasks
Review the merge request and check that every job passes on Drupal 10, 11 and 12.
Comments
Comment #5
trebormc