Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## | ||
| # A reusable workflow that checks the PHP coding standards. | ||
| ## | ||
| name: PHP coding standards | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| php-version: | ||
| description: 'The PHP version to use.' | ||
| required: false | ||
| type: 'string' | ||
| default: 'latest' | ||
| old-branch: | ||
| description: 'Whether this is an old branch that runs phpcbf instead of phpcs' | ||
| required: false | ||
| type: 'boolean' | ||
| default: false | ||
| <<<<<<< Updated upstream | ||
| <<<<<<< Updated upstream | ||
| ======= | ||
| ======= | ||
| >>>>>>> Stashed changes | ||
| # Disable permissions for all available scopes by default. | ||
| # Any needed permissions should be configured at the job level. | ||
| permissions: {} | ||
| <<<<<<< Updated upstream | ||
| >>>>>>> Stashed changes | ||
| ======= | ||
| >>>>>>> Stashed changes | ||
| jobs: | ||
| # Runs the PHP coding standards checks. | ||
| # | ||
| # Violations are reported inline with annotations. | ||
| # | ||
| # Performs the following steps: | ||
| # - Checks out the repository. | ||
| # - Sets up PHP. | ||
| # - Configures caching for PHPCS scans. | ||
| # - Installs Composer dependencies. | ||
| # - Make Composer packages available globally. | ||
| # - Runs PHPCS on the full codebase (warnings excluded). | ||
| # - Generate a report for displaying issues as pull request annotations. | ||
| # - Runs PHPCS on the `tests` directory without (warnings included). | ||
| # - Generate a report for displaying `test` directory issues as pull request annotations. | ||
| # - Ensures version-controlled files are not modified or deleted. | ||
| phpcs: | ||
| name: Run coding standards checks | ||
| runs-on: ubuntu-24.04 | ||
| permissions: | ||
| contents: read | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | ||
| persist-credentials: false | ||
| - name: Set up PHP | ||
| <<<<<<< Updated upstream | ||
| <<<<<<< Updated upstream | ||
| uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 | ||
| ======= | ||
| uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0 | ||
| >>>>>>> Stashed changes | ||
| ======= | ||
| uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0 | ||
| >>>>>>> Stashed changes | ||
| with: | ||
| php-version: ${{ inputs.php-version }} | ||
| coverage: none | ||
| tools: cs2pr | ||
| # This date is used to ensure that the PHPCS cache is cleared at least once every week. | ||
| # http://man7.org/linux/man-pages/man1/date.1.html | ||
| - name: "Get last Monday's date" | ||
| id: get-date | ||
| run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT" | ||
| - name: Cache PHPCS scan cache | ||
| <<<<<<< Updated upstream | ||
| <<<<<<< Updated upstream | ||
| uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
| ======= | ||
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | ||
| >>>>>>> Stashed changes | ||
| ======= | ||
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | ||
| >>>>>>> Stashed changes | ||
| with: | ||
| path: | | ||
| .cache/phpcs-src.json | ||
| .cache/phpcs-tests.json | ||
| key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-php-${{ inputs.php-version }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }} | ||
| # Since Composer dependencies are installed using `composer update` and no lock file is in version control, | ||
| # passing a custom cache suffix ensures that the cache is flushed at least once per week. | ||
| - name: Install Composer dependencies | ||
| uses: ramsey/composer-install@a2636af0004d1c0499ffca16ac0b4cc94df70565 # v3.1.0 | ||
| with: | ||
| custom-cache-suffix: ${{ steps.get-date.outputs.date }} | ||
| - name: Make Composer packages available globally | ||
| run: echo "${PWD}/vendor/bin" >> "$GITHUB_PATH" | ||
| - name: Run PHPCS on all Core files | ||
| id: phpcs-core | ||
| if: ${{ ! inputs.old-branch }} | ||
| run: phpcs -n --report-full --cache=./.cache/phpcs-src.json --report-checkstyle=./.cache/phpcs-report.xml | ||
| - name: Show PHPCS results in PR | ||
| if: ${{ always() && steps.phpcs-core.outcome == 'failure' }} | ||
| run: cs2pr ./.cache/phpcs-report.xml | ||
| - name: Check test suite files for warnings | ||
| id: phpcs-tests | ||
| if: ${{ ! inputs.old-branch }} | ||
| run: phpcs tests --report-full --cache=./.cache/phpcs-tests.json --report-checkstyle=./.cache/phpcs-tests-report.xml | ||
| - name: Show test suite scan results in PR | ||
| if: ${{ always() && steps.phpcs-tests.outcome == 'failure' }} | ||
| run: cs2pr ./.cache/phpcs-tests-report.xml | ||
| - name: Run PHPCBF on all Core files (old branches) | ||
| if: ${{ inputs.old-branch }} | ||
| run: phpcbf | ||
| - name: Ensure version-controlled files are not modified during the tests | ||
| run: git diff --exit-code | ||