name: Tests

on:
  push:
  pull_request:

jobs:
  test:
    runs-on: ${{ matrix.operating-system }}
    strategy:
      fail-fast: false
      matrix:
        operating-system: ['ubuntu-20.04', 'ubuntu-22.04', 'ubuntu-24.04']
        php-versions: ['8.1', '8.2', '8.3', '8.4']
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        submodules: true

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-versions }}
        extensions: gmp
        coverage: none

    - name: Install dependencies
      run: composer install --prefer-dist

    - name: Run tests
      run: make phpunit-full-ci

  coverage:
    runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        operating-system: ['ubuntu-24.04']
        php-versions: ['8.4']

    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        submodules: true

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-versions }}
        extensions: gmp, pcov

    - name: Install dependencies
      run: composer install --prefer-dist

    - name: Run tests
      run: make phpunit-ci
