language: erlang

otp_release:
  - 19.0
  - 20.3
  - 21.1

services:
  - redis-server

before_install:
  #
  # We need MySQL 5.6 or newer in order to get support for FULLTEXT indexes
  # with InnoDB. As soon as Travis ships that version, the following lines
  # (except for the "apt-get update" call) can go away.
  #
  # See: https://github.com/travis-ci/travis-ci/issues/1986
  #
  - sudo sed -i -e s/table_cache/table_open_cache/ -e /log_slow_queries/d /etc/mysql/my.cnf
  - sudo apt-key adv --import .travis/mysql_repo_key.asc
  - sudo add-apt-repository 'deb http://repo.mysql.com/apt/ubuntu/ precise mysql-5.6'
  - sudo apt-get -qq update
  - sudo apt-get -qq -o Dpkg::Options::=--force-confold install mysql-server
  - sudo mysql_upgrade
  # /END MYSQL 5.6
  - pip install --user coveralls-merge

install:
  - sudo apt-get -qq install libexpat1-dev libyaml-dev libpam0g-dev libsqlite3-dev libgd-dev libwebp-dev

before_script:
  # Ulimit: See Travis-CI issue report: https://github.com/travis-ci/travis-ci/issues/3328
  - mysql -u root -e "CREATE USER 'ejabberd_test'@'localhost' IDENTIFIED BY 'ejabberd_test';"
  - mysql -u root -e "CREATE DATABASE ejabberd_test;"
  - mysql -u root -e "GRANT ALL ON ejabberd_test.* TO 'ejabberd_test'@'localhost';"
  - mysql -u root ejabberd_test < sql/mysql.sql
  - psql -U postgres -c "CREATE USER ejabberd_test WITH PASSWORD 'ejabberd_test';"
  - psql -U postgres -c "CREATE DATABASE ejabberd_test;"
  - psql -U postgres ejabberd_test -f sql/pg.sql
  - psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE ejabberd_test TO ejabberd_test;"
  - psql -U postgres ejabberd_test -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO ejabberd_test;"

script:
  - ./autogen.sh
  - ./configure --prefix=/tmp/ejabberd --enable-all --disable-odbc --disable-riak
  - make
  - make install -s
  - make xref
  - sed -i -e 's/ct:pal/ct:log/' test/suite.erl
  - ln -sf ../sql priv/
  - echo "" >> rebar.config
  - echo '{ct_extra_params, "-verbosity 20"}.' >> rebar.config
  - escript ./rebar skip_deps=true ct -v
  - grep -q 'TEST COMPLETE,.* 0 failed' logs/raw.log

after_script:
  - find logs -name suite.log -exec cat '{}' ';'

after_failure:
  - find logs -name exunit.log -exec cat '{}' ';'
  - find logs -name ejabberd.log -exec cat '{}' ';'
  - find logs -name suite.log -exec cat '{}' ';' | awk 'BEGIN{RS="\n=case";FS="\n"} /=result\s*failed/ {print "=case" $0}

after_success:
  - coveralls-merge erlang.json

notifications:
  email: false
