Add Symfony LSP diagnostics to CI - #88
Open
loevgaard wants to merge 3 commits into
Open
Conversation
Run `symfony lsp:check` (https://symfony.com/blog/introducing-symfony-lsp-check-symfony-aware-diagnostics-in-your-ci) as a new "symfony-diagnostics" job so that unknown routes, services, templates, translation keys, deprecated configuration keys etc. are reported as GitHub annotations. symfony-lsp only discovers a Symfony application when its composer.json requires symfony/framework-bundle and, to boot it, needs a PSR-4 entry pointing at the kernel plus <project>/vendor/autoload.php. The test application is not a standalone Composer project, so: - tests/Application/composer.json declares the framework-bundle requirement and the PSR-4 namespace of the kernel (nothing is ever installed from this file) - tests/Application/vendor is a symlink to the root vendor directory - .symfony-lsp.json points symfony-lsp at tests/Application and enables translation diagnostics
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.2.x #88 +/- ##
=========================================
Coverage 75.00% 75.00%
Complexity 3 3
=========================================
Files 3 3
Lines 8 8
=========================================
Hits 6 6
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Two dependency releases broke the test application, independent of the Symfony LSP integration. Nothing in CI noticed, because tests/Functional is empty and no job loaded the API routes until now. - symfony/type-info >= 7.4.6 (and >= 8.0.6) collects @phpstan-template tags and rejects the "Loggable|object" template bound that gedmo/doctrine-extensions declares on AbstractLogEntry, which Sylius' AddressLogEntry extends. API Platform runs into it while building the identifier metadata of that resource, so loading the routes, and with it cache:warmup and every request, fails on Symfony 7.4. Until doctrine-extensions/DoctrineExtensions#3046 is released, symfony/type-info is kept below 7.4.6, which in turn requires symfony/property-info below 7.4.7. See doctrine-extensions/DoctrineExtensions#3044 - doctrine/orm 3.7.0 validates that the inverse side of an association targets the owning entity (doctrine/orm#12460). Sylius' ShipmentUnit#shipment / Shipment#units mapping does not satisfy that, so doctrine:schema:validate fails. doctrine/orm is kept below 3.7 until Sylius handles it. Both pins live in require-dev and therefore only affect this repository and plugins generated from it, never projects installing a plugin.
The check belongs with the other lint steps rather than in a job of its own. The Symfony CLI is downloaded from its GitHub release because the coding-standards composite action does not install it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integrates symfony lsp:check into the build workflow as a step of the
coding-standardsjob, right after thesetono/sylius-plugin/coding-standards@v2action. It runssymfony lsp:check --format=github, so unknown routes/services/templates/translation keys, deprecated config keys etc. show up as annotations on pull requests. The Symfony CLI is downloaded from its GitHub release because the composite action does not install it; moving both into that action so every plugin gets the check would be a natural follow-up.Repository changes needed for symfony-lsp to find and boot the test application
symfony-lsp discovers an application only if its
composer.jsonrequiressymfony/framework-bundle, locates the kernel through a PSR-4 entry in thatcomposer.json, and boots it via<project>/vendor/autoload.php. The test application is not a standalone Composer project, hence:tests/Application/composer.jsonnow declares thesymfony/framework-bundlerequirement and the PSR-4 namespace of the kernel. Nothing is ever installed from this file; it is only a marker (as it already was for project-dir resolving).tests/Application/vendoris a symlink to the rootvendordirectory. PHPUnit 11 only scanstests/Unitandtests/Functional, and ECS/PHPStan/Rector do not follow symlinks, so no other tooling is affected..symfony-lsp.jsonpoints symfony-lsp attests/Applicationand enables translation diagnostics.CLAUDE.mddocuments the command.Dependency pins needed to make the test application work at all
Two upstream releases had already broken the test application on this branch. Nothing in CI noticed, because
tests/Functionalis empty and no job loaded the API routes until this check. Both pins are inrequire-dev, so they affect only this repository and the plugins generated from it, never projects installing a plugin.symfony/type-info: <7.4.6andsymfony/property-info: ^6.4 || >=7.4 <7.4.7. type-info 7.4.6 / 8.0.6 started collecting@phpstan-templatetags and rejects theLoggable|objectbound that gedmo declares onAbstractLogEntry, which Sylius'AddressLogEntryextends. API Platform hits it while building identifier metadata for that resource, so loading the routes,cache:warmupand every request failed on Symfony 7.4. property-info 7.4.7+ requires type-info 7.4.7+, hence the second pin. Upstream: Incompatibility with symfony/type-info > 8.0.4 doctrine-extensions/DoctrineExtensions#3044, fix pending in Fix Loggable template bounds for Symfony TypeInfo compatibility doctrine-extensions/DoctrineExtensions#3046. Drop both pins once that ships.doctrine/orm: <3.7. ORM 3.7.0 added a schema validation (SchemaValidator should report inverseBy targeting a different entity doctrine/orm#12460) that Sylius'ShipmentUnit#shipment/Shipment#unitsmapping fails, which broke thedoctrine:schema:validatestep of every functional-tests job. Sylius already conflicts with other broken ORM patch releases, so this pin can go once Sylius handles 3.7.Verification (local, PHP 8.4, symfony-lsp 0.20.0, Symfony packages pinned to 7.4 like CI does)
bin/console cache:warmupfails before the pins and succeeds after;debug:routerlists 393 routesdoctrine:schema:validate --skip-sync: mapping files are correctsymfony-lsp check: runtime metadata, 0 diagnostics, exit code 0composer validate --strictandcomposer normalize --dry-runpassRunning the check locally requires the Symfony CLI 5.20 or newer (
symfony lsp:check), or the standalonesymfony-lspbinary from https://github.com/symfony/language-tools/releases.