box: hhvm/hhvm-proxygen
# Build definition

build:
  # The steps that will be executed on build
  steps:
    - script:
        name: disable interactive install
        code: |
          export DEBIAN_FRONTEND=noninteractive
    - install-packages:
      packages: curl git mysql-server mysql-server-5.7 redis-server postgresql
    - script:
        name: start database servers
        code: |
          /etc/init.d/mysql start
          /etc/init.d/redis-server start
          sed -i "s/ peer/ trust/g" /etc/postgresql/*/main/pg_hba.conf
          sed -i "s/ md5/ trust/g" /etc/postgresql/*/main/pg_hba.conf
          /etc/init.d/postgresql start
    - script:
        name: install composer
        code: |
          rm -f composer.lock
          export COMPOSER_CACHE_DIR=$WERCKER_CACHE_DIR
          curl -sS https://getcomposer.org/installer | hhvm --php -- --install-dir=/usr/local/bin/
          composer.phar remove mongodb/mongodb --no-update --dev
          composer.phar install
          echo "xdebug.enable = On" >> /etc/hhvm/php.ini
    - script:
        name: setup HHVM servers
        code: |
          echo ${WERCKER_ROOT}/tests/data/app
          echo "hhvm.server.source_root=${WERCKER_ROOT}/tests/data/app" >> tests/data/app/hhvm-server.ini
          cat tests/data/app/hhvm-server.ini
          hhvm -m server -c tests/data/app/hhvm-server.ini -c /etc/hhvm/site.ini &
          echo "hhvm.server.source_root=${WERCKER_ROOT}/tests/data/rest" >> tests/data/rest/hhvm-server.ini
          hhvm -m server -c tests/data/rest/hhvm-server.ini -c /etc/hhvm/site.ini &
    - script:
        name: prepare databases
        code: |
          mysql -e 'create database codeception_test;'
          su postgres -c "psql -c 'create database codeception_test;' -U postgres"

    # A custom script step, name value is used in the UI
    # and the code value contains the command that get executed
    - script:
        name: codeception tests
        code: |
          php codecept run cli,unit