---
language: c

jobs:
  allow_failures:
    - os: osx
    - stage: sanitizers
    - arch: arm64
  fast_finish: true
  include:
    - &test-linux
      stage: test
      os: linux
      dist: bionic
      arch: amd64
      compiler: clang
      addons:
        apt:
          packages:
            - nghttp2
            - python3-docutils
            - python3-sphinx
            - libunwind-dev
            - libpcre2-dev
      before_script:
        - ./autogen.sh
        - ./configure --enable-maintainer-mode --with-unwind
      script: &script-common
        - make -j16 check VERBOSE=1
    - <<: *test-linux
      arch: arm64
    - <<: *test-linux
      compiler: gcc
      before_script:
        - ./autogen.sh
        - ./configure --enable-maintainer-mode
    - <<: *test-linux
      compiler: gcc
      arch: arm64
      before_script:
        - ./autogen.sh
        - ./configure --enable-maintainer-mode
    - <<: *test-linux
      env: WITNESS=1
      script: make -j16 witness VERBOSE=1
    - <<: *test-linux
      stage: sanitizers
      addons:
        apt:
          sources:
            - sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
              key_url: https://apt.llvm.org/llvm-snapshot.gpg.key
            - ubuntu-toolchain-r-test
          packages:
            - clang-9
            - libunwind-dev
            - llvm-9
            - nghttp2
            - python3-docutils
            - python3-sphinx
            - libpcre2-dev
      env: ASAN=1 UBSAN=1
      before_script:
        - |
          export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0,use_sigaltstack=0,disable_coredump=0
          export LSAN_OPTIONS=abort_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/lsan.suppr
          export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr
          export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr
          export CC=clang-9
        - ./autogen.sh
        - ./configure --enable-maintainer-mode --with-unwind --enable-debugging-symbols --disable-stack-protector --with-persistent-storage --enable-asan --enable-ubsan --enable-workspace-emulator
    - stage: test
      os: osx
      osx_image: xcode12.5
      compiler: clang
      addons:
        homebrew:
          packages:
            - docutils
            - nghttp2
            - sphinx-doc
      before_script:
        - export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"
        - ./autogen.sh
        - ./configure --enable-maintainer-mode
      script: *script-common
    - <<: *test-linux
      stage: coverity
      env:
        - secure: "TndnHrwJk9FRSuVQWUk+ZrRc0jcNc0PW3TnvbRicIIwvYSLkMV5Y1tCQ5Jq/P98DA48/N/gf9DCAiFkxrNSKVeOY70FKgHYWlS130GhTv7r0c8zd+CdEXNORclcbBNV5F3Pli/LxZ+RUImjOfwcIcWV4eYv54Xv7aNFDAaDt4G9QlkSwXykLlZkoWLJQXFbhDBFioT1F1mucD9q9izEEeE+kqO1QH/IfobAq9v7/WrcS38sYI+0WvB1S0ajWuZJgRYqy1bocDNcQd05Vbr9NfAdJ9y+4VTuluZtTUyLxu3/0Tw8mAjHkcpOeNU26r3LnpdRk+5JuOFej/MrCmYRRawVfyvNGtu9RwcMkv8jl48TTs5kTf6UwFqJhe85QSlSi7IszfrE8HfB7B6u8eRr67rqjTr9k/BwEQyoBdK4JElQDj4A1GYHClomxgzmMZnVLvStnAm+IjdNlee4SfY0jj2KfPBd/v6Ms+LGVqNV9NDDKRQdOQD+H52MkIWs5Xu9fU5VaWP+xjFomA9aXex3r5FCssgyQ2P+HtWPdjNEtrkNezzfZ5b+VBVP87RdxfSqkZaRxi6gof0AgeTHWoi7GN1scseiKLxxCI7C0dfQgKrXTN7mZdcED1MMYdiaSI9mlSYQDDUHMQGeY1n3a9D6bUcC/TcmYo524PoTFBZgbbYM="
      before_script:
        - curl
            --data "token=$COVTOKEN&project=varnish"
            --insecure
            -o coverity_tool.tgz https://scan.coverity.com/download/cxx/linux64
        - tar xfz coverity_tool.tgz
        - export PATH=$PATH:$(echo $(pwd)/cov-analysis-*/bin)
      script:
        - ./autogen.sh
        - ./configure --enable-maintainer-mode --with-unwind
        - cov-build --dir cov-int make
        - tar cfz varnish.tgz cov-int
        - curl --form token="$COVTOKEN"
            --form email=varnish-dev@varnish-cache.org
            --form file=@varnish.tgz
            --form version="$TRAVIS_COMMIT"
            --form description="$TRAVIS_BRANCH"
            --insecure
            'https://scan.coverity.com/builds?project=varnish'

stages:
  - name: test
    if: type != cron
  - name: sanitizers
    if: type != cron AND
        type != pull_request
  - name: coverity
    if: type = cron

notifications:
  irc:
    if: branch = master AND
        repo = varnishcache/varnish-cache
    channels:
      - "irc.linpro.no#varnish-hacking"
    on_success: change
    use_notice: true

