From 9b45519ffcf57b16986f27be2b0e28274b4ea9dd Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Thu, 10 Nov 2022 12:29:53 +0300 Subject: [PATCH] Add github action for static analysis code --- .github/workflows/static-analysis.yml | 87 ++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 .github/workflows/static-analysis.yml diff --git a/ .github/workflows/static-analysis.yml b/ .github/workflows/static-analysis.yml new file mode 100755 index 0000000..3def7a8 --- /dev/null +++ b/ .github/workflows/static-analysis.yml @@ -0,0 +1,87 @@ +name: "Static analysis code" + +on: + - push + - pull_request + +env: + COMPOSER_FLAGS: "--ansi --prefer-dist --no-interaction --no-progress" + +jobs: + + ## PHP linter + linter: + name: "Check syntax errors" + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: + - "7.2" + - "7.3" + - "7.4" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: ${{ matrix.php-version }} + + - name: "Lint PHP files" + run: find ./src -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f + + ## PHPSTAN + phpstan: + name: "PHP Static Analysis" + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: + - "7.2" + - "7.3" + - "7.4" + steps: + - name: "Cancel Previous Runs" + uses: styfle/cancel-workflow-action@0.9.0 + with: + all_but_latest: true + access_token: ${{ github.token }} + + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: ${{ matrix.php-version }} + + - name: "Setup github auth token for composer" + run: composer config github-oauth.github.com ${{ github.token }} + + - name: "Get composer cache directory" + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: "Cache Composer Directory" + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: "Composer Install" + run: | + composer install ${{ env.COMPOSER_FLAGS }} + rm composer.lock + composer config platform.php ${{ matrix.php }} + + - name: Run phpstan + run: composer phpstan \ No newline at end of file