name: Tests

on:
  push:
  pull_request:
  schedule:
    - cron: '0 0 * * *'

jobs:
  tests:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
      matrix:
        php: [7.4, 8.0, 8.1]
        dependency-version: [prefer-lowest, prefer-stable]

    name: PHP ${{ matrix.php }} ${{ matrix.dependency-version }}

    steps:
    - name: Checkout
      uses: actions/checkout@v2

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

    - name: Mimic PHP 8.0
      run: composer config platform.php 8.0.999
      if: matrix.php > 8

    - name: Setup Problem Matchers
      run: |
        echo "::add-matcher::${{ runner.tool_cache }}/php.json"
        echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

    - name: Install PHP dependencies
      run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist --no-progress --ansi

    - name: Run Unit Tests
      run: vendor/bin/phpunit --colors=always
