diff --git a/.github/workflows/phpcs_on_pull_request.yml b/.github/workflows/phpcs_on_pull_request.yml index ba827aa1..6936961b 100644 --- a/.github/workflows/phpcs_on_pull_request.yml +++ b/.github/workflows/phpcs_on_pull_request.yml @@ -1,15 +1,51 @@ -on: pull_request name: Inspections +on: + pull_request: + types: + - opened + - synchronize + - ready_for_review + +# Cancel previous workflow run groups that have not completed. +concurrency: + # Group workflow runs by workflow name, along with the head branch ref of the pull request + # or otherwise the branch or tag ref. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} + cancel-in-progress: true + jobs: runPHPCSInspection: name: Run PHPCS inspection runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - - name: Run PHPCS inspection - uses: rtCamp/action-phpcs-code-review@master - env: - SKIP_FOLDERS: "tests,.github" - GH_BOT_TOKEN: ${{ secrets.RTBOT_TOKEN }} + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.0" + coverage: none + + - name: Configure Composer cache + uses: actions/cache@v3.0.5 + id: php-composer-cache + env: + SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5' + with: + path: vendor + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install Composer dependencies + if: ${{ steps.php-composer-cache.outputs.cache-hit != 'true' }} + run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction + + - name: Validate composer.json + run: composer --no-interaction validate --no-check-all + - name: Run PHPCS inspection + uses: rtCamp/action-phpcs-code-review@master + env: + SKIP_FOLDERS: "tests,.github" + GH_BOT_TOKEN: ${{ secrets.RTBOT_TOKEN }}