Use CodeCov for test coverage. #16
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: PHP Composer | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| pull_request: | |
| branches: [ "master" ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| name: Test on php ${{ matrix.php_version }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| php_version: ['8.3', '8.4', '8.5'] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: /tmp/composer-cache | |
| key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} | |
| - name: Validate dependencies | |
| uses: php-actions/composer@v6 | |
| with: | |
| command: validate | |
| - name: Install dependencies on php ${{ matrix.php_version }} | |
| uses: php-actions/composer@v6 | |
| with: | |
| php_version: "${{ matrix.php_version }}" | |
| version: 2 | |
| - name: Run phpunit tests on php ${{ matrix.php_version }} | |
| uses: php-actions/phpunit@v4 | |
| with: | |
| php_version: "${{ matrix.php_version }}" | |
| configuration: phpunit.xml | |
| coverage: | |
| name: Code coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup PHP with pcov | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.3' | |
| coverage: pcov | |
| tools: composer:v2 | |
| - name: Install dependencies | |
| run: composer install --no-interaction --no-progress | |
| - name: Run phpunit with coverage | |
| run: vendor/bin/phpunit --coverage-clover coverage.xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| files: coverage.xml | |
| fail_ci_if_error: false | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |