dist: trusty
sudo: false
language: php

cache:
    directories:
        - $HOME/.composer/cache

php:
    - 7.1
    - 7.2
    - nightly

services:
    - riak
    - mongodb
    - memcached
    - redis-server
    - docker

before_install:
    - pecl channel-update pecl.php.net
    - pecl config-set preferred_state beta
    - echo yes | pecl upgrade apcu
    - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
    - ./tests/travis/Couchbase.sh
    - phpenv config-add ./tests/travis/php.ini

install:
    - rm composer.lock
    - travis_retry composer update --no-interaction --prefer-dist

script: ./vendor/bin/phpunit --exclude-group performance

jobs:
  allow_failures:
    - php: nightly

  include:
    - stage: Coding standard
      install:
          - travis_retry composer install --no-interaction --prefer-dist --ignore-platform-reqs
      script:
        - ./vendor/bin/phpcs

    - stage: Coverage
      before_script:
        - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
        - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
      script:
        - ./vendor/bin/phpunit --exclude-group performance --coverage-clover clover.xml
      after_script:
        - wget https://scrutinizer-ci.com/ocular.phar
        - php ocular.phar code-coverage:upload --format=php-clover clover.xml
