dist: xenial

language: php

stages:
  - name: "Lint"
  - name: "PHP Unit tests"

cache:
  directories:
    - $HOME/.composer/cache/

install:
  - composer install --no-interaction

script:
  - ./vendor/bin/phpunit --coverage-clover clover.xml

after_success:
  - wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.2.0/php-coveralls.phar
  - chmod +x php-coveralls.phar
  - php php-coveralls.phar --verbose --coverage_clover clover.xml --json_path coveralls-upload.json

jobs:
  allow_failures:
    - php: nightly

  include:
    - stage: "Lint"
      name: "Lint files"
      before_install: phpenv config-rm xdebug.ini
      after_success: skip
      script: ./vendor/bin/phpcs

    - stage: "PHP Unit tests"
      php: 7.1
      name: "PHP 7.1"
    - stage: "PHP Unit tests"
      php: 7.2
      name: "PHP 7.2"
    - stage: "PHP Unit tests"
      php: 7.3
      name: "PHP 7.3"
    - stage: "PHP Unit tests"
      php: 7.4
      name: "PHP 7.4"
    - stage: "PHP Unit tests"
      php: nightly
      name: "PHP nightly"
      install:
        - composer install --no-interaction --ignore-platform-reqs

notifications:
  email: true
