language: php
sudo: false

addons:
  apt:
    packages:
      - gdb
      - lcov

env:
  global:
    - TEST_PHP_ARGS="-q -s output.txt -g XFAIL,FAIL,BORK,WARN,LEAK,SKIP -x --show-diff"
    - REPORT_EXIT_STATUS=1
    - SERVER_VERSION=4.0.0
    - DEPLOYMENT=STANDALONE

matrix:
  include:
    - php: 7.2
      env:
        - TESTS=tests/atlas.phpt
        - TEST_PHP_ARGS="-q -s output.txt -x --show-diff"
    - php: 5.5
    - php: 5.6
    - php: 7.0
    - php: 7.1
    - php: 7.2
    - php: 7.2
      env:
        - DEPLOYMENT=STANDALONE_SSL
    - php: 7.2
      env:
        - DEPLOYMENT=SHARDED_CLUSTER
    - php: 7.2
      env:
        - DEPLOYMENT=STANDALONE_AUTH
    - php: 7.2
      env:
        - DEPLOYMENT=REPLICASET
    - php: 7.2
      env:
        - DEPLOYMENT=REPLICASET_AUTH
    - php: 7.2
      env:
        - SERVER_VERSION=3.0.15
        - DEPLOYMENT=REPLICASET_OLD
    - php: 7.0
      env:
        - SERVER_VERSION=3.0.15
        - DEPLOYMENT=STANDALONE_OLD
    - php: 7.0
      env:
        - SERVER_VERSION=3.2.20
        - DEPLOYMENT=STANDALONE_OLD
    - php: 7.0
      env:
        - SERVER_VERSION=3.4.15
        - DEPLOYMENT=STANDALONE_OLD
    - php: 7.0
      env:
        - SERVER_VERSION=3.6.5

before_install:
  - openssl aes-256-cbc -K $encrypted_b354efda2943_key -iv $encrypted_b354efda2943_iv -in .travis.scripts/atlas-uris.txt.enc -out .travis.scripts/atlas-uris.txt -d || true
  - pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
  - .travis.scripts/before_install.sh
  - wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-${SERVER_VERSION}.tgz
  - tar zxf mongodb-linux-x86_64-ubuntu1404-${SERVER_VERSION}.tgz
  - export PATH=${PWD}/mongodb-linux-x86_64-ubuntu1404-${SERVER_VERSION}/bin:${PATH}
  - mongod --version
  - mongo-orchestration --version
  - export MO_PATH=`python -c 'import mongo_orchestration; from os import path;
    print(path.dirname(mongo_orchestration.__file__));'`
  - php -r 'if ( ! ($f = php_ini_loaded_file())) { $f = PHP_CONFIG_FILE_PATH . "/php.ini"; } file_put_contents($f, "variables_order=EGPCS\n", FILE_APPEND); $a = file($f, FILE_IGNORE_NEW_LINES); var_dump($a[count($a)-1]);'

before_script:
  - mongo-orchestration start
  - .travis.scripts/setup_mo.sh
  - ulimit -a
  - ulimit -c unlimited || true
  - .travis.scripts/before_script.sh

script:
  - export MONGODB_URI=`cat /tmp/uri.txt`
  - echo $MONGODB_URI
  - make test

after_success:
  - make coveralls

after_failure:
  - find . -name 'core*' -exec .travis.scripts/debug-core.sh {} \;
  - find . -name '*.diff' -exec .travis.scripts/debug-diff.sh {} \;

after_script:
  - mongo-orchestration stop
