<commit_before>name: CI

on:
  push:
    branches:
      - '4.x'
      - '4.next'
  pull_request:
    branches:
      - '*'
  schedule:
    - cron: "0 0 * * *"

jobs:
  testsuite:
    runs-on: ubuntu-18.04
    strategy:
      fail-fast: false
      matrix:
        php-version: ['7.2', '8.0']
        db-type: [sqlite, mysql, pgsql]
        prefer-lowest: ['']
        exclude:
          - php-version: '7.2'
            db-type: 'mysql'
        include:
          - php-version: '7.4'
            db-type: 'mariadb'
          - php-version: '7.2'
            db-type: 'mysql'
            prefer-lowest: 'prefer-lowest'
          - php-version: '8.1'
            db-type: 'sqlite'

    services:
      redis:
        image: redis
        ports:
          - 6379/tcp
      memcached:
        image: memcached
        ports:
          - 11211/tcp

    steps:
    - name: Setup MySQL latest
      if: matrix.db-type == 'mysql' && matrix.php-version == '7.2'
      run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin

    - name: Setup MySQL 5.6
      if: matrix.db-type == 'mysql' && matrix.php-version != '7.2'
      run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:5.6 --character-set-server=utf8

    - name: Setup PostgreSQL latest
      if: matrix.db-type == 'pgsql' && matrix.php-version == '7.2'
      run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres

    - name: Setup PostgreSQL 9.4
      if: matrix.db-type == 'pgsql' && matrix.php-version != '7.2'
      run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=<PASSWORD> -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres:9.4

    - uses: getong/mariadb-action@v1.1
      if: matrix.db-type == 'mariadb'
      with:
        mysql database: 'cakephp'
        mysql root password: '<PASSWORD>'

    - uses: actions/checkout@v2

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-version }}
        extensions: mbstring, intl, apcu, memcached, redis, pdo_${{ matrix.db-type }}
        ini-values: apc.enable_cli = 1
        coverage: pcov

    - name: Get composer cache directory
      id: composer-cache
      run: echo "::set-output name=dir::$(composer config cache-files-dir)"

    - name: Get date part for cache key
      id: key-date
      run: echo "::set-output name=date::$(date +'%Y-%m')"

    - name: Cache composer dependencies
      uses: actions/cache@v2
      with:
        path: ${{ steps.composer-cache.outputs.dir }}
        key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

    - name: Install packages
      run: |
        sudo locale-gen da_DK.UTF-8
        sudo locale-gen de_DE.UTF-8

    - name: Composer install
      run: |
        if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
          composer update --prefer-lowest --prefer-stable
        elif ${{ matrix.php-version == '8.1' }}; then
          composer update --ignore-platform-reqs
        else
          composer update
        fi

    - name: Setup problem matchers for PHPUnit
      if: matrix.php-version == '7.2' && matrix.db-type == 'mysql'
      run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

    - name: Run PHPUnit
      env:
        REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
        MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
      run: |
        if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
        if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} == '7.2' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi
        if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} != '7.2' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp?encoding=utf8'; fi
        if [[ ${{ matrix.db-type }} == 'mariadb' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi
        if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi

        if [[ ${{ matrix.php-version }} == '8.0' ]]; then
          export CODECOVERAGE=1
          vendor/bin/phpunit --verbose --coverage-clover=coverage.xml
          CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --verbose --testsuite=database
        else
          vendor/bin/phpunit
          CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --testsuite=database
        fi

    - name: Submit code coverage
      if: matrix.php-version == '8.0'
      uses: codecov/codecov-action@v1

  testsuite-windows:
    runs-on: windows-2019
    name: Windows - PHP 8.0 & SQL Server

    env:
      EXTENSIONS: mbstring, intl, apcu, memcached, redis, wincache, pdo_sqlsrv
      PHP_VERSION: '8.0'

    steps:
    - uses: actions/checkout@v2

    - name: Get date part for cache key
      id: key-date
      run: echo "::set-output name=date::$(date +'%Y-%m')"

    - name: Setup PHP extensions cache
      id: php-ext-cache
      uses: shivammathur/cache-extensions@v1
      with:
        php-version: ${{ env.PHP_VERSION }}
        extensions: ${{ env.EXTENSIONS }}
        key: ${{ steps.key-date.outputs.date }}

    - name: Cache PHP extensions
      uses: actions/cache@v2
      with:
        path: ${{ steps.php-ext-cache.outputs.dir }}
        key: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}
        restore-keys: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ env.PHP_VERSION }}
        extensions: ${{ env.EXTENSIONS }}
        ini-values: apc.enable_cli = 1, extension = php_fileinfo.dll
        coverage: none

    - name: Setup SQLServer
      run: |
        # MSSQLLocalDB is the default SQL LocalDB instance
        SqlLocalDB start MSSQLLocalDB
        SqlLocalDB info MSSQLLocalDB
        sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "create database cakephp;"

    - name: Get composer cache directory
      id: composer-cache
      run: echo "::set-output name=dir::$(composer config cache-files-dir)"

    - name: Cache composer dependencies
      uses: actions/cache@v2
      with:
        path: ${{ steps.composer-cache.outputs.dir }}
        key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

    - name: Composer install
      run: composer update

    - name: Run PHPUnit
      env:
        DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
      run: |
          vendor/bin/phpunit --verbose
          
    - name: Run PHPUnit (autoquote enabled)
      env:
        DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
      run: |
          set CAKE_TEST_AUTOQUOTE=1
          vendor/bin/phpunit --verbose --testsuite=database

  cs-stan:
    name: Coding Standard & Static Analysis
    runs-on: ubuntu-18.04

    steps:
    - uses: actions/checkout@v2

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: '7.4'
        extensions: mbstring, intl, apcu, memcached, redis
        tools: cs2pr
        coverage: none

    - name: Get composer cache directory<commit_msg>Wait unil mysql is ready before running phpunit<commit_after>name: CI

