Fix CI pipeline: phpunit.xml validation warning, php-parser v4 test skip, and comprehensive type-analysis regression coverage #316
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
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| tests: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: [ | |
| 8.1, | |
| 8.2, | |
| 8.3, | |
| 8.4 | |
| ] | |
| composer: [basic] | |
| # Test against both supported nikic/php-parser major versions. | |
| # php-parser v4 requires phpunit ^9.6 because phpunit/php-code-coverage v11+ | |
| # has a hard dependency on php-parser v5; phpunit 9 uses php-code-coverage v9 | |
| # which is compatible with both. | |
| parser-version: [v4, v5] | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2.37.0 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| coverage: xdebug | |
| extensions: zip | |
| tools: composer | |
| - name: Determine composer cache directory | |
| id: composer-cache | |
| run: echo "directory=$(composer config cache-dir)" >> "$GITHUB_OUTPUT" | |
| - name: Cache composer dependencies | |
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.directory }} | |
| # Include parser-version in the key to avoid cache poisoning between v4/v5 runs. | |
| key: ${{ matrix.php }}-${{ matrix.parser-version }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ matrix.php }}-${{ matrix.parser-version }}-composer- | |
| - name: Install dependencies | |
| run: | | |
| if [[ "${{ matrix.parser-version }}" == "v4" ]]; then | |
| # php-parser v4: pin phpunit to ^9.6 because phpunit 11's php-code-coverage requires php-parser v5. | |
| # Use --with (temporary constraint) instead of listing packages positionally: the latter is a | |
| # partial-update and requires a lock file, which libraries do not commit. --with does a full | |
| # resolve with the extra constraint, so it works fine without a lock file. | |
| composer update --prefer-dist --no-interaction --with nikic/php-parser:'^4.18' --with phpunit/phpunit:'^9.6' | |
| elif [[ "${{ matrix.composer }}" == "lowest" ]]; then | |
| composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable | |
| else | |
| composer update --prefer-dist --no-interaction | |
| fi | |
| composer dump-autoload -o | |
| - name: Run tests | |
| run: | | |
| mkdir -p build/logs | |
| php vendor/bin/phpunit -c phpunit.xml --coverage-filter=src --coverage-clover=build/logs/clover.xml | |
| - name: Run phpstan | |
| if: ${{ matrix.php == '8.3' }} | |
| run: | | |
| php vendor/bin/phpstan analyse | |
| - name: Upload coverage results to Coveralls | |
| env: | |
| COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| composer global require php-coveralls/php-coveralls | |
| php-coveralls --coverage_clover=build/logs/clover.xml -v | |
| - name: Upload coverage results to Codecov | |
| uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 | |
| with: | |
| files: build/logs/clover.xml | |
| - name: Archive logs artifacts | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: logs_composer-${{ matrix.composer }}_parser-${{ matrix.parser-version }}_php-${{ matrix.php }} | |
| path: | | |
| build/logs |