name: Test

on:
  push:
    branches:
      - 'master'
      - 'fix'
    paths:
      - '**.php'
      - '**.json'
      - '**.yml'
      - 'composer.lock'
      - 'phpstan.neon'

  pull_request:
    paths:
      - '**.php'
      - '**.json'
      - '**.yml'
      - 'composer.lock'
      - 'phpstan.neon'

jobs:
  test:
    name: Test on PHP ${{ matrix.php-versions }}
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        php-versions: ['8.2', '8.3', '8.4']

    steps:
    - uses: actions/checkout@v2

    - name: Setup PHP with Composer
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-versions }}
        tools: composer:v2
        ini-values: memory_limit=1024M

    - name: Composer install
      run: composer install

    - name: Static analysis
      run: vendor/bin/phpstan

    - name: Unit testing
      run: vendor/bin/phpunit tests/unit
