name: CI

on:
  pull_request:
  push:
    branches:
      - master

jobs:
  tests:
    name: Tests (PHP ${{ matrix.php }}, dependencies ${{ matrix.dependencies }})
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php: [8.1]
        dependencies:
          - "lowest"
          - "highest"
        include:
          - { php: 8.1, dependencies: "highest" }
          - { php: 8.2, dependencies: "highest" }
          - { php: 8.3, dependencies: "highest" }
          - { php: 8.4, dependencies: "highest" }
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
      - name: Install dependencies
        uses: ramsey/composer-install@v2
        with:
          dependency-versions: ${{ matrix.dependencies }}
      - name: Run tests
        run: vendor/bin/phpunit test

  phpunit-compatibility:
    name: Test End to End with php ${{ matrix.php }}, phpunit ${{ matrix.phpunit }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - { phpunit: 10, php: 8.1 }
          - { phpunit: 10, php: 8.2 }
          - { phpunit: 10, php: 8.3 }
          - { phpunit: 10, php: 8.4 }
          - { phpunit: 11, php: 8.2 }
          - { phpunit: 11, php: 8.3 }
          - { phpunit: 11, php: 8.4 }
          - { phpunit: 12, php: 8.3 }
          - { phpunit: 12, php: 8.4 }
          - { phpunit: 13, php: 8.4 }
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
      - name: Install dependencies
        uses: ramsey/composer-install@v2
      - name: Download phpunit phar
        run: |
          wget -O phpunit https://phar.phpunit.de/phpunit-${{ matrix.phpunit }}.phar
          chmod +x phpunit
      - name: Run tests
        run: ./phpunit --testsuite EndToEnd
