phan in ci #247
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: MO4 Coding Standard CI | |
| on: | |
| pull_request: | |
| push: | |
| schedule: | |
| - cron: '30 5 1 * *' | |
| jobs: | |
| style-checks: | |
| env: | |
| XMLLINT_INDENT: " " | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: install dependencies | |
| run: sudo apt update -qq && sudo apt -y install libxml2-utils | |
| - name: Check out repository code | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Install PHP | |
| uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # master | |
| with: | |
| php-version: '8.1' | |
| coverage: 'none' | |
| - name: Cache dependencies | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: '~/.cache/composer' | |
| key: "cache-composer-${{ hashFiles('composer.json') }}" | |
| restore-keys: 'cache-composer-' | |
| - name: run composer | |
| run: composer update --prefer-lowest --prefer-dist --no-interaction --no-progress | |
| - run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd MO4/ruleset.xml | |
| - run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd phpcs.mo4.xml | |
| - run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd phpcs.xml.dist | |
| - run: diff -B MO4/ruleset.xml <(xmllint --format MO4/ruleset.xml) | |
| - run: diff -B phpcs.mo4.xml <(xmllint --format phpcs.mo4.xml) | |
| - run: diff -B phpcs.xml.dist <(xmllint --format phpcs.xml.dist) | |
| - name: Stylecheck against MO4 itself | |
| run: vendor/bin/phpcs | |
| run-tests: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| php_version: | |
| - 8.1 | |
| - 8.2 | |
| - 8.3 | |
| - 8.4 | |
| - 8.5 | |
| dependencies_level: | |
| - --prefer-lowest | |
| - "" | |
| include: | |
| - os: windows-latest | |
| php_version: 8.1 | |
| dependencies_level: --prefer-lowest | |
| - os: windows-latest | |
| php_version: 8.1 | |
| dependencies_level: '' | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Set git to use LF on windows | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.eol lf | |
| - name: Check out repository code | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Install PHP | |
| uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # master | |
| with: | |
| coverage: 'xdebug' | |
| php-version: ${{ matrix.php_version }} | |
| extensions: ast-1.1.1 | |
| - name: Cache dependencies | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: '~/.cache/composer' | |
| key: "cache-composer-${{ hashFiles('composer.json') }}" | |
| restore-keys: 'cache-composer-' | |
| - name: Run composer | |
| run: composer update ${{ matrix.dependencies_level }} --prefer-dist --no-interaction --no-progress | |
| - name: Check composer.json | |
| run: composer normalize --dry-run | |
| - name: Run tests | |
| run: vendor/bin/phpunit | |
| - name: Run integration tests | |
| run: vendor/bin/phpcs -s --standard=MO4 integrationtests/testfile.php | |
| - name: Run PHPStan | |
| run: vendor/bin/phpstan analyse --no-progress | |
| - name: Run psalm | |
| if: ${{ matrix.os != 'windows-latest' && !(matrix.dependencies_level == '--prefer-lowest' && matrix.php_version == '8.5') }} | |
| run: vendor/bin/psalm | |
| - name: Install and run phan | |
| if: ${{ matrix.os != 'windows-latest' }} | |
| run: | | |
| rm composer.lock | |
| composer require ${{ matrix.dependencies_level }} --dev phan/phan | |
| vendor/bin/phan | |
| # AST 1.1 binary for Windows seems to be missing on PECL | |
| - name: Install and run phan with polyfill | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| run: | | |
| rm composer.lock | |
| composer require ${{ matrix.dependencies_level }} --dev phan/phan | |
| vendor/bin/phan --allow-polyfill-parser | |
| - name: Run tests with coverage | |
| if: ${{ matrix.os != 'windows-latest' && matrix.php_version == '8.1' && matrix.dependencies_level != '--prefer-lowest' }} | |
| run: php vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-cobertura=cobertura.xml --log-junit=junit.xml | |
| - name: Upload coverage to Codecov | |
| if: ${{ matrix.os != 'windows-latest' && matrix.php_version == '8.1' && matrix.dependencies_level != '--prefer-lowest' }} | |
| uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results to Codecov | |
| if: ${{ matrix.os != 'windows-latest' && matrix.php_version == '8.1' && matrix.dependencies_level != '--prefer-lowest' }} | |
| uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload coverage to Qlty | |
| if: ${{ matrix.os != 'windows-latest' && matrix.php_version == '8.1' && matrix.dependencies_level != '--prefer-lowest' }} | |
| uses: qltysh/qlty-action/coverage@a19242102d17e497f437d7466aa01b528537e899 # v2.2.0 | |
| with: | |
| token: ${{ secrets.QLTY_COVERAGE_TOKEN }} | |
| files: cobertura.xml | |
| strip-prefix: '/home/runner/work/mo4-coding-standard' | |
| add-prefix: 'MO4/Sniffs/' | |
| env: | |
| QLTY_COVERAGE_TOKEN: ${{ secrets.QLTY_COVERAGE_TOKEN }} | |