language: cpp
# Do not build latest as this is just a tag on the latest successful release by appveyor
branches:
  except:
  - latest
#To uncomment in case a core occurs:
#sudo: required
# xenial & xvfb to support integrated tests with SDL2 (https://stackoverflow.com/questions/60677892/failed-to-connect-to-mir-on-travis-server)
dist: xenial
services:
 - xvfb
addons:
 apt:
  sources:
    - ubuntu-toolchain-r-test
    #- llvm-toolchain-precise-5.0
  packages:
    - libsdl2-dev
    - libfreetype6-dev
    - zlib1g-dev
    - libpng-dev
    - gcc-9
    - g++-9
    - clang-5.0
    - clang-tidy-5.0
    # For debian package validation
    - dpkg-dev
    - pbuilder
    - quilt
    - devscripts
    - fakeroot
    - debhelper
#To uncomment in case a core occurs:
#    - gdb
before_script:
    - export CXX=g++-9
    - wget http://softpres.org/_media/files:ipflib42_linux-x86_64.tar.gz -O /tmp/ipflib42_linux-x86_64.tar.gz
    - tar -xf /tmp/ipflib42_linux-x86_64.tar.gz 2>&1 >/dev/null
    - sudo cp -r x86_64-linux-gnu-capsimage/include/caps /usr/include

# Build and test both in release and debug to ensure both works fine
script: 
#To uncomment in case a core occurs:
# - ulimit -c unlimited
# - sudo sysctl kernel.core_pattern=core
 - make -j 2 WITH_IPF=true
 - make -j 2 WITH_IPF=true unit_test
 - make -j 2 e2e_test
 - make -j 2 clean
 - make -j 2 debug CFLAGS=-Wno-literal-suffix
 - make -j 2 clang-tidy
 - make -j 2 deb_pkg VERSION=99.99.0 REVISION=1
# Also validate that make install works well.
# APP_PATH could be anything as long as there's no cap32.cfg in it.
 - make -j 2 clean && make -j 2 APP_PATH=/tmp/cap32 DESTDIR=/tmp/cap32 install && test/integrated/test_make_install.sh /tmp/cap32
#To uncomment in case a core occurs:
# - find ./ -name 'core*'
# - for i in $(find ./ -name 'core*' -print); do gdb ./test/test_runner $i -ex "thread apply all bt" -ex "set pagination 0" -batch; done;
