name: Coverage

on:
  push:
    branches: [ '**' ]
  pull_request:
    branches: [ '**' ]

jobs:
  test:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        php: [ '8.3' ]

    name: Coverage

    steps:
    - uses: actions/checkout@v3

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        tools: composer:v2
        coverage: pcov

    - name: Cache Composer packages
      id: composer-cache
      uses: actions/cache@v3
      with:
        path: vendor
        key: php-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
        restore-keys: php-${{ matrix.php }}-

    - name: Install dependencies
      if: steps.composer-cache.outputs.cache-hit != 'true'
      run: composer update --prefer-stable

    - name: Run test suite
      run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml --colors=always

    - name: Coverage
      uses: codecov/codecov-action@v3
