Odd difference to local phpstan
wlfio opened this issue · 6 comments
Locally I am using phpstan's docker one liner
$ docker run --rm -v /home/wlfio/work/<redacted>:/app phpstan/phpstan --no-interaction --no-progress analyse --error-format=github
Note: Using configuration file /app/phpstan.neon.
[OK] No errors
And getting the above result
using this workflow step
- name: PHPStan Analysis
uses: php-actions/phpstan@v1
with:
error_format: github
I am getting
Command: phpstan --no-interaction --no-progress analyse --error-format=github
Note: Using configuration file /github/workspace/phpstan.neon.
------ --------------------------------------------------------------------
Line src/Config.php
------ --------------------------------------------------------------------
46 Constant APP_ROOT not found.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
49 Constant APP_ROOT not found.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ --------------------------------------------------------------------
This is the neon file
parameters:
level: 3
paths:
- src/
Thanks for reporting this, I will take a look later today to figure out what's the cause.
It would be helpful to see the project in question, but I expect the redacted project name means you can't share this with me? Happy to take a call with you to resolve this, rather than disclose project information here.
Yeh it was a work project unfortunately
However i have managed to recreate it with a minimum codebase here (wlfio/phpstan-test).
If you have make installed locally you can just clone the project, composer install
and run make
in it
Can see the action failing here
Hi @wlfio ,
I have had a look at the issue you're reporting, and I will require more information to solve this for you.
When your action runs, I can see that the issue PhpStan is showing is Constant MAIN_CONST not found.
When I run it locally (using Docker, as per your Makefile), I get the exact same response.
The reason the Github Action is showing this error is because it too uses Docker to run the tests. Might this be due to the version of PHP installed locally on your computer? I believe that PhpStan uses whatever the latest stable version is, which currently is 7.4. I notice in your composer.json that it specifies 7.3.
Either way, I have been working on hosting my own Docker image to act as the baseline image for all the php-actions Actions, so that it will be possible to configure which PHP version is used to execute, etc. If you think that this is the issue here, please let me know and I'll keep you updated with the release of the custom image (should be tomorrow).
Hmm, Ok I'll have another look to see whats going on in my docker environment then.
I fixed the problem in the work project with a bootstrap file.
Also on a side note hosting the docker image would be great, (could even use githubs docker repo feature?).
Would speed up the actions running as they wouldn't need to build. Thus making your php actions cheaper to run.
I love the docker image idea, it works great locally, but I'm having a real tough time getting Github's package repository working. Please see this thread: php-actions/phpunit#16 (comment)
I've got the Docker image working in the composer and phpunit actions, and I'll update this action to v2 with the new changes as soon as I can get time. Watch this space!