name: phpunit

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php: [7.4, 8.0, 8.1, 8.2]
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Cache dependencies
        uses: actions/cache@v2
        with:
          path: ~/.composer/cache/files
          key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
          restore-keys: |
            dependencies-php-${{ matrix.php }}-composer-
            dependencies-php-

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

      - name: Install dependencies
        run: composer install --prefer-dist --no-interaction --no-suggest

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