Configure PHPUnit <source> so coverage CI job stops warning + exiting 1 #6
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: PHPUnit (PHP ${{ matrix.php }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up PHP ${{ matrix.php }} | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: curl, json, mbstring | |
| tools: composer:v2 | |
| coverage: none | |
| - name: Cache Composer packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.composer/cache | |
| key: composer-${{ matrix.php }}-${{ hashFiles('composer.json') }} | |
| restore-keys: composer-${{ matrix.php }}- | |
| - name: Validate composer.json | |
| run: composer validate --strict | |
| - name: Install dependencies | |
| run: composer install --no-progress --prefer-dist --no-interaction | |
| - name: Run PHPUnit | |
| run: vendor/bin/phpunit | |
| coverage: | |
| name: Coverage | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up PHP 8.3 (with pcov) | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.3' | |
| extensions: curl, json, mbstring | |
| tools: composer:v2 | |
| coverage: pcov | |
| - run: composer install --no-progress --prefer-dist --no-interaction | |
| - name: Run PHPUnit with coverage | |
| run: vendor/bin/phpunit --coverage-clover coverage.xml | |
| - name: Upload to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ./coverage.xml | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| static-analysis: | |
| name: PHPStan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.3' | |
| tools: composer:v2 | |
| coverage: none | |
| - run: composer install --no-progress --prefer-dist --no-interaction | |
| - name: Run PHPStan | |
| run: vendor/bin/phpstan analyse --no-progress | |
| code-style: | |
| name: PHP-CS-Fixer | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.3' | |
| tools: composer:v2 | |
| coverage: none | |
| - run: composer install --no-progress --prefer-dist --no-interaction | |
| - name: Check code style | |
| run: vendor/bin/php-cs-fixer fix --dry-run --diff --no-interaction |