language: c

# use new build environment (docker)
sudo: required

env:
  global:
    # GITAUTH:
    - secure: nSunY54Wp5HkQCHHbKwlwpbaKyqRVIu/0EnhaoJSwhM1wqerQV/E5d/2JelO9/tZgbungAO7wk/fjutRMVc7d378RTIPwS8vHpvZfEoGhCFsLoTOlqESzsZFBup2H5t1lpQ23jRHDOxlLdJy2lz5U+zd1YnYgDXqdDFjegsIYdo=
    # COVERITY_SCAN_TOKEN:
    - secure: C7LLWmOCdRYJGiXjFYDHWwBB6XGjs9Hio4kkvDehLRredRgp1UJ73g6Av9L7xrTUide6GiPrSd+RJw7py/twx5qaeIjOWPy+XvtmabDEQBquLjEkvS+LP2EycaMe92kHMo1ItFfRomgj1FyNYPVnUFgdyedGWv+p553ziDbrMas=


dist: trusty

matrix:
  fast_finish: true
  include:
    - os: linux
      compiler: gcc
      env:
        - ANALYZE=false
        - PYTHON=python2
    - os: linux
      compiler: clang
      env:
        - ANALYZE=false
        - PYTHON=python2
    - os: linux
      compiler: clang
      env:
        - ANALYZE=false
        - PYTHON=python3
    - os: linux
      compiler: tcc
      env:
        - ANALYZE=false
        - PYTHON=python2
    - os: linux
      compiler: gcc
      env: ANALYZE=true
    - os: linux
      compiler: clang
      env: ANALYZE=true
    #- os: linux
    #  compiler: gcc
    #  env: LINT=true
    - os: linux
      compiler: gcc
      env: DOCKER=true
      services:
        - docker
    - os: linux
      compiler: clang
      env: FUZZER=true
    - os: osx
      compiler: clang
      # disable homebrew auto update which takes a lot of time
      env: HOMEBREW_NO_AUTO_UPDATE=1
      cache:
        directories:
          - $HOME/Library/Caches/Homebrew
    - os: linux
      compiler: gcc
      addons:
        sonarcloud:
          organization: open62541
          branches:
            - master
            - sonarcloud
      env:
        - SONAR=true
        - PYTHON=python2
      cache:
        directories:
          - '$HOME/.sonar/cache'
addons:
  apt:
    sources:
      # see https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
    packages:
      - binutils-mingw-w64-i686
      - build-essential
      - check
      - cmake
      - cppcheck
      - gcc-multilib
      - g++-mingw-w64-i686
      - g++-mingw-w64-x86-64
      - g++-multilib
      - graphviz
      - libsubunit-dev
      - libx11-dev
      - mingw-w64
      - python-six
      - python3-six
      - texlive-fonts-recommended
      - texlive-latex-extra
      - texlive-latex-recommended
      - valgrind
      - wget
      - xutils-dev
      - zip
  coverity_scan:
    project:
      name: "open62541/open62541"
      description: "Build submitted by Travis"
    notification_email: null@plt.rwth-aachen.de
    build_command_prepend: "mkdir build && cd build && cmake .."
    build_command: "make"
    branch_pattern: coverity_scan

cache:
  pip: true
  apt: true
  directories:
    - $HOME/install
    - $HOME/.cache/pip

# combine all the commands into one single command. See https://github.com/travis-ci/travis-ci/issues/1066
before_install: |
 set -e
 # Exit travis if on coverity_scan branch and not first build
 test $TRAVIS_BRANCH != coverity_scan -o ${TRAVIS_JOB_NUMBER##*.} = 1 || exit 0
 if [ ${TRAVIS_OS_NAME} == "linux" ]; then echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-; fi
 if [ ${TRAVIS_OS_NAME} == "linux" ]; then sh ./tools/travis/travis_linux_before_install.sh; fi
 if [ ${TRAVIS_OS_NAME} == "osx" ]; then sh ./tools/travis/travis_osx_before_install.sh; fi

script: |
 set -e
 if [ ${TRAVIS_OS_NAME} == "linux" ]; then sh ./tools/travis/travis_linux_script.sh; fi
 if [ ${TRAVIS_OS_NAME} == "osx" ]; then sh ./tools/travis/travis_osx_script.sh; fi

after_success: |
 if [ ${TRAVIS_OS_NAME} == "linux" ]; then sh ./tools/travis/travis_linux_after_success.sh; fi
 # Sleep to flush travis output
 echo == Build success ==
 sleep 5

after_failure: |
 # Sleep to flush travis output
 echo == Build failed ==
 sleep 5

deploy:
  provider: releases
  api_key:
    secure: PKCoA7MBRtHloIbNF4Qj5LQyCafjekfVeFXlMBd9KmC0ynNuef+D7nn38f/jo25/b0Ii7r+hgslkQPezbKyEqo2zcCB8Pn8TWau2hbzKM/dUCPoN90HVaQcRjUi8P2Y+QkouwyPWSujBL35/X5QiAntRotCSbZx4fkyiN8cU95o=
  file:
    - open62541-win32.zip
    - open62541-win64.zip
    - open62541-linux32.tar.gz
    - open62541-linux64.tar.gz
    - open62541-raspberrypi.tar.gz
    - open62541.c
    - open62541.h
  skip_cleanup: true
  on:
    repo: open62541/open62541
    tags: true
    condition: $CC = gcc && $ANALYZE = false