name: phpunit

on: [push, pull_request]

jobs:

  phpunit:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        php: [8.1, 8.0, 7.4, 7.3]
        stability: [prefer-lowest, prefer-stable]
    name: phpunit on PHP ${{ matrix.php }}@${{ matrix.stability }}
    steps:
      - uses: actions/checkout@v2
      - uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: mbstring
          coverage: xdebug
      - run: |
          echo "::add-matcher::${{ runner.tool_cache }}/php.json"
          echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
      - run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction
      - run: vendor/bin/phpunit
