name: CI

on:
  push:
  pull_request:

jobs:
  phpunit:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        php-version:
          - "8.1"
          - "8.2"
          - "8.3"
        dependencies:
          - "highest"
        include:
          - dependencies: "lowest"
            php-version: "8.1"

    steps:
      - uses: actions/checkout@v4

      - name: Add php extensions
        uses: shivammathur/setup-php@v2
        with:
          php-version: "${{ matrix.php-version }}"
          tools: pecl, cs2pr
          extensions: opcache, pcntl, pdo_mysql, zip

      - name: "Install dependencies with Composer"
        uses: "ramsey/composer-install@v2"
        with:
          dependency-versions: "${{ matrix.dependencies }}"

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

  phpcs:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Add php extensions
        uses: shivammathur/setup-php@v2
        with:
          php-version: "8.1"
          tools: pecl, composer, cs2pr
          extensions: opcache, pcntl, pdo_mysql, zip

      - name: Install php packages
        run: composer install

      - name: Run phpcs
        run: ./vendor/bin/phpcs -q --report=checkstyle | tee -a /dev/stderr | cs2pr

  psalm:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Add php extensions
        uses: shivammathur/setup-php@v2
        with:
          php-version: "8.1"
          tools: pecl, composer, cs2pr
          extensions: opcache, pcntl, pdo_mysql, zip

      - name: Install php packages
        run: composer install

      - name: Run psalm
        run: ./vendor/bin/psalm
