-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
PHPStan support not compatible with gitlabci #92
Comments
is there a contrib module you can point to that demonstrates the issue? |
Its been true on any module I've tested. For example, I have a module that uses this baseline that I built to work in gitlab-ci on d.o
If I run phpstan in ddev all these are reported.
Updating through ddev generates this diff
But if you push that to drupal.org the pipeline fails because the files don't exist in the https://git.drupalcode.org/project/coveo/-/jobs/3226498 You can see this commit fixing the phpstan failures by using the correct paths. |
Proof: and the manually fixed baseline: https://git.drupalcode.org/project/view_usernames/-/blob/1.0.0/phpstan-baseline.neon?ref_type=tags |
PR welcome |
I'm happy to make a MR but I'm not sure how to fix this. The two options I see are:
|
Option 2 extension, how about looping through every directory in web/modules/custom, opening the directories and running phpstan in them? That would eliminate the hardcoded module name problem and also the path issue in phpstan-baseline.neon. |
That seems like it would be leaning into the Drupalism while simultaneously making it impossible for the ddev command to generate the baseline since its being run multiple times instead of a single process. 1 seems like the better use of the tool if I'm honest because it keeps the implementation simple and lets PHPstan handle the complexity the way it normally would for any other project. |
I've found that adding this to phpstan.neon:
And then modifying the phpstan command to analyze files in the basedir:
Works in my case. Thanks to @neclimdul for these suggestions. Not sure how this issue hasn't been brought up more times, I found it quite surprising that phpstan with a baseline did not work. Either you have it fixed for local work and it fails on Drupal CI or you have it fixed for Drupal CI and it fails locally, making it impossible to invoke pre-commit hooks. Though this all goes away if you don't have a baseline and have your codebase fixed up so maybe that's the reason. |
The PHPStan support this provides runs in web/modules/custom/ which means that the baselines aren't compatible with those that would be generated for gitlab-ci. This makes it much less useful for testing a module and fixing CI issues.
The text was updated successfully, but these errors were encountered: