language: php

sudo: false

env:
  - XDEBUG_MODE=coverage

branches:
  only:
    - main

php:
  - 5.6
  - 7.0
  - 7.1
  - 7.2
  - 7.3
  - 7.4
  - nightly

matrix:
  allow_failures:
    - php: nightly
  include:
    - os: linux
      dist: trusty
      language: php
      php: 5.4

addons:
  apt:
    packages:
    - devscripts
    - fakeroot
    - debhelper
    - pkg-config
    - alien
    - rpm
    - dh-make
    - imagemagick

before_install:
  - composer self-update
  - if [ -n "$GH_TOKEN" ]; then git config --global github.token ${GH_TOKEN} && composer config github-oauth.github.com ${GH_TOKEN}; fi;
  - if [ -n "$GH_USER" ]; then git config --global github.user ${GH_USER}; fi;
  - if [[ "$TRAVIS_PHP_VERSION" != "nightly" ]] && [[ "$TRAVIS_PHP_VERSION" != "5.3" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm-3.18" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]] && [[ "$TRAVIS_PHP_VERSION" != "7.2" ]]; then printf "\n" | pecl install imagick-beta -v; fi;

before_script:
  - composer install --no-interaction
  - if [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then composer require php-coveralls/php-coveralls --no-interaction; fi

script:
  - make qa rpm deb

after_failure:
  - cat ./target/logs/junit.xml
  - cat ./target/report/phpcpd.txt

after_success:
  - cat ./target/report/phploc.txt
  - cat ./target/report/phpcompatinfo.txt
  - "echo 'coverage_clover: target/coverage/coverage.xml' >> .coveralls.yml"
  - "echo 'json_path: target/coverage/coveralls-upload.json' >> .coveralls.yml"
  - if [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then php vendor/php-coveralls/php-coveralls/bin/php-coveralls -v; fi;
