language: c
compilers:
  - clang
  - gcc
env:
  # Don't use `NGINX` as the variable name or Nginx won't daemonise
  # Mainline
  - SHIB_NGINX_VERSION=1.13.6 SHIB_DYNAMIC_MODULE=true
  - SHIB_NGINX_VERSION=1.13.6 SHIB_DYNAMIC_MODULE=false
  # Stable
  - SHIB_NGINX_VERSION=1.12.2 SHIB_DYNAMIC_MODULE=true
  - SHIB_NGINX_VERSION=1.12.2 SHIB_DYNAMIC_MODULE=false
  # Past stable versions
  - SHIB_NGINX_VERSION=1.10.3 SHIB_DYNAMIC_MODULE=false
  - SHIB_NGINX_VERSION=1.8.1 SHIB_DYNAMIC_MODULE=false
sudo: false
addons:
  apt:
    packages:
      - libpcre3-dev
      - libssl-dev
      - perl
      - cpanminus
cache:
  apt: true
  cpan: true
  ccache: true
  directories:
    - $HOME/perl5
before_install:
  - cpanm --notest --local-lib=$HOME/perl5 Test::Nginx
install:
  - wget -O - http://nginx.org/download/nginx-${SHIB_NGINX_VERSION}.tar.gz | tar -xzf -
  - cd nginx-${SHIB_NGINX_VERSION}
  - git clone https://github.com/openresty/headers-more-nginx-module.git -b v0.30
  - |
    if [ "$SHIB_DYNAMIC_MODULE" = true ]; then
      ./configure --with-debug --add-dynamic-module=.. --add-dynamic-module=./headers-more-nginx-module
    else
      ./configure --with-debug --add-module=.. --add-module=./headers-more-nginx-module
    fi
  - make
  - export PATH=$(pwd)/objs:$PATH
  - export SHIB_MODULE_PATH=$(pwd)/objs
  - cd ..
script:
  - PERL5LIB=$HOME/perl5/lib/perl5 TEST_NGINX_VERBOSE=true prove -v
after_failure:
  - cat t/servroot/conf/nginx.conf
  - cat t/servroot/access.log
  - cat t/servroot/error.log
