# .github/workflows/code_checks.yaml
name: Code_Checks

on: ["push", "pull_request"]

jobs:
  js-tests:
    name: "JS Tests"
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install JS dependencies
        run: |
          cd Resources && npm install

      - name: Run JS tests
        run: |
          cd Resources && npm run test
  phpunit:
    name: "PHP ${{ matrix.php }} + ${{ matrix.dependencies }} dependencies + Symfony ${{ matrix.symfony }}"
    runs-on: ubuntu-20.04
    strategy:
      fail-fast: false
      matrix:
        php: ['8.0', '8.1']
        dependencies: [highest]
        symfony: ['*']
        include:
          # Minimum supported dependencies with the oldest supported PHP version
          - php: '8.0'
            dependencies: lowest
            symfony: '*'

          # Minimum supported dependencies with the latest supported PHP version
          - php: '8.1'
            dependencies: lowest
            symfony: '*'

          - php: '8.1'
            dependencies: highest
            symfony: '*'

          # Test each supported Symfony version with lowest supported PHP version

          - php: '8.0'
            dependencies: highest
            symfony: '5.4.*'

          - php: '8.0'
            dependencies: highest
            symfony: '6.0.*'
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}

      - name: Require Symfony version
        if: matrix.symfony != '*'
        run: |
          composer global require --no-interaction --no-progress symfony/flex:^1.11
          composer config extra.symfony.require ${{ matrix.symfony }}

      - name: Update project dependencies
        uses: ramsey/composer-install@v1
        with:
          dependency-versions: ${{ matrix.dependencies }}

      - name: Cache PHPUnit
        uses: actions/cache@v2
        with:
          path: vendor/bin/.phpunit
          key: ${{ runner.os }}-phpunit-${{ matrix.php }}

      - name: Install PHPUnit
        run: vendor/bin/simple-phpunit install

      - name: Run PHPUnit tests
        env:
          SYMFONY_DEPRECATIONS_HELPER: max[self]=0
        run: vendor/bin/simple-phpunit -v
