name: Run tests (lowest deps)

on:
  workflow_call:

jobs:
  test:
    name: PHP 7.4
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v6.0.2

      - name: Install PHP
        uses: shivammathur/setup-php@2.37.0
        with:
          php-version: '7.4'
          tools: composer:v2
          coverage: none

      - name: Set up problem matchers
        run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

      - name: Install dependencies (--prefer-lowest)
        uses: nick-fields/retry@v4.0.0
        with:
          timeout_minutes: 5
          max_attempts: 5
          command: composer update --prefer-lowest --prefer-stable --no-interaction --no-progress

      - name: Install PHPUnit
        uses: nick-fields/retry@v4.0.0
        with:
          timeout_minutes: 5
          max_attempts: 5
          command: composer bin phpunit update --no-interaction --no-progress

      - name: Run tests
        run: make test
        env:
          EXCLUDE_GROUP: php-parser-v4-fail
