language: cpp
env:
  global:
  - secure: Zo+BbyV3sgNmKHwWvn7cCt3leXCLGbE9rSrAYoCrl22OEDZjPj7KeGzQ/59xLosE5v8PA5MV8KceH7aQB9GoIbDt6sHLw5mws13VXmy5HWtM7yhk2RpNnn1gTZIfEz33QGYuPG1geapTcZtZfaVKFU04PMkvk3f7zxA1HuS6zGRgzrNv1AmcpuOGH4LIGxbk3Z1S6xGcUMj/z9calyLlmPTOfbDLJWChU11FMVmvdTzyeDLE0oQZ5IkmsowluCfDHARfIijeRuPiuU8RzJptYEIzcWvpQ6gfDb4qDWndA9BgPDkN2aTmPL5/TA/S9zfs8BKjo07sg0TaVbTboPisyS/gGDf3SBYxlAS9B95KKdRzGGD41ZYe+cHod5tgWUt5gO/Obq2MPY/GltSwuq5KEsR+R/pKVLby/k7+R5oCO8avXJPL5HBgn46ZehEzpw0I8LFQ/ed+dLqykrxaSiA2/zHAkHSeVZptzegoCF5xeDf6T/rJFNqxr1BV3kVLPiXW90z0m63Hv2K6rz8LmBUNTQcR/mrLpkpdbQ8UQ/et30o7CE2GcJLLzUDNcjxYfA1fe66oR9L+euqyBtZc8dNuzy1iIaUOLazGWYkdlUpiYnGvWrxv6BUwzAJYpiXjWELtcTVUGMjMBpkvAmwV1FjZN45isX2iHGz5XhoVDrjbE5c=
jobs:
  include:
  - stage: main test
    os: linux
    dist: xenial
    compiler: clang
    env:
    - DEPLOY=false
    - CCACHE_CPP2=yes
    - RUN_TESTS=true
    cache:
      ccache: true
      directories:
      - "$HOME/.sonar/cache"
  - os: linux
    dist: bionic
    compiler: clang
    env:
    - DEPLOY=false
    - CCACHE_CPP2=yes
    - RUN_TESTS=true
    cache:
      ccache: true
      directories:
      - "$HOME/.sonar/cache"
  - os: osx
    compiler: clang
    env:
    - DEPLOY=true
    - LEGACY=false
    - XCODE=xcode12_2
    osx_image: xcode12.2
    cache:
      directories:
      - "$HOME/Library/Caches/Homebrew"
      - "/usr/local/Homebrew"
  - os: osx
    compiler: clang
    env:
    - DEPLOY=true
    - LEGACY=false
    - XCODE=xcode11
    osx_image: xcode11
    cache:
      directories:
      - "$HOME/Library/Caches/Homebrew"
      - "/usr/local/Homebrew"
  - os: osx
    compiler: clang
    env:
    - DEPLOY=true
    - LEGACY=true
    - XCODE=xcode8
    osx_image: xcode8
    cache:
      directories:
      - "$HOME/Library/Caches/Homebrew"
      - "/usr/local/Homebrew"
before_cache:
  - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then brew cleanup; fi
# Credit https://discourse.brew.sh/t/best-practice-for-homebrew-on-travis-brew-update-is-5min-to-build-time/5215/9
# Cache only .git files under "/usr/local/Homebrew" so "brew update" does not take 5min every build
  - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then find /usr/local/Homebrew \! -regex ".+\.git.+" -delete; fi
before_install:
- |
  if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
    sudo apt-get -qq update;
    sudo apt-get install -y qtbase5-dev;
    sudo apt-get install -y libqt5svg5-dev;
    sudo apt-get install -y qt5-default;
    sudo apt-get install -y qttools5-dev-tools;
    sudo apt-get install -y libqt5xmlpatterns5-dev;
    sudo apt-get install -y libqt5core5a;
    sudo apt-get install -y libqt5gui5;
    sudo apt-get install -y libqt5printsupport5;
    sudo apt-get install -y libqt5svg5;
    sudo apt-get install -y libqt5widgets5;
    sudo apt-get install -y libqt5xml5;
    sudo apt-get install -y libqt5xmlpatterns5;
    sudo apt-get install -y xpdf;
    sudo apt-get install -y xvfb;
    wget https://launchpad.net/ubuntu/+archive/primary/+files/ccache_3.3.4-1_amd64.deb;
    sudo dpkg -i ccache_3.3.4-1_amd64.deb;
  else
    if [[ "$LEGACY" = false ]]; then
      brew update > /dev/null;
      brew install qt5;
      chmod -R 755 /usr/local/opt/qt5/*
    else
      unset SSL_CERT_FILE;
      HOMEBREW_NO_AUTO_UPDATE=1 brew install https://gist.githubusercontent.com/dismine/c3ac01de38e12edcf22d9e05791adf82/raw/1218041ffba3ff4b64d109e64a9a867f8fe394c1/qt.rb;
      brew link qt --force;
      chmod -R 755 /usr/local/opt/qt/*;
      HOMEBREW_NO_AUTO_UPDATE=1 brew install python3;
    fi
    python3 --version;
    pip3 install dropbox;
  fi
before_script:
- |
  if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
    uname -a;
    which qmake;
  else
    QTDIR="/usr/local/opt/qt5";
    PATH="$QTDIR/bin:$PATH";
    LDFLAGS=-L$QTDIR/lib;
    CPPFLAGS=-I$QTDIR/include;
    PKG_CONFIG_PATH=/usr/local/opt/qt5/lib/pkgconfig;
  fi
- mkdir build
- cd build
- pwd
- qmake --version
- |
  if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
    if [[ "$RUN_TESTS" == "true" ]]; then
      qmake ../Valentina.pro -r -spec linux-clang CONFIG+=noDebugSymbols CONFIG+=checkWarnings;
    else
      qmake ../Valentina.pro -r -spec linux-clang CONFIG+=noDebugSymbols CONFIG+=checkWarnings CONFIG+=noTests;
    fi
  else
    if [[ "$LEGACY" = false ]]; then
      qmake ../Valentina.pro -r CONFIG+=noDebugSymbols CONFIG+=no_ccache CONFIG+=checkWarnings CONFIG+=noTests;
    else
      qmake ../Valentina.pro -r CONFIG+=noDebugSymbols CONFIG+=no_ccache CONFIG+=noTests;
    fi
  fi
script:
- "$CXX --version"
- |
  if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
    make -j$(nproc);
    if [[ "$RUN_TESTS" == "true" ]]; then
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$TRAVIS_BUILD_DIR/build/src/libs/vpropertyexplorer/bin:$TRAVIS_BUILD_DIR/build/src/libs/qmuparser/bin";
      xvfb-run -a make --silent check TESTARGS="-silent";
    fi
  else
    make -j1;
  fi
notifications:
  email:
    recipients:
    - dismine@gmail.com
    on_success: change
    on_failure: always
after_success:
- ../scripts/travis-deploy.sh