on:
  push:
    branches:
      - '4.x'
      - '4.next'
  pull_request:
    branches:
      - '*'
  schedule:
    - cron: "0 0 * * *"

jobs:
  testsuite:
    runs-on: ubuntu-18.04
    strategy:
      fail-fast: false
      matrix:
        php-version: ['7.2', '8.0']
        db-type: [sqlite, mysql, pgsql]
        prefer-lowest: ['']
        exclude:
          - php-version: '7.2'
            db-type: 'mysql'
        include:
          - php-version: '7.4'
            db-type: 'mariadb'
          - php-version: '7.2'
            db-type: 'mysql'
            prefer-lowest: 'prefer-lowest'
          - php-version: '8.1'
            db-type: 'sqlite'

    services:
      redis:
        image: redis
        ports:
          - 6379/tcp
      memcached:
        image: memcached
        ports:
          - 11211/tcp

    steps:
    - name: Setup MySQL latest
      if: matrix.db-type == 'mysql' && matrix.php-version == '7.2'
      run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=<PASSWORD> -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin

    - name: Setup MySQL 5.6
      if: matrix.db-type == 'mysql' && matrix.php-version != '7.2'
      run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=<PASSWORD> -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:5.6 --character-set-server=utf8

    - name: Setup PostgreSQL latest
      if: matrix.db-type == 'pgsql' && matrix.php-version == '7.2'
      run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres

    - name: Setup PostgreSQL 9.4
      if: matrix.db-type == 'pgsql' && matrix.php-version != '7.2'
      run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres:9.4

    - uses: getong/mariadb-action@v1.1
      if: matrix.db-type == 'mariadb'
      with:
        mysql database: 'cakephp'
        mysql root password: '<PASSWORD>'

    - uses: actions/checkout@v2

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-version }}
        extensions: mbstring, intl, apcu, memcached, redis, pdo_${{ matrix.db-type }}
        ini-values: apc.enable_cli = 1
        coverage: pcov

    - name: Get composer cache directory
      id: composer-cache
      run: echo "::set-output name=dir::$(composer config cache-files-dir)"

    - name: Get date part for cache key
      id: key-date
      run: echo "::set-output name=date::$(date +'%Y-%m')"

    - name: Cache composer dependencies
      uses: actions/cache@v2
      with:
        path: ${{ steps.composer-cache.outputs.dir }}
        key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

    - name: Install packages
      run: |
        sudo locale-gen da_DK.UTF-8
        sudo locale-gen de_DE.UTF-8

    - name: Composer install
      run: |
        if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
          composer update --prefer-lowest --prefer-stable
        elif ${{ matrix.php-version == '8.1' }}; then
          composer update --ignore-platform-reqs
        else
          composer update
        fi

    - name: Setup problem matchers for PHPUnit
      if: matrix.php-version == '7.2' && matrix.db-type == 'mysql'
      run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

    - name: Wait for MySQL
      if: matrix.db-type == 'mysql' || matrix.db-type == 'mariadb'
      run: while ! `mysqladmin ping -h 127.0.0.1 --silent`; do printf 'Waiting for MySQL...\n'; sleep 2; done;

    - name: Run PHPUnit
      env:
        REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
        MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
      run: |
        if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
        if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} == '7.2' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi
        if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} != '7.2' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp?encoding=utf8'; fi
        if [[ ${{ matrix.db-type }} == 'mariadb' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi
        if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi

        if [[ ${{ matrix.php-version }} == '8.0' ]]; then
          export CODECOVERAGE=1
          vendor/bin/phpunit --verbose --coverage-clover=coverage.xml
          CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --verbose --testsuite=database
        else
          vendor/bin/phpunit
          CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --testsuite=database
        fi

    - name: Submit code coverage
      if: matrix.php-version == '8.0'
      uses: codecov/codecov-action@v1

  testsuite-windows:
    runs-on: windows-2019
    name: Windows - PHP 8.0 & SQL Server

    env:
      EXTENSIONS: mbstring, intl, apcu, memcached, redis, wincache, pdo_sqlsrv
      PHP_VERSION: '8.0'

    steps:
    - uses: actions/checkout@v2

    - name: Get date part for cache key
      id: key-date
      run: echo "::set-output name=date::$(date +'%Y-%m')"

    - name: Setup PHP extensions cache
      id: php-ext-cache
      uses: shivammathur/cache-extensions@v1
      with:
        php-version: ${{ env.PHP_VERSION }}
        extensions: ${{ env.EXTENSIONS }}
        key: ${{ steps.key-date.outputs.date }}

    - name: Cache PHP extensions
      uses: actions/cache@v2
      with:
        path: ${{ steps.php-ext-cache.outputs.dir }}
        key: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}
        restore-keys: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ env.PHP_VERSION }}
        extensions: ${{ env.EXTENSIONS }}
        ini-values: apc.enable_cli = 1, extension = php_fileinfo.dll
        coverage: none

    - name: Setup SQLServer
      run: |
        # MSSQLLocalDB is the default SQL LocalDB instance
        SqlLocalDB start MSSQLLocalDB
        SqlLocalDB info MSSQLLocalDB
        sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "create database cakephp;"

    - name: Get composer cache directory
      id: composer-cache
      run: echo "::set-output name=dir::$(composer config cache-files-dir)"

    - name: Cache composer dependencies
      uses: actions/cache@v2
      with:
        path: ${{ steps.composer-cache.outputs.dir }}
        key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

    - name: Composer install
      run: composer update

    - name: Run PHPUnit
      env:
        DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
      run: |
          vendor/bin/phpunit --verbose

    - name: Run PHPUnit (autoquote enabled)
      env:
        DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
      run: |
          set CAKE_TEST_AUTOQUOTE=1
          vendor/bin/phpunit --verbose --testsuite=database

  cs-stan:
    name: Coding Standard & Static Analysis
    runs-on: ubuntu-18.04

    steps:
    - uses: actions/checkout@v2

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: '7.4'
        extensions: mbstring, intl, apcu, memcached, redis
        tools: cs2pr
        coverage: none

    - name: Get composer cache directory
{'fraction_non_alphanumeric': 0.149025069637883, 'fraction_numerical': 0.021687226422602467, 'mean_word_length': 2.19402668926075, 'pattern_counts': {'":': 10, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 9, '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': '4518838', 'n_tokens_mistral': 5396, 'n_tokens_neox': 5080, 'n_words': 1144}