text: name: Execute tests
  
  on:
    push:
      branches:
        - master
      tags-ignore:
        - '**'
    pull_request:
  
  jobs: # Docs: <https://help.github.com/en/articles/workflow-syntax-for-github-actions>
    tests:
      name: PHP ${{ matrix.php }}, ${{ matrix.setup }} setup
      runs-on: ubuntu-latest
      timeout-minutes: 10
      strategy:
        fail-fast: false
        matrix:
          setup: ['basic', 'lowest']
          php: ['7.1', '7.2', '7.3', '7.4']
          include:
            - php: '7.1'
              setup: 'basic'
              coverage: 'true'
            - php: '7.4'
              setup: 'basic'
              coverage: 'true'
      steps:
        - name: Check out code
          uses: actions/checkout@v2
          with:
            fetch-depth: 1
  
        - name: Setup PHP, with composer and extensions
          uses: shivammathur/setup-php@master # Action page: <https://github.com/shivammathur/setup-php>
          with:
            php-version: ${{ matrix.php }}
            extensions: mbstring, pdo, pdo_sqlite, sqlite3 # definition is required for php 7.4
  
        - name: Get Composer Cache Directory # Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
          id: composer-cache
          run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  
        - name: Cache dependencies # Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
          uses: actions/cache@v1
          with:
            path: ${{ steps.composer-cache.outputs.dir }}
            key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
            restore-keys: ${{ runner.os }}-composer-
  
        - name: Install Composer 'hirak/prestissimo' package
          run: composer global require hirak/prestissimo --update-no-dev
  
        - name: Install lowest Composer dependencies
          if: matrix.setup == 'lowest'
          run: composer update --prefer-dist --no-interaction --no-suggest --prefer-lowest
  
        - name: Install basic Composer dependencies
          if: matrix.setup == 'basic'
          run: composer update --prefer-dist --no-interaction --no-suggest
  
        - name: Show most important packages versions
          run: composer info | grep -e laravel/laravel -e phpunit/phpunit -e phpstan/phpstan
  
        - name: Execute tests
          if: matrix.coverage != 'true'
          run: composer test
  
        - name: Execute tests with code coverage
          if: matrix.coverage == 'true'
          run: composer test-cover
  
        - uses: codecov/codecov-action@v1 # Docs: <https://github.com/codecov/codecov-action>
          if: matrix.coverage == 'true'
          with:
            token: ${{ secrets.CODECOV_TOKEN }}
            file: ./coverage/clover.xml
            fail_ci_if_error: false
  
    lint-changelog:
      name: Lint changelog file
      runs-on: ubuntu-latest
      steps:
        - name: Check out code
          uses: actions/checkout@v2
          with:
            fetch-depth: 1
  
        - name: Lint changelog file
          uses: docker://avtodev/markdown-lint:v1 # Action page: <https://github.com/avto-dev/markdown-lint>
          with:
            rules: '/lint/rules/changelog.js'
            config: '/lint/config/changelog.yml'
            args: './CHANGELOG.md'
  