<commit_before>name: Tests and linting

on:
  push:
  pull_request:
  schedule:
    - cron:  '0 3 * * *'

jobs:
  unit-tests:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        php-version: ['7.2', '7.3', '7.4']
        dependencies: ['']
        include:
          - { php-version: '7.2', dependencies: '--prefer-lowest --prefer-stable' }

    name: Unit tests - PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}

    steps:
      - uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}
          extensions: mbstring, intl, zip
          coverage: xdebug
          tools: composer:v2

      - name: Install dependencies
        run: composer update --no-interaction ${{ matrix.dependencies }}

      - name: Run tests
        working-directory: ./src-tests/
        env:
          COLUMNS: 120
        run: |
          ../vendor/bin/phpunit --exclude-group integration --coverage-clover ./logs/clover.xml

      - name: Submit coverage to Coveralls
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NO_COLOR: 'true'
        run: |
          composer global require php-coveralls/php-coveralls
          ~/.composer/vendor/bin/php-coveralls --coverage_clover=./src-tests/logs/clover.xml --json_path=./src-tests/logs/coveralls-upload.json -v

  integration-tests:
    runs-on: ubuntu-latest
    name: Integration tests
    env:
      SELENIUM_VERSION: 3.141.59

    steps:
      - uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 7.4
          extensions: mbstring, intl, zip
          coverage: xdebug
          tools: composer:v2

      - name: Install dependencies
        run: composer update --no-interaction

      - name: Start Selenium server and Xvfb
        run: |
          google-chrome --version
          chromedriver --version
          SELENIUM_JAR=$(bin/steward install --no-interaction --no-ansi $SELENIUM_VERSION)
          xvfb-run --server-args="-screen 0, 1280x720x24" --auto-servernum java -jar $SELENIUM_JAR -log selenium-server.log &
          while ! nc -z localhost 4444 </dev/null; do echo Waiting for Selenium server to start...; sleep 1; done

      - name: Run tests
        working-directory: ./src-tests/
        env:
          COLUMNS: 120
        run: |
          ../vendor/bin/phpunit --group integration --coverage-clover ./logs/clover.xml

      - name: Submit coverage to Coveralls
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NO_COLOR: 'true'
        run: |
          composer global require php-coveralls/php-coveralls
          ~/.composer/vendor/bin/php-coveralls --coverage_clover=./src-tests/logs/clover.xml --json_path=./src-tests/logs/coveralls-upload.json -v

      - name: Dump logs
        if: ${{ always() }}
        run: |
          [ -r selenium-server.log ] && cat selenium-server.log

  codestyle:
      name: "Code style and static analysis"
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v2

        - name: Setup PHP
          uses: shivammathur/setup-php@v2
          with:
            php-version: '7.4'
            extensions: mbstring, intl
            tools: composer:v2

        - name: Install dependencies
          run: composer update --no-progress

        - name: Lint
          run: composer lint

        - name: Run checks
          run: composer analyze

  markdown-link-check:
    name: "Markdown link check"<commit_msg>Make Coveralls merge coverage from all jobs<commit_after>name: Tests and linting

on:
  push:
  pull_request:
  schedule:
    - cron:  '0 3 * * *'

jobs:
  unit-tests:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        php-version: ['7.2', '7.3', '7.4']
        dependencies: ['']
        include:
          - { php-version: '7.2', dependencies: '--prefer-lowest --prefer-stable' }

    name: Unit tests - PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}

    steps:
      - uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}
          extensions: mbstring, intl, zip
          coverage: xdebug
          tools: composer:v2

      - name: Install dependencies
        run: composer update --no-interaction ${{ matrix.dependencies }}

      - name: Run tests
        working-directory: ./src-tests/
        env:
          COLUMNS: 120
        run: |
          ../vendor/bin/phpunit --exclude-group integration --coverage-clover ./logs/clover.xml

      - name: Submit coverage to Coveralls
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          COVERALLS_PARALLEL: true
          COVERALLS_FLAG_NAME: ${{ github.job }}-PHP-${{ matrix.php-version }} ${{ matrix.dependencies }}
          NO_COLOR: 'true'
        run: |
          composer global require php-coveralls/php-coveralls
          ~/.composer/vendor/bin/php-coveralls --coverage_clover=./src-tests/logs/clover.xml --json_path=./src-tests/logs/coveralls-upload.json -v

  integration-tests:
    runs-on: ubuntu-latest
    name: Integration tests
    env:
      SELENIUM_VERSION: 3.141.59

    steps:
      - uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 7.4
          extensions: mbstring, intl, zip
          coverage: xdebug
          tools: composer:v2

      - name: Install dependencies
        run: composer update --no-interaction

      - name: Start Selenium server and Xvfb
        run: |
          google-chrome --version
          chromedriver --version
          SELENIUM_JAR=$(bin/steward install --no-interaction --no-ansi $SELENIUM_VERSION)
          xvfb-run --server-args="-screen 0, 1280x720x24" --auto-servernum java -jar $SELENIUM_JAR -log selenium-server.log &
          while ! nc -z localhost 4444 </dev/null; do echo Waiting for Selenium server to start...; sleep 1; done

      - name: Run tests
        working-directory: ./src-tests/
        env:
          COLUMNS: 120
        run: |
          ../vendor/bin/phpunit --group integration --coverage-clover ./logs/clover.xml

      - name: Submit coverage to Coveralls
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          COVERALLS_PARALLEL: true
          COVERALLS_FLAG_NAME: ${{ github.job }}
          NO_COLOR: 'true'

        run: |
          composer global require php-coveralls/php-coveralls
          ~/.composer/vendor/bin/php-coveralls --coverage_clover=./src-tests/logs/clover.xml --coverage_clover=./src-tests/FunctionalTests/logs/clover.xml --json_path=./src-tests/logs/coveralls-upload.json -v

      - name: Dump logs
        if: ${{ always() }}
        run: |
          [ -r selenium-server.log ] && cat selenium-server.log

  finish-tests:
    name: Tests finished
    needs: [unit-tests, integration-tests]
    runs-on: ubuntu-latest
    steps:
      - name: Notify Coveralls
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          parallel-finished: true

  codestyle:
      name: "Code style and static analysis"
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v2

        - name: Setup PHP
          uses: shivammathur/setup-php@v2
          with:
            php-version: '7.4'
            extensions: mbstring, intl
            tools: composer:v2

        - name: Install dependencies
          run: composer update --no-progress

        - name: Lint
          run: composer lint

        - name: Run checks
          run: composer analyze

  markdown-link-check:
    name: "Markdown link check"
{'fraction_non_alphanumeric': 0.11491160645657186, 'fraction_numerical': 0.012810658467845248, 'mean_word_length': 1.8776262440103206, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 9}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2333080', 'n_tokens_mistral': 2536, 'n_tokens_neox': 2386, 'n_words': 563}