os: linux
dist: focal
language: cpp

env:
  - ARMADILLO=latest SANITY_HISTORY=perform
  - ARMADILLO=minimum

stages:
  - test
  - name: sanity
    if: type = pull_request AND env(SANITY_HISTORY) = "perform"

jobs:
  include:
    - stage: sanity
      name: "HISTORY.md Check"
      script: sh ./scripts/history-update-check.sh

script:
  - sudo apt-get update
  - sudo apt-get install -y --allow-unauthenticated libopenblas-dev liblapack-dev g++ xz-utils
  - if [ $ARMADILLO == "latest" ]; then
      curl https://ftp.fau.de/macports/distfiles/armadillo/`curl https://ftp.fau.de/macports/distfiles/armadillo/ -- | grep '.tar.xz' | sed 's/^.*<a href="\(armadillo-[0-9]*.[0-9]*.[0-9]*.tar.xz\)".*$/\1/' | tail -1` | tar xvJ && cd armadillo*;
    else
      curl -L https://sourceforge.net/projects/arma/files/armadillo-9.800.6.tar.xz | tar -xvJ && cd armadillo*;
    fi
  - cmake . && make && sudo make install && cd ..
  - mkdir build && cd build && cmake .. && make ensmallen_tests -j2
  - CTEST_OUTPUT_ON_FAILURE=1 travis_wait 30 ctest -j2

notifications:
  email:
    - mlpack-git@lists.mlpack.org
  irc:
    channels:
      - "chat.freenode.net#mlpack"
    on_success: change
    on_failure: always
