env:
  - PACKAGE_VERSION=1.3.6a

language: c

compiler:
  - gcc
  - clang

services:
  - docker
  - redis-server

install:
  - sudo apt-get update -qq
  # for unit tests
  - sudo apt-get install -y check
  - sudo apt-get install -y libsubunit-dev
  # for mod_lang
  - sudo apt-get install -y gettext
  # for xattr support
  - sudo apt-get install -y libattr1-dev
  # for mod_cap
  - sudo apt-get install -y libcap-dev
  # for mod_geoip
  - sudo apt-get install -y libgeoip-dev
  # for mod_ldap
  - sudo apt-get install -y libldap2-dev libsasl2-dev
  # for memcache support
  - sudo apt-get install -y libmemcached-dev
  # for redis support
  - sudo apt-get install -y libhiredis-dev
  # for mod_sql_mysql
  - sudo apt-get install -y libmysqlclient-dev
  # for PAM support
  - sudo apt-get install -y libpam-dev
  # for mod_sql_postgres
  - sudo apt-get install -y libpq-dev
  # for mod_sql_odbc
  - sudo apt-get install -y unixodbc-dev
  # for OpenSSL support
  - sudo apt-get install -y libssl-dev
  # for Sodium support
  - sudo apt-get install -y --force-yes libsodium-dev
  # for mod_sql_sqlite
  - sudo apt-get install -y libsqlite3-dev sqlite3
  # for mod_wrap
  - sudo apt-get install -y libwrap0-dev
  # for PCRE support
  - sudo apt-get install -y libpcre3-dev
  # for zlib support
  - sudo apt-get install -y zlib1g-dev
  # for static code analysis
  # - sudo apt-get install -y cppcheck
  # - sudo apt-get install -y rats
  # for test code coverage
  - sudo apt-get install -y lcov
  - gem install coveralls-lcov
  # for HTML validation
  - sudo apt-get install -y tidy

before_script:
  - cd ${TRAVIS_BUILD_DIR}
  - lcov --directory . --zerocounters

script:
  # - find . -type f -name "*.c" -print | grep -v tests | xargs cppcheck 2>&1
  # - find . -type f -name "*.c" -print | grep -v tests | xargs rats --language=c
  - ./configure LIBS="-lodbc -lm -lsubunit -lrt -pthread" --enable-devel=coverage --enable-ctrls --enable-facl --enable-memcache --enable-nls --enable-pcre --enable-redis --enable-tests --with-modules=mod_sql:mod_sql_mysql:mod_sql_odbc:mod_sql_postgres:mod_sql_sqlite:mod_sql_passwd:mod_sftp:mod_sftp_sql:mod_sftp_pam:mod_tls:mod_tls_fscache:mod_tls_shmcache:mod_tls_memcache:mod_tls_redis:mod_ban:mod_copy:mod_ctrls_admin:mod_deflate:mod_dnsbl:mod_dynmasq:mod_exec:mod_facl:mod_geoip:mod_ifversion:mod_ldap:mod_load:mod_log_forensic:mod_qos:mod_quotatab:mod_quotatab_file:mod_quotatab_ldap:mod_quotatab_radius:mod_quotatab_sql:mod_radius:mod_readme:mod_rewrite:mod_shaper:mod_site_misc:mod_snmp:mod_wrap:mod_wrap2:mod_wrap2_file:mod_wrap2_redis:mod_wrap2_sql:mod_digest:mod_auth_otp:mod_statcache:mod_unique_id:mod_ifsession
  - make
  - make TEST_VERBOSE=1 check-api
  - make clean
  - ./configure LIBS="-lodbc -lm -lsubunit -lrt -pthread" --enable-devel --enable-ctrls --enable-dso --enable-facl --enable-memcache --enable-nls --enable-pcre --enable-tests --with-shared=mod_sql:mod_sql_mysql:mod_sql_odbc:mod_sql_postgres:mod_sql_sqlite:mod_sql_passwd:mod_sftp:mod_sftp_sql:mod_sftp_pam:mod_tls:mod_tls_fscache:mod_tls_shmcache:mod_tls_memcache:mod_ban:mod_copy:mod_ctrls_admin:mod_deflate:mod_dnsbl:mod_dynmasq:mod_exec:mod_facl:mod_geoip:mod_ifversion:mod_ldap:mod_load:mod_log_forensic:mod_qos:mod_quotatab:mod_quotatab_file:mod_quotatab_ldap:mod_quotatab_radius:mod_quotatab_sql:mod_radius:mod_readme:mod_rewrite:mod_shaper:mod_site_misc:mod_snmp:mod_wrap:mod_wrap2:mod_wrap2_file:mod_wrap2_redis:mod_wrap2_sql:mod_digest:mod_auth_otp:mod_statcache:mod_unique_id:mod_ifsession
  - make
  # NOTE: Temporarily commented out until the EPEL metalink issues (stale
  # epel-release-7-10.noarch.rpm with regard to EPEL mirror updates on
  # 2017-11-09) are sorted.
  # - (cd contrib/dist/travis && sudo docker run -e PACKAGE_VERSION=${PACKAGE_VERSION} -e TRAVIS_BRANCH=${TRAVIS_BRANCH} -v `pwd`:`pwd` -w `pwd` centos:centos7 /bin/bash `pwd`/docker-rpmbuild.sh)

after_success:
  - cd ${TRAVIS_BUILD_DIR}
  # capture the test coverage info
  - lcov --ignore-errors gcov,source --directory . --capture --output-file coverage.info
  # filter out system and test code
  - lcov --remove coverage.info 'lib/glibc-glob.*' 'lib/ccan-json.*' 'lib/hanson-tpl.*' 'lib/pr_fnmatch_loop.*' 'tests/*' '/usr/*' --output-file coverage.info
  # debug before upload
  - lcov --list coverage.info
  # upload coverage info to coveralls
  - coveralls-lcov coverage.info
  # Run some validation on the docs
  - for f in `/bin/ls doc/contrib/*.html doc/howto/*.html doc/modules/*.html doc/utils/*.html`; do echo "Processing $f"; tidy -errors -omit -q $f; done
