-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add PHPStan Github Action #38
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
phpstan-baseline.neon
Outdated
parameters: | ||
ignoreErrors: | ||
- | ||
message: "#^Call to an undefined method DOMNode\\:\\:setAttribute\\(\\)\\.$#" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it because of the dom extension missing on the phpqa image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not. Had this inconsistency on another project as well. Typehinting it as DOMElement
instead solves this error.
The object actually isn't a DOMNode
. This is because of the return signature on appendChild
in PHP core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, would be great to document how to use jakzal/phpqa with github actions. I'd appreciate a PR if you have some spare time. Otherwise I'll try to do it in the next couple of weeks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will send you a PR once this one is ready 👍
Locally the baseline file gets used. Any idea why it's not used by Github checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you're testing with the latest image locally. PHPStan was recently updated.
5f0d1c4
to
1fd9533
Compare
4b7f002
to
2195817
Compare
Having problems with getting the tests green. Although using My current assumption is that a working directory volume isn't mounted under @odolbeau probably the same applies to #40 as tests are way too fast there. Can you make the cs-fixer output more verbose? |
@rvanlaak I introduced a "error" on purpose on #40 & it looks like it's working like a charm: https://github.com/php-translation/symfony-storage/pull/40/checks?check_run_id=337944668 |
Why do we need to mount the Have you tried:
I read somewhere it might not work with If everything fails we can add a WORKING_DIRECTORY env variable to jakzal/phpqa and change the working path in the entry point. |
composer.json
Outdated
@@ -10,6 +10,7 @@ | |||
], | |||
"require": { | |||
"php": "^7.2", | |||
"ext-intl": "*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really a hard requirement?
@rvanlaak Could we consider using https://github.com/OskarStark/phpstan-ga for this Github action in order to move forward please? |
runs-on: ubuntu-latest | ||
services: | ||
volumes: | ||
- .:/project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a quick test on one of my projects. You don't need to mount any directories, github will do it for you.
This is all you need:
name: Static code analysis
on: [pull_request]
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run PHPStan
uses: docker://jakzal/phpqa:php7.3-alpine
with:
args: sh -c 'composer install && phpstan analyze src/ -l 1'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think to make it work jakzal/phpqa needs to be updated to run composer etc.
- name: Run PHPStan | ||
uses: docker://jakzal/phpqa:php7.3-alpine | ||
with: | ||
args: sh -c 'composer install && phpstan analyze src/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated jakzal/phpqa to install composer dependencies if it is run as a github action (jakzal/phpqa#185).
As soon as docker hub builds images all you will need is args: phpstan analyze src/
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Then I'll change the action to running phpstan using the minimum required amount of code, and wait until the images are pushed before rerunning the build 👍
39dbbc6
to
a4dee5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for me, thanks! :)
PHPStan baseline is added to ignore current state. Baseline file should get removed together with #39