name: Code style and static analysis

on:
    pull_request:
    push:
        branches: [ master ]

jobs:
    composer-validate:
        name: Validate composer.json
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v2.0.0

            - name: Validate
              run: composer validate --no-check-lock --strict

    php-cs-fixer:
        name: PHP-CS-Fixer
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v2

            - name: Setup PHP
              uses: shivammathur/setup-php@v2

            - name: Install PHP-CS-Fixer
              run: composer global require friendsofphp/php-cs-fixer --prefer-dist --no-progress

            - name: Run script
              run: $HOME/.composer/vendor/bin/php-cs-fixer fix --verbose --diff --dry-run

    phpstan:
        name: PHPStan
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v2

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

            - name: Install dependencies
              run: composer install

            - name: Run script
              run: vendor/bin/phpstan analyse

name: Code style and static analysis

on:
    pull_request:
    push:
        branches: [ master ]

jobs:
    composer-validate:
        name: Validate composer.json
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v2.0.0

            - name: Validate
              run: composer validate --no-check-lock --strict

    php-cs-fixer:
        name: PHP-CS-Fixer
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v2

            - name: Setup PHP
              uses: shivammathur/setup-php@v2

            - name: Install PHP-CS-Fixer
              run: composer global require friendsofphp/php-cs-fixer --prefer-dist --no-progress

            - name: Run script
              run: $HOME/.composer/vendor/bin/php-cs-fixer fix --verbose --diff --dry-run

    phpstan:
        name: PHPStan
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v2

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

            - name: Install dependencies
              run: composer install

            - name: Run script
              run: vendor/bin/phpstan analyse

    # Fail CI if repo is in dirty state after bin/update_readme
    update-readme:
        name: bin/update_readme
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v2

            - name: Setup PHP
              uses: shivammathur/setup-php@v2

            - name: Install dependencies
              run: composer install

            - name: Check Status
              run: ./bin/update_readme && git diff --exit-code README.md

Bring back bin/update-readme status check to CI again
Bring back bin/update-readme status check to CI again
