name: PHPUnit

on:
  push:
  pull_request:

jobs:
  tests:
    name: Tests
    strategy:
      matrix:
        include:
          - php: '7.4'
          - php: '8.0'
          - php: '8.1'
          - php: '8.2'
          - php: '8.3'
      fail-fast: false

    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          coverage: xdebug
          php-version: "${{ matrix.php }}"
      - name: Get composer cache directory
        id: composer-cache
        run: echo "::set-output name=dir::$(composer config cache-files-dir)"
      - name: Cache composer dependencies
        uses: actions/cache@v1
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: ${{ runner.os }}-composer-
      - name: Install
        run: |
          composer install -n
          if [ "${{ matrix.mode }}" = "low-deps" ]; then composer update --prefer-lowest --prefer-stable -n; fi;
      - name: Tests
        run: vendor/bin/phpunit
