├── Dockerfile ├── LICENSE ├── README.md ├── action.yml └── entrypoint.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.0-alpine 2 | 3 | ENV REVIEWDOG_VERSION=v0.9.17 4 | 5 | RUN apk --no-cache add git 6 | RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ 7 | RUN wget -c https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar && mv phpstan.phar /usr/local/bin 8 | 9 | COPY entrypoint.sh /entrypoint.sh 10 | 11 | ENTRYPOINT ["/entrypoint.sh"] 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 GeneaLabs, LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Action: Run PHPSTAN with ReviewDog 2 | This action runs [PHP Static Analyzer](https://phpstan.org) with [ReviewDog](https://github.com/reviewdog/reviewdog). 3 | 4 | ## Inputs 5 | ### `github_token` 6 | **Required** Must be in form of `github_token: ${{ secrets.github_token }}` 7 | 8 | ### `level` 9 | Report level for reviewdog [info,warning,error]. It's same as `-level` flag of reviewdog. 10 | **Default** `warning` 11 | 12 | ### `phpstan_level` 13 | Report level for phpstan. 14 | **Default** `4` 15 | 16 | ### `reporter` 17 | Reporter of reviewdog command [github-pr-check,github-check,github-pr-review]. It's same as `-reporter` flag of reviewdog. 18 | **Default** `github-pr-check` 19 | 20 | ### `target_directory` 21 | **Default** `src` 22 | 23 | ### `fail_on_error` 24 | Fail on error. 25 | **Default** `false` 26 | 27 | ### `args` 28 | This is a catch-all for any other commandline arguments you want to add to PHPStan. 29 | **Default** '' 30 | 31 | ## Usage 32 | ```yml 33 | 34 | phpstan-linter: 35 | name: PHPStan 36 | runs-on: ubuntu-latest 37 | steps: 38 | - name: Check out code into the workspace 39 | uses: actions/checkout@v2 40 | - name: Run php check code with reviewdog 41 | uses: GeneaLabs/action-reviewdog-phpstan@1.1.2 42 | with: 43 | github_token: '${{ github.token }}' 44 | level: 'error' 45 | fail_on_error: 'false' 46 | phpstan_level: 4 47 | reporter: 'github-pr-review' 48 | target_directory: 'src' 49 | ``` 50 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Run PHPStan with ReviewDog' 2 | description: '🐾 Run PHP Static Analyzer with ReviewDog.' 3 | author: 'Mike Bronner' 4 | inputs: 5 | github_token: 6 | description: 'GITHUB_TOKEN' 7 | default: '${{ github.token }}' 8 | 9 | level: 10 | description: 'Report level for reviewdog [info,warning,error].' 11 | default: 'warning' 12 | 13 | phpstan_level: 14 | description: 'Report level for phpstan.' 15 | default: '4' 16 | 17 | reporter: 18 | description: 'Reporter of reviewdog command [github-pr-check,github-pr-review].' 19 | default: 'github-pr-check' 20 | 21 | target_directory: 22 | description: Directory to run checks against. 23 | default: 'src' 24 | 25 | fail_on_error: 26 | description: Fail on error. 27 | default: 'false' 28 | 29 | args: 30 | description: Catch-all for any command-line arguments you would like to add. 31 | default: '' 32 | 33 | runs: 34 | using: 'docker' 35 | image: 'Dockerfile' 36 | args: 37 | - ${{ inputs.github_token }} 38 | - ${{ inputs.level }} 39 | - ${{ inputs.reporter }} 40 | - ${{ inputs.target_directory }} 41 | - ${{ inputs.args }} 42 | - ${{ inputs.fail_on_error }} 43 | - ${{ inputs.phpstan_level }} 44 | 45 | branding: 46 | icon: 'check-circle' 47 | color: 'green' 48 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ -n "${GITHUB_WORKSPACE}" ]; then 5 | cd "${GITHUB_WORKSPACE}" || exit 6 | git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 1 7 | fi 8 | 9 | export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" 10 | 11 | php /usr/local/bin/phpstan.phar analyse ${INPUT_TARGET_DIRECTORY} --level=${INPUT_PHPSTAN_LEVEL} --memory-limit 1G --error-format=raw ${INPUT_ARGS} \ 12 | | reviewdog -name=PHPStan -f=phpstan -reporter=${INPUT_REPORTER} -fail-on-error=${INPUT_FAIL_ON_ERROR} -level=${INPUT_LEVEL} -diff='git diff' 13 | --------------------------------------------------------------------------------