language: cpp

jobs:
  include:
    - os: linux
      dist: bionic
      services: docker
      compiler: gcc
      env:
        - BUILD_TYPE="docker"
        - DOCKER_IMG="qtio"
    - os: linux
      dist: bionic
      services: docker
      compiler: clang
      env:
        - BUILD_TYPE="docker"
        - DOCKER_IMG="qtio"
    - os: linux
      dist: bionic
      services: docker
      compiler: gcc
      env:
        - BUILD_TYPE="docker"
        - DOCKER_IMG=""
    - os: linux
      dist: bionic
      services: docker
      compiler: gcc
      env:
        - BUILD_TYPE="docker"
        - DOCKER_IMG="focal"
        - DOCKER_SCRIPT="./tools/build_extra_tests"
    - os: linux
      dist: bionic
      services: docker
      compiler: gcc
      env:
        - BUILD_TYPE="docker"
        - DOCKER_IMG="f32"
    #- os: linux
    #  dist: xenial
    #  compiler: gcc
    #  env:
    #    - BUILD_TYPE="local"
    #    - QT_VERSION="5.9.9" # 5.12.1 vtesto stmsdf fails with valgrind 3.11.0 which is on xenial
    #  addons:
    #    apt:
    #      packages:
    #        - expat
    #        - fop
    #        - valgrind
    #        - xsltproc
    #        - libxml2-utils
    #        - libusb-1.0-0-dev
    #        - docbook-xml
    #        - docbook-xsl
    #        - libgl1-mesa-dev
    #        - libxkbcommon-x11-0 # for qt onliner installer 3.2.1
    #  cache:
    #    directories:
    #      - $HOME/Cache
    #    timeout: 600
    - os: osx
      compiler: clang
      env:
        - QT_VERSION="5.9.9"
        - QT_INSTALL_METHOD="installer"
      cache:
        directories:
          - $HOME/Cache
        timeout: 600
    - os: osx
      osx_image: xcode10.3
      compiler: clang
      env:
        - QT_VERSION="5.12.10"
        - QT_INSTALL_METHOD="installer"
      cache:
        directories:
          - $HOME/Cache
        timeout: 600
    - os: osx
      osx_image: xcode11.6
      compiler: clang
      env:
        - QT_VERSION="5.15.2"
        - QT_INSTALL_METHOD="artifactory"
      cache:
        directories:
          - $HOME/Cache
        timeout: 600
    - os: linux
      dist: focal
      compiler: gcc
      env:
        - BUILD_TYPE="coverage"
      addons:
        apt:
          packages:
            - gcovr
            - lcov
            - libusb-1.0-0-dev
            - qt5-default

install:
  - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "local" ]; then ./tools/travis_install_linux_local ${QT_VERSION} && source ${HOME}/Cache/qt-${QT_VERSION}.env; fi
  - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./tools/travis_install_osx ${QT_VERSION} ${QT_INSTALL_METHOD} && source ${HOME}/Cache/qt-${QT_VERSION}.env; fi

script:
  - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "coverage" ]; then ./tools/travis_script_linux_coverage; fi
  - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "docker" ]; then ./tools/travis_script_linux_docker ${DOCKER_IMG} ${DOCKER_SCRIPT}; fi
  - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "local" ]; then echo $PATH; ./build_and_test; fi
  - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./tools/travis_script_osx; fi

after_success:
  - cd ${TRAVIS_BUILD_DIR}
  # only deploy pushes to master or prs that target master.  the prs will go to transfr.sh, the pushes go to github.
  - if [ "${TRAVIS_OS_NAME}" = "osx" ] &&  [ "${QT_VERSION}" = "5.12.10" ] && [ "$TRAVIS_BRANCH" = "master" ]; then bash ./tools/uploadtool/upload.sh  gui/GPSBabel-*.dmg; fi

branches:
  except:
    - /^(?i:continuous)$/  # Do not build tags that we create when we upload to GitHub Releases
    - /^(?i:continuous.*windows)$/  # Do not build tags that we create when we upload to GitHub Releases

