name: Tests
on: [push, pull_request]

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 10
      matrix:
        php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']

    steps:
      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          coverage: none
          tools: flex

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

      - name: Download dependencies
        run: composer update --no-interaction --optimize-autoloader --prefer-stable

      - name: Run tests
        run: ./vendor/bin/simple-phpunit

  build8:
    name: Build PHP 8
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 10
      matrix:
        php: ['8.0', '8.1']

    steps:
      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          coverage: none
          tools: flex

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

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

      - name: Download dependencies
        run: composer update --no-interaction --optimize-autoloader --prefer-stable

      - name: Run tests
        run: ./vendor/bin/simple-phpunit
        env:
          SYMFONY_PHPUNIT_VERSION: 9.5

  lowest:
    name: Lowest deps
    runs-on: ubuntu-latest
    steps:
      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 7.3
          coverage: pcov

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

      - name: Download dependencies
        run: composer update --no-interaction --optimize-autoloader --prefer-stable --prefer-lowest

      - name: Run tests
        env:
          SYMFONY_DEPRECATIONS_HELPER: "max[self]=0"
        run: ./vendor/bin/simple-phpunit --coverage-text
