language: php

sudo: false

cache:
    directories:
        - $HOME/im

# dist: bionic
# dist: trusty

php:
    - nightly
    - 7.4
    - 7.3
    - 7.2
    - 7.1
    - 7.0
    - 5.6
# These don't work on travis currently, and although I don't particularly
# want to drop support for them, I can't justify spending any more time on
# getting the travis build to work for them.
#    - 5.5
#    - 5.4

env:
  - IMAGEMAGICK_VERSION=git7
  - IMAGEMAGICK_VERSION=git6
  - IMAGEMAGICK_VERSION=7.0.10-27
  - IMAGEMAGICK_VERSION=7.0.8-4
  - IMAGEMAGICK_VERSION=7.0.1-0
  - IMAGEMAGICK_VERSION=6.9.2-0
  - IMAGEMAGICK_VERSION=6.8.7-0
  - IMAGEMAGICK_VERSION=6.7.8-0

# Include individual commits like this:
  # - IMAGEMAGICK_VERSION=commit_25553302a6d5f736b55e60109600dfbce5fbea48


matrix:
  allow_failures:
    - env: IMAGEMAGICK_VERSION=git6
    - env: IMAGEMAGICK_VERSION=git7
  exclude:
    - php: 5.4
      env: IMAGEMAGICK_VERSION=6.8.7-0



before_install:
    - sudo apt-get update
    - sudo apt-get install -y fonts-urw-base35 || true
    # - sudo apt-get install -y fonts-freefont-ttf || true
    - sudo apt-get install -y libfreetype6-dev || true
    - sudo apt-get install -y texlive-fonts-recommended || true

before_script:
    - for file in tests/*.phpt; do grep $(basename $file) package.xml >/dev/null || (echo "Missing $file from package.xml" ; exit 1); done
    - bash ./imagemagick_dependency.sh "${IMAGEMAGICK_VERSION}"

script:
    - export NO_INTERACTION=1
    - export REPORT_EXIT_STATUS=1
    - export SKIP_SLOW_TESTS=1
    - export TEST_PHP_EXECUTABLE=`which php`
    - export PHP_IMAGICK_VERSION=$(php -r '$sxe = simplexml_load_file ("package.xml"); echo (string) $sxe->version->release;')
    - export CFLAGS=$(php util/calculate_cflags.php $TRAVIS_PHP_VERSION $IMAGEMAGICK_VERSION)
    - echo "CFLAGS are ${CFLAGS}"
    # - . ./configure-cflags.sh
    - phpize
    - ./configure --with-imagick="${HOME}/im/imagemagick-${IMAGEMAGICK_VERSION}"
    - make install
    - php -d extension=imagick.so util/check_fonts.php
    - php run-tests.php -d extension=imagick.so -d extension_dir=modules -n ./*.phpt
    - php run-tests.php -d extension=imagick.so -d extension_dir=modules -n ./tests/*.phpt
    - for i in `ls tests/*.diff 2>/dev/null`; do echo "-- START ${i}"; cat $i; echo "-- END"; done
    - php ./util/check_version.php


