At my company we use Gitlab CI and for most projects we use phpcs to scan our codebase. The stage might take more time then is necessary because it’s scanning all files instead of just the ones that have changed. Because of this we are now using the following line to make it a lot faster (the slowest part is spinning up the docker container).
1 | codestyle: |
The git diff will output a list of files which are saved to a temporary text file. And to check whether the diff actually outputs something we cat the file.
phpcs accepts a file with a filelisting as last argument.