language: generic
os: linux
dist: trusty

services:
  - docker

## NOTE: Since we're using a docker image for testing,
## we can ONLY use those PERL & TEX combinations which are pre-built!
## [And use env PERL=5.xx, NOT perl:5.xx ]
env:
  ## Testing without texlive  -- perl 5.28, 5.26.2, 5.24.4
  - PERL=5.28.0 TEX=none
  - PERL=5.26.2 TEX=none
  - PERL=5.24.4 TEX=none
  - PERL=5.20.3 TEX=none
  - PERL=5.14.4 TEX=none
  ## Testing with texlive 2018 -- perl 5.28
  - PERL=5.28.0 TEX=texlive-2018
  ## Testing with texlive 2016 -- perl 5.26
  - PERL=5.26.2 TEX=texlive-2016
  ## Testing with texlive 2015 -- perl 5.22
  - PERL=5.22.4 TEX=texlive-2015

jobs:
  # We allow failures for all the TeXLives excepts the 2016 ones
  allow_failures:
    - env: PERL=5.28.0 TEX=texlive-2018
    - env: PERL=5.22.4 TEX=texlive-2015
  # don't wait for the allow_failures to finish
  # just mark the results as done. 
  fast_finish: true

before_install:
# create a docker container to run the tests and name it 'sam'
  - docker pull latexml/latexml-test-runtime:${PERL}_$TEX
  - docker run -d --env "CI=true" --rm --name sam --entrypoint="" -v $(pwd):/root/latexml -t -i latexml/latexml-test-runtime:${PERL}_$TEX sleep infinity
# setup a convenience function 'sam' to run things inside the container
  - function sam() { eval docker exec -ti sam /bin/bash -c "\"source /usr/local/perlbrew/etc/bashrc; $@\"" ; }

install:
  - sam perl --version
  - sam cpanm --version
  - sam tex --version || true
  - sam cpanm -v --installdeps --notest .

before_script:
  - sam perl Makefile.PL
  - sam make

script:
  - sam make test

after_script:
  - docker stop sam