laravelgithub-actionsphpstanphpmd

PHPStan and PHPMD outputs missing in GitHub Actions but present locally


I'm running PHPStan and PHPMD in my GitHub Actions workflow. Locally, both tools return a list of issues, but in GitHub Actions, no issues are reported. I've made sure the path is right in github actions by ls and pwd. I have no idea what I really need to delve into.

Local Environment:

GitHub Actions Environment:

PHPStan and PHPMD are set up in the workflow as shown below:

  - name: Run PHPStan
run: |
./vendor/bin/phpstan analyse --error-format=raw --no-progress --memory-limit=1G --configuration=./phpstan.neon | reviewdog -f=phpstan -name="PHPStan" -reporter=github-pr-review -level=warning

- name: Run PHPMD
run: |
  php /usr/local/bin/phpmd.phar ./app/Exceptions,./app/Http,./app/Models,./app/Contracts,./app/Repositories,./app/Services,./routes,./tests checkstyle ./phpmd.xml | reviewdog -f=checkstyle -name="PHPMD" -reporter=github-pr-review -level=warning

Logs in github action

- PHPStan -
Run ./vendor/bin/phpstan analyse --error-format=raw --no-progress --memory-limit=1G --configuration=./phpstan.neon | reviewdog  -f=phpstan -name="PHPStan"  -reporter=github-pr-review -level=warning

  ./vendor/bin/phpstan analyse --error-format=raw --no-progress --memory-limit=1G --configuration=./phpstan.neon | reviewdog  -f=phpstan -name="PHPStan"  -reporter=github-pr-review -level=warning
  shell: /usr/bin/bash -e {0}
  env:
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    COMPOSER_NO_AUDIT: 1
    REVIEWDOG_GITHUB_API_TOKEN: ***

- PHPMD -    
Run php /usr/local/bin/phpmd.phar ./app/Exceptions,./app/Http,./app/Models,./app/Contracts,./app/Repositories,./app/Services,./routes,./tests checkstyle phpmd.xml | reviewdog -f=checkstyle -name="PHPMD" -reporter=github-pr-review -level=warning

  php /usr/local/bin/phpmd.phar ./app/Exceptions,./app/Http,./app/Models,./app/Contracts,./app/Repositories,./app/Services,./routes,./tests checkstyle phpmd.xml | reviewdog -f=checkstyle -name="PHPMD" -reporter=github-pr-review -level=warning
  shell: /usr/bin/bash -e {0}
  env:
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    COMPOSER_NO_AUDIT: 1
    REVIEWDOG_GITHUB_API_TOKEN: ***

Has anyone encountered this issue, or can anyone suggest what might be causing this discrepancy between the local and CI environments?


Solution

  • Remove these parts from your commands that run PHPStan:

    So basically run PHPStan as usual as you'd run it locally:

    ./vendor/bin/phpstan analyse --no-progress --memory-limit=1G --configuration=./phpstan.neon
    

    PHPStan automatically detects it runs in GitHub Actions and will output the correct format understood by GitHub Actions to show errors in pull requests on specific lines where the errors occurred.