name: Tests

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  current:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php-version:
          - "8.1"
          - "8.2"
          - "8.3"
          - "8.4"

    steps:
    - uses: "actions/checkout@v4"
    - uses: "shivammathur/setup-php@v2"
      with:
        php-version: ${{ matrix.php-version }}

    - name: Validate composer.json and composer.lock
      run: composer validate --strict

    - name: Cache Composer packages
      id: composer-cache
      uses: actions/cache@v4
      with:
        path: vendor
        key: php-${{ matrix.php-version }}

    - name: Install Composer dependencies
      run: composer install --prefer-dist --no-progress

    - name: Run test suite
      run: composer run-script test
