steps:
- bash: |
    sudo apt-get install -y software-properties-common zlib1g zlib1g-dev swig
    sudo add-apt-repository -y ppa:csaba-kertesz/random
    sudo apt-get update
    sudo apt-get install -y boost1.58
    cd /opt
    wget -q https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.tar.gz
    tar xzf cmake-3.12.0-Linux-x86_64.tar.gz
  displayName: Setup build environment
- bash: |
    export CXX=/usr/bin/g++
    export CC=/usr/bin/gcc
    export PATH=/opt/cmake-3.12.0-Linux-x86_64/bin:$PATH
    mkdir build && cd build && \
    cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DBOOST_LIBRARYDIR=/usr/lib/x86_64-linux-gnu \
    -DBOOST_ROOT=/usr \
    -DRDK_INSTALL_INTREE=ON \
    -DRDK_INSTALL_STATIC_LIBS=ON \
    -DRDK_BUILD_CPP_TESTS=OFF \
    -DRDK_BUILD_PYTHON_WRAPPERS=OFF \
    -DRDK_USE_BOOST_REGEX=OFF \
    -DRDK_BUILD_COORDGEN_SUPPORT=ON \
    -DRDK_OPTIMIZE_NATIVE=ON \
    -DRDK_BUILD_TEST_GZIP=OFF \
    -DRDK_BUILD_FREESASA_SUPPORT=ON \
    -DRDK_BUILD_AVALON_SUPPORT=ON \
    -DRDK_BUILD_INCHI_SUPPORT=ON \
    -DRDK_BUILD_SWIG_WRAPPERS=ON \
    -DRDK_SWIG_STATIC=ON \
    -DRDK_BUILD_THREADSAFE_SSS=ON \
    -DRDK_TEST_MULTITHREADED=ON \
    -DBoost_NO_SYSTEM_PATHS=ON \
    -DBoost_USE_STATIC_LIBS=ON
  displayName: Configure build (Run CMake)
- bash: |
    cd build
    VERBOSE=1 make -j $( $(number_of_cores) ) install
  displayName: Build
- bash: |
    export RDBASE=`pwd`
    export PYTHONPATH=${RDBASE}:${PYTHONPATH}
    export LD_LIBRARY_PATH=${RDBASE}/lib:${LD_LIBRARY_PATH}
    export QT_QPA_PLATFORM='offscreen'
    cd build
    ctest -j $( $(number_of_cores) ) --output-on-failure -T Test
  displayName: Run tests
- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'CTest'
    testResultsFiles: 'build/Testing/*/Test.xml'
    testRunTitle: $(system.phasedisplayname) CTest Test Run
