# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2

jobs:
  "php-7.1 / mariadb-10":
    docker:
      - image: aimeos/ci-php:7.1
      - image: circleci/mariadb:10
        environment:
          MYSQL_ROOT_PASSWORD: rootpw
          MYSQL_DATABASE: aimeos
          MYSQL_USER: aimeos
          MYSQL_PASSWORD: aimeos
    steps:
      - checkout
      - run: git clone --depth=50 --branch=2021.04 git://github.com/aimeos/aimeos-core.git ../aimeos-core
      - run: cd .. && mv project aimeos-core/ext/ai-controller-jobs && mv aimeos-core project && cd project
      - restore_cache:
          keys:
            - php71-{{ checksum "composer.json" }}
      - run: composer update -n --prefer-dist
      - save_cache:
          key: php71-{{ checksum "composer.json" }}
          paths: [./vendor]
      - run: echo "<?php return array( 'db' => array( 'adapter' => 'mysql', 'host' => '127.0.0.1', 'port' => 3306, 'database' => 'aimeos', 'username' => 'aimeos', 'password' => 'aimeos', 'limit' => 2, 'opt-persistent' => false, 'stmt' => array( \"SET SESSIOn sort_buffer_size=2097144; SET NAMES 'utf8'; SET SESSION sql_mode='ANSI'\" ) ), 'fs' => array( 'adapter' => 'Standard', 'basedir' => '.' ), 'mq' => array( 'adapter' => 'Standard', 'db' => 'db' ) );" > config/resource.php
      - run: for i in `seq 1 10`; do nc -z 127.0.0.1 3306 && echo OK && exit 0; echo -n .; sleep 1; done
      - run: ./vendor/bin/phing -Ddir=ext/ai-controller-jobs setup testext

  "php-7.2 / mysql-5.7":
    docker:
      - image: aimeos/ci-php:7.2
      - image: circleci/mysql:5.7
        environment:
          MYSQL_ROOT_PASSWORD: rootpw
          MYSQL_DATABASE: aimeos
          MYSQL_USER: aimeos
          MYSQL_PASSWORD: aimeos
    steps:
      - checkout
      - run: git clone --depth=50 --branch=2021.04 git://github.com/aimeos/aimeos-core.git ../aimeos-core
      - run: cd .. && mv project aimeos-core/ext/ai-controller-jobs && mv aimeos-core project && cd project
      - restore_cache:
          keys:
            - php72-{{ checksum "composer.json" }}
      - run: composer update -n --prefer-dist
      - save_cache:
          key: php72-{{ checksum "composer.json" }}
          paths: [./vendor]
      - run: echo "<?php return array( 'db' => array( 'adapter' => 'mysql', 'host' => '127.0.0.1', 'port' => 3306, 'database' => 'aimeos', 'username' => 'aimeos', 'password' => 'aimeos', 'limit' => 2, 'opt-persistent' => false, 'stmt' => array( \"SET SESSIOn sort_buffer_size=2097144; SET NAMES 'utf8'; SET SESSION sql_mode='ANSI'\" ) ), 'fs' => array( 'adapter' => 'Standard', 'basedir' => '.' ), 'mq' => array( 'adapter' => 'Standard', 'db' => 'db' ) );" > config/resource.php
      - run: for i in `seq 1 10`; do nc -z 127.0.0.1 3306 && echo OK && exit 0; echo -n .; sleep 1; done
      - run: ./vendor/bin/phing -Ddir=ext/ai-controller-jobs setup testext checkext

  "php-7.3 / pgsql-13":
    docker:
      - image: aimeos/ci-php:7.3
      - image: circleci/postgres:13
        environment:
          POSTGRES_PASSWORD: aimeos
          POSTGRES_USER: aimeos
          POSTGRES_DB: aimeos
    steps:
      - checkout
      - run: git clone --depth=50 --branch=2021.04 git://github.com/aimeos/aimeos-core.git ../aimeos-core
      - run: cd .. && mv project aimeos-core/ext/ai-controller-jobs && mv aimeos-core project && cd project
      - restore_cache:
          keys:
            - php73-{{ checksum "composer.json" }}
      - run: composer update -n --prefer-dist
      - save_cache:
          key: php73-{{ checksum "composer.json" }}
          paths: [./vendor]
      - run: echo "<?php return array( 'db' => array( 'adapter' => 'pgsql', 'host' => '127.0.0.1', 'port' => 5432, 'database' => 'aimeos', 'username' => 'aimeos', 'password' => 'aimeos', 'limit' => 2, 'opt-persistent' => false, 'stmt' => array() ), 'fs' => array( 'adapter' => 'Standard', 'basedir' => '.' ), 'mq' => array( 'adapter' => 'Standard', 'db' => 'db' ) );" > config/resource.php
      - run: for i in `seq 1 10`; do nc -z 127.0.0.1 5432 && echo OK && exit 0; echo -n .; sleep 1; done
      - run: ./vendor/bin/phing -Ddir=ext/ai-controller-jobs setup testext

  "php-7.4 / mysql-8.0":
    docker:
      - image: aimeos/ci-php:7.4
      - image: circleci/mysql:8.0
        environment:
          MYSQL_ROOT_PASSWORD: rootpw
          MYSQL_DATABASE: aimeos
          MYSQL_USER: aimeos
          MYSQL_PASSWORD: aimeos
    steps:
      - checkout
      - run: git clone --depth=50 --branch=2021.04 git://github.com/aimeos/aimeos-core.git ../aimeos-core
      - run: cd .. && mv project aimeos-core/ext/ai-controller-jobs && mv aimeos-core project && cd project
      - restore_cache:
          keys:
            - php74-{{ checksum "composer.json" }}
      - run: composer update -n --prefer-dist
      - save_cache:
          key: php74-{{ checksum "composer.json" }}
          paths: [./vendor]
      - run: echo "<?php return array( 'db' => array( 'adapter' => 'mysql', 'host' => '127.0.0.1', 'port' => 3306, 'database' => 'aimeos', 'username' => 'aimeos', 'password' => 'aimeos', 'limit' => 2, 'opt-persistent' => false, 'stmt' => array( \"SET SESSIOn sort_buffer_size=2097144; SET NAMES 'utf8'; SET SESSION sql_mode='ANSI'\" ) ), 'fs' => array( 'adapter' => 'Standard', 'basedir' => '.' ), 'mq' => array( 'adapter' => 'Standard', 'db' => 'db' ) );" > config/resource.php
      - run: for i in `seq 1 10`; do nc -z 127.0.0.1 3306 && echo OK && exit 0; echo -n .; sleep 1; done
      - run: ./vendor/bin/phing -Ddir=ext/ai-controller-jobs setup coverageext
      - run: ./vendor/bin/php-coveralls -x ext/ai-controller-jobs/controller/jobs/tests/coverage.xml -vvv

  "php-8.0 / mysql-8.0":
    docker:
      - image: aimeos/ci-php:8.0
      - image: circleci/mysql:8.0
        environment:
          MYSQL_ROOT_PASSWORD: rootpw
          MYSQL_DATABASE: aimeos
          MYSQL_USER: aimeos
          MYSQL_PASSWORD: aimeos
    steps:
      - checkout
      - run: git clone --depth=50 --branch=2021.04 git://github.com/aimeos/aimeos-core.git ../aimeos-core
      - run: cd .. && mv project aimeos-core/ext/ai-controller-jobs && mv aimeos-core project && cd project
      - restore_cache:
          keys:
            - php80-{{ checksum "composer.json" }}
      - run: composer update -n --prefer-dist
      - save_cache:
          key: php80-{{ checksum "composer.json" }}
          paths: [./vendor]
      - run: echo "<?php return array( 'db' => array( 'adapter' => 'mysql', 'host' => '127.0.0.1', 'port' => 3306, 'database' => 'aimeos', 'username' => 'aimeos', 'password' => 'aimeos', 'limit' => 2, 'opt-persistent' => false, 'stmt' => array( \"SET SESSIOn sort_buffer_size=2097144; SET NAMES 'utf8'; SET SESSION sql_mode='ANSI'\" ) ), 'fs' => array( 'adapter' => 'Standard', 'basedir' => '.' ), 'mq' => array( 'adapter' => 'Standard', 'db' => 'db' ) );" > config/resource.php
      - run: for i in `seq 1 10`; do nc -z 127.0.0.1 3306 && echo OK && exit 0; echo -n .; sleep 1; done
      - run: ./vendor/bin/phing -Ddir=ext/ai-controller-jobs setup coverageext
      - run: ./vendor/bin/php-coveralls -x ext/ai-controller-jobs/controller/jobs/tests/coverage.xml -vvv

workflows:
  version: 2
  unittest:
    jobs:
      - "php-7.1 / mariadb-10"
      - "php-7.2 / mysql-5.7"
      - "php-7.3 / pgsql-13"
      - "php-7.4 / mysql-8.0"
      - "php-8.0 / mysql-8.0"
