name: Coverage

on:
  push:
  pull_request:

jobs:
  linux_tests:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: true

    name: PHP Code Coverage

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.3
          extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, gd, xdebug
          tools: composer:v2
          coverage: xdebug

      - name: Install dependencies
        uses: nick-invision/retry@v3
        with:
          timeout_minutes: 5
          max_attempts: 2
          command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

      - name: Execute tests
        run: vendor/bin/phpunit

      - name: Upload coverage results to Coveralls
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: vendor/bin/php-coveralls -v