Merge pull request #2024 from PHPCompatibility/feature/ghactions-pin-… #2485
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
| name: CS | |
| on: | |
| # Run on all pushes and on all pull requests. | |
| push: | |
| pull_request: | |
| # Allow manually triggering the workflow. | |
| workflow_dispatch: | |
| # Cancels all previous workflow runs for the same branch that have not yet completed. | |
| concurrency: | |
| # The concurrency group contains the workflow name and the branch name. | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| checkcs: | |
| name: 'Basic CS and QA checks' | |
| runs-on: ubuntu-latest | |
| env: | |
| # - COMPOSER_ROOT_VERSION is needed to get round the recursive dependency when using CI. | |
| COMPOSER_ROOT_VERSION: '10.99.99' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Install PHP | |
| uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0 | |
| with: | |
| php-version: 'latest' | |
| coverage: none | |
| tools: cs2pr | |
| - name: 'Composer: adjust dependencies' | |
| run: | | |
| # Using PHPCS `4.x` as an early detection system for bugs upstream. | |
| composer require --no-update squizlabs/php_codesniffer:"4.x-dev" --no-interaction | |
| # Install dependencies and handle caching in one go. | |
| # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer | |
| - name: Install Composer dependencies | |
| uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1 | |
| with: | |
| # Bust the cache at least once a month - output format: YYYY-MM. | |
| custom-cache-suffix: $(date -u "+%Y-%m") | |
| - name: Validate ruleset XML file against schema | |
| uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1 | |
| with: | |
| pattern: "PHPCompatibility/ruleset.xml" | |
| xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd" | |
| - name: Validate documentation XML files against schema | |
| uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1 | |
| with: | |
| pattern: "./PHPCompatibility/Docs/*/*Standard.xml" | |
| xsd-file: "vendor/phpcsstandards/phpcsdevtools/DocsXsd/phpcsdocs.xsd" | |
| - name: Validate Project PHPCS ruleset against schema | |
| uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1 | |
| with: | |
| pattern: "phpcs.xml.dist" | |
| xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd" | |
| - name: "Validate PHPUnit < 10 config for use with PHPUnit 8" | |
| uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1 | |
| with: | |
| pattern: "phpunit.xml.dist" | |
| xsd-file: "vendor/phpunit/phpunit/schema/8.5.xsd" | |
| - name: "Validate PHPUnit < 10 config for use with PHPUnit 9" | |
| uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1 | |
| with: | |
| pattern: "phpunit.xml.dist" | |
| xsd-file: "vendor/phpunit/phpunit/schema/9.2.xsd" | |
| - name: "Validate PHPUnit 10+ config for use with PHPUnit 10" | |
| uses: phpcsstandards/xmllint-validate@0fd9c4a9046055f621fca4bbdccb8eab1fd59fdc # v1.0.1 | |
| with: | |
| pattern: "phpunit10.xml.dist" | |
| xsd-file: "vendor/phpunit/phpunit/phpunit.xsd" | |
| # Check the code-style consistency of the PHP files. | |
| - name: Check PHP code style | |
| id: phpcs | |
| run: vendor/bin/phpcs --no-cache --report-full --report-checkstyle=./phpcs-report.xml | |
| - name: Show PHPCS results in PR | |
| if: ${{ always() && steps.phpcs.outcome == 'failure' }} | |
| run: cs2pr ./phpcs-report.xml | |
| # Check that the sniffs available are feature complete. | |
| # For now, just check that all sniffs have unit tests. | |
| # At a later stage the documentation check can be activated. | |
| - name: Check sniff feature completeness | |
| run: composer check-complete | |
| # While this won't catch everything, it should catch any serious XML errors and exit with a non-zero exit code in that case. | |
| - name: Check the docs can be displayed without errors | |
| run: vendor/bin/phpcs --generator=Text --standard=PHPCompatibility | |
| xml-cs: | |
| name: 'XML Code style' | |
| runs-on: ubuntu-latest | |
| env: | |
| XMLLINT_INDENT: ' ' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| persist-credentials: false | |
| # Updating the lists can fail intermittently, typically after Microsoft has released a new package. | |
| # This should not be blocking for this job, so ignore any errors from this step. | |
| # Ref: https://github.com/dotnet/core/issues/4167 | |
| - name: Update the available packages list | |
| continue-on-error: true | |
| run: sudo apt-get update | |
| - name: Install xmllint | |
| run: sudo apt-get install --no-install-recommends -y libxml2-utils | |
| # Show XML violations inline in the file diff. | |
| - name: Enable showing XML issues inline | |
| uses: korelstar/xmllint-problem-matcher@1bd292d642ddf3d369d02aaa8b262834d61198c0 # v1.2.0 | |
| - name: Check XML code style | |
| run: diff -B ./PHPCompatibility/ruleset.xml <(xmllint --format "./PHPCompatibility/ruleset.xml") | |
| verify-tests: | |
| name: 'Check test files are up to date' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Install PHP | |
| uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0 | |
| with: | |
| php-version: 'latest' | |
| ini-values: zend.assertions=1, error_reporting=-1, display_errors=On, display_startup_errors=On | |
| coverage: none | |
| - name: Regenerate the test files for the forbidden names test | |
| run: php "./bin/generate-forbidden-names-test-files" | |
| # If the regeneration of the test files yielded changes, this will ensure we fail the build. | |
| - name: Ensure version-controlled files are not modified or deleted | |
| run: git diff --exit-code | |
| markdownlint: | |
| name: 'Lint Markdown' | |
| uses: PHPCSStandards/.github/.github/workflows/reusable-markdownlint.yml@a06ac9fa50dcd1d98cc581e9a4e331363a69ea09 # v1.1.0 | |
| yamllint: | |
| name: 'Lint Yaml' | |
| uses: PHPCSStandards/.github/.github/workflows/reusable-yamllint.yml@a06ac9fa50dcd1d98cc581e9a4e331363a69ea09 # v1.1.0 | |
| with: | |
| strict: true | |
| find-token-properties: | |
| # The properties in the PHPCS Tokens class have been deprecated. | |
| # The code in this repository should always use the constants instead. | |
| name: 'Find use of Tokens properties' | |
| uses: PHPCSStandards/.github/.github/workflows/reusable-findtokenprops.yml@a06ac9fa50dcd1d98cc581e9a4e331363a69ea09 # v1.1.0 |