# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
  build:
    docker:
      # Specify the version you desire here
      - image: circleci/php:7.4-cli
      - image: circleci/mariadb:10.5-ram
        environment:
          MYSQL_ROOT_PASSWORD: rootplb
          MYSQL_DATABASE: planningb
          MYSQL_USER: plb
          MYSQL_PASSWORD: plb

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # Using the RAM variation mitigates I/O contention
      # for database intensive operations.
      # - image: circleci/mysql:5.7-ram
      #
      # - image: redis:2.8.19

    steps:
      - checkout

      - run: sudo apt update # PHP CircleCI 2.0 Configuration File# PHP CircleCI 2.0 Configuration File sudo apt install zlib1g-dev libsqlite3-dev
      - run: sudo docker-php-ext-install zip
      - run: sudo docker-php-ext-install mysqli
      - run: sudo docker-php-ext-install pdo_mysql

      # Download and cache dependencies
      - restore_cache:
          keys:
            # "composer.lock" can be used if it is committed to the repo
            - v1-dependencies-{{ checksum "composer.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run: cp .circleci/.env.test.local .env.test.local
      - run: cp .circleci/.env.local .env.local
      - run: composer install -n --prefer-dist

      - save_cache:
          key: v1-dependencies-{{ checksum "composer.json" }}
          paths:
            - ./vendor

      # run tests with phpunit or codecept
      #- run: ./vendor/bin/phpunit
      - run: sudo cp $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini && echo 'xdebug.mode=coverage' | sudo tee -a $PHP_INI_DIR/php.ini
      - run: ./vendor/bin/simple-phpunit --coverage-text --coverage-clover coverage.xml --bootstrap tests/bootstrap.php tests/
      - run: bash <(curl -s https://codecov.io/bash)
