language: cpp
dist: trusty
sudo: false

matrix:
  include:
# First check if all our options are good
#   Renewal without VIP
    - os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
         - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
         - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=no --enable-buildbot=yes"
#   Renewal with VIP
    - os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
         - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
         - CONFIGURE_FLAGS="--enable-prere=yes --enable-vip=no --enable-buildbot=yes"
#   Pre-Renewal without VIP
    - os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
         - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
         - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=yes --enable-buildbot=yes"
#   Pre-Renewal with VIP
    - os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
         - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
         - CONFIGURE_FLAGS="--enable-prere=yes --enable-vip=yes --enable-buildbot=yes"
# After that check all different compilers and compiler versions
# GCC
#   Version 6
    - os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-6
      env:
        - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
        - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=no --enable-buildbot=yes"
#   Version 7
    - os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env:
        - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
        - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=no --enable-buildbot=yes"
#   Version 8
    - os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-8
      env:
        - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
        - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=no --enable-buildbot=yes"
# Clang
#   Version 3.9
    - os: linux
      addons:
        apt:
          sources:
            - llvm-toolchain-trusty-3.9
          packages:
            - clang-3.9
      env:
        - MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
        - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=no --enable-buildbot=yes"
#   Version 4
    - os: linux
      addons:
        apt:
          sources:
            - llvm-toolchain-trusty-4.0
          packages:
            - clang-4.0
      env:
        - MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
        - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=no --enable-buildbot=yes"
#   Version 5
    - os: linux
      addons:
        apt:
          sources:
            - llvm-toolchain-trusty-5.0
          packages:
            - clang-5.0
      env:
        - MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"
        - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=no --enable-buildbot=yes"
#   LLVM on OSX
#    - os: osx
#      osx_image: xcode9.2
#      install:
#        - brew update
#        - brew install mysql
#        - brew tap homebrew/services
#        - brew services start mysql
##         MySQL takes a while to start...
#        - brew services list
#        - launchctl list | grep mysql
#      before_install: false
#      env:
#        - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=no --enable-buildbot=yes --enable-lto=no"
#      script:
#        - ./configure $CONFIGURE_FLAGS
##         MacOS default MySQL configuration does not like our card seller(only full group by)
#        - ./tools/ci/npc.sh
#        - make clean
#        - make all
#        - ./login-server --run-once
#        - ./char-server --run-once
#        - ./map-server --run-once
# CMake
    - os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
         - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
      script:
         - mkdir cbuild
         - cd cbuild
         - cmake -G "Unix Makefiles" ..
         - make || travis_terminate 1
# MariaDB
    - os: linux
      addons:
        mariadb: '10.0'
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
            - libmariadbclient-dev
      env:
         - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
         - CONFIGURE_FLAGS="--enable-prere=no --enable-vip=no --enable-buildbot=yes"

before_install:
    - eval "${MATRIX_EVAL}"

before_script:
  - uname -a
  - ./tools/ci/sql.sh

script:
  - ./configure $CONFIGURE_FLAGS || travis_terminate 1
  - ./tools/ci/npc.sh
  - make clean || travis_terminate 1
  - make all || travis_terminate 1
  - ./login-server --run-once
  - ./char-server --run-once
  - ./map-server --run-once

env:
  global:
    - DB_ROOT="root"
    - DB_HOST="127.0.0.1"
    - DB_NAME="ragnarok"
    - DB_USER="ragnarok"
    - DB_PASS="ragnarok"

notifications:
  email: false
