name: "Continuous Integration"
on:
  workflow_dispatch:
  push:
    branches:
      - "master"
  pull_request:
    branches:
      - "master"
jobs:
  phpstan:
    name: "PHPStan Static Analysis  ${{ matrix.php-version }}, ${{ matrix.operating-system }}"
    runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        php-version:
          - "8.2"
          - "8.3"
        operating-system:
          - "ubuntu-latest"
    steps:
      - uses: actions/checkout@v4
      - name: "Install PHP ${{ matrix.php-version }}"
        uses: shivammathur/setup-php@master
        with:
           php-version: "${{ matrix.php-version }}"
           extensions: mbstring
      - name: "Validate composer.json and composer.lock"
        run: composer validate --strict
      - name: "Setup Composer, install dependencies"
        uses: ramsey/composer-install@v3
        with:
           composer-options: "--prefer-dist --optimize-autoloader"
           require-lock-file: "true"
      - name: "Run PHPStan"
        run: composer run-script phpstan
  unit-test:
    name: "Run Unit Tests ${{ matrix.php-version }}, ${{ matrix.operating-system }}"
    runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        php-version:
          - "8.2"
          - "8.3"
          - "8.4"
        operating-system:
          - "ubuntu-latest"
    steps:
      - uses: actions/checkout@v4
        with:
           fetch-depth: 10
      - name: "Install PHP ${{ matrix.php-version }}"
        uses: shivammathur/setup-php@master
        with:
           php-version: "${{ matrix.php-version }}"
           extensions: mbstring
           coverage: xdebug
      - name: "Validate composer.json and composer.lock"
        run: composer validate --strict
      - name: "Setup Composer, install dependencies"
        uses: ramsey/composer-install@v3
        with:
           composer-options: "--prefer-dist --optimize-autoloader"
           require-lock-file: "true"
      - name: "Run test suite"
        run: composer run-script test
      - name: Coverage Check
        uses: ericsizemore/
[email protected]
        with:
          clover_file: 'build/logs/clover.xml'
          threshold: 100
      - uses: sudo-bot/action-scrutinizer@latest
        with:
           cli-args: "--format=php-clover build/logs/clover.xml"