# vim ft=yaml
#
# Travis CI configuration

language: c

os:
  - linux
  - osx

compiler:
  - gcc
  - clang

addons:
  apt:
    packages:
    - libmysqlclient-dev
    - libpq-dev
    - libaio-dev

services:
  - mysql
  - postgresql

before_install:
  - >
    case "${TRAVIS_OS_NAME:-linux}" in
    osx)
      # Workaround for https://github.com/Homebrew/legacy-homebrew/issues/43874
      # brew uninstall libtool
      # brew update --quiet
      # brew install libtool mysql
      brew install mysql

      # OS X requires servers to be started explicitly
      brew services start mysql

      # Avoid PostgreSQL upgrade woes, just reinstall the database
      brew uninstall postgresql
      rm -rf /usr/local/var/postgres
      brew install postgresql

      echo "Starting PostgreSQL"
      pg_ctl -wD /usr/local/var/postgres start
      echo "Creating user postgres"
      createuser -s postgres
      ;;
    esac

install:
  - pip install --user cram cpp-coveralls
  - >
    case "${TRAVIS_OS_NAME:-linux}" in
    osx)
      # OS X requires this for user-local pip packages
      export PATH=~/Library/Python/2.7/bin:$PATH
      ;;
    esac

before_script:
  - mysql -u root -e 'CREATE DATABASE sbtest'
  - psql -U postgres -c 'CREATE DATABASE sbtest'

script:
  - ./autogen.sh && ./configure --enable-coverage --with-mysql --with-pgsql
  - make
  - make distcheck
  - SBTEST_MYSQL_ARGS="--mysql-user=root" SBTEST_PGSQL_ARGS="--pgsql-user=postgres" make test

after_success:
  - coveralls --gcov-options '\-lp'

# Local variables:
# mode: yaml
# End:
