| name: Tests
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
jobs:
  tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php: [8.1, 8.2, 8.3]
        laravel: [10.*]
    steps:
    - uses: actions/checkout@v4
    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring, xml, ctype, iconv, intl, xdebug
        coverage: xdebug
    - name: Install Dependencies
      run: composer install --prefer-dist --no-progress
    - name: Check Code Style
      run: |
        vendor/bin/php-cs-fixer fix --dry-run --diff
        vendor/bin/phpcs
    - name: Static Analysis
      run: vendor/bin/phpstan analyse
    - name: Execute tests via PHPUnit with coverage
      run: vendor/bin/phpunit --coverage-clover coverage.xml
    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v4
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        files: ./coverage.xml
        fail_ci_if_error: false # Set to true once coverage is stable
        verbose: true 
 |