# Travis CI configuration for libseccomp

# https://docs.travis-ci.com/user/reference/bionic
# https://wiki.ubuntu.com/Releases

dist: bionic

notifications:
  email:
    on_success: always
    on_failure: always

arch:
  - amd64
  - arm64
  - ppc64le

os:
  - linux

language: c
compiler:
  - gcc

language: python

addons:
  coverity_scan:
    project:
      name: "seccomp/libseccomp"
      description: "Build submitted via Travis CI"
    notification_email: paul@paul-moore.com
    build_command_prepend: "./configure; make clean"
    build_command: "make check-build"
    branch_pattern: coverity-scan
  apt:
    packages:
      - build-essential
      - valgrind
      - clang
      - lcov
      - gperf

env:
  global:
    # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
    #   via the "travis encrypt" command using the project repo's public key
    - secure: "k2MNZTt+rn7K1fEHINFDgwXcW1iQ6sUFTRHf74oRrWEpQKAkug5YG3PdS3nJJHmo3//YUk7IFxdSior+ht+1NtqzQwuGQNjspar/dGb2ohqgaqJSzLu23vs16Rjmgg+D3ZF+kAXyQNnE+XSgGqsV+tpE38oXs202ZGDZJ6R8c+xuwKSG+R9Kcn8wLtxnjyc3z9Lx9dNsitpdU21MGEq/HgdLteKRTKBPklnyJZ2ejAhdqL1djwHA5SE2/3GeMiDn/eZLLLclIMd8wZBGqT1Nb0NW/MvwEcz771cekcHAAAQbgwN4532RoBRic52hHNmFrOTZr/3t4+CvNIzHuDt9XljaUngSVOcu7Y3V/Ct11HtfnZwzkww73a33xAp2wnbXXMM6vCjUeAojR5+sQeL8Lr/eyEpDNvAhfIndp5cTs3dNppRggzkuIDFr1Fz5Ydflns5zL0vIOTJZ5pCeL7Yik+0ggoTnPIcqpwMhvsnMuKCVxe1ilrm/cdGLGXJf2mvmFqc44LjI/m+bogXao7vDXGWjyCRbWwmpKX9trwPdW/lKOtmfzhvU3YSiEG0v8BStLCiMN6SXj+mJkL01EDSonffXbH4QFwhtFDGQjNUcFr0Vt8gFWN1sMr2w30D79kDiowqWAqMYHzHMOqZF1zxyL3as1yqEXjyrPrjFPg2rHqw="

# resolve any remaining dependency issues
before_install:
  # assume the distro has an old version of cython
  - pip install cython
  # see https://github.com/eddyxu/cpp-coveralls
  - |
    if [ $TRAVIS_CPU_ARCH == "amd64" ]; then
      pip install cpp-coveralls
    fi

# perform the build and fail immediately on error
install:
  - ./autogen.sh

# NOTE: the coverity_scan plugin runs between "install" and "script"

# run all of the tests independently, fail if any of the tests error
script:
  - ./configure --enable-python
  - make check-build
  - LIBSECCOMP_TSTCFG_STRESSCNT=5 make check
  - LIBSECCOMP_TSTCFG_TYPE=live LIBSECCOMP_TSTCFG_MODE_LIST=c make -C tests check
  - |
    if [ $TRAVIS_CPU_ARCH == "amd64" -o -x scan-build ]; then
      make clean && ./configure && scan-build --status-bugs make
    fi

after_success:
  # limit the code coverage tests to the 'test-code-coverage' target
  # https://github.com/eddyxu/cpp-coveralls/blob/master/README.md
  - |
    if [ $TRAVIS_CPU_ARCH == "amd64" ]; then
      make clean && ./configure --enable-code-coverage && make test-code-coverage && coveralls --gcov-options '\-lp' --exclude tests --exclude tools --exclude src/arch-syscall-check.c
    fi
