fruivita/corporate

View on GitHub
.github/workflows/static.yml

Summary

Maintainability
Test Coverage
###############################################################################
# About GitHub Actions                                                        #
# https://docs.github.com/en/actions/learn-github-actions                     #
# https://www.youtube.com/watch?v=TLB5MY9BBa4                                 #
###############################################################################
#
# Perform static analysis of php code and force style standardization.
#
# PHPStan: static analysis https://phpstan.org/
# PHP CS Fixer: php code pattern https://github.com/FriendsOfPHP/PHP-CS-Fixer

name: Static Analysis

on: ['workflow_dispatch', 'push', 'pull_request']

concurrency:
  group: static-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:

  php-cs-fixer:
    runs-on: ubuntu-latest

    name: PHP Coding Standards Fixer

    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          ref: ${{ github.head_ref }}

      - name: Run PHP CS Fixer
        uses: docker://oskarstark/php-cs-fixer-ga
        with:
          args: -v --config=.php-cs-fixer.dist.php --allow-risky=yes

      - name: Auto Commit
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: 'style: code pattern with php-cs-fixer'
          branch: ${{ github.head_ref }}

  phpstan:
    runs-on: ubuntu-latest

    name: PHPStan - PHP Static Analysis Tool

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.0'
          tools: composer:v2
          coverage: none

      - name: Install Dependencies
        run: composer update --prefer-stable --no-interaction --no-progress

      - name: Run PHPStan
        run: vendor/bin/phpstan analyse --ansi --memory-limit 1G --error-format=github --debug