language: php

dist: trusty
sudo: false

stages:
  - Code Format and Static Analysis
  - test
  - Test CommonMark (weak)

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

matrix:    
  fast_finish: true
  allow_failures:
    - php: nightly
    - php: 7.3
    - env: ALLOW_FAILURE

install:
  # remove packages with PHP requirements higher than 7.0 to prevent composer trying to resolve these, see: https://github.com/composer/composer/issues/6011
  - composer remove vimeo/psalm friendsofphp/php-cs-fixer --dev --no-update --no-interaction
  - composer install --prefer-dist --no-interaction --no-progress

script: composer test-units

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

jobs:
  include:
    - stage: Code Format and Static Analysis
      php: 7.2
      install: composer install --prefer-dist --no-interaction --no-progress
      script:
        - '[ -z "$TRAVIS_TAG" ] || [ "$TRAVIS_TAG" == "$(php -r "require(\"vendor/autoload.php\"); echo Erusev\Parsedown\Parsedown::version;")" ]'
        - composer test-static
        - composer test-formatting

    - stage: Test CommonMark (weak)
      php: 7.2
      env: ALLOW_FAILURE
      install: composer install --prefer-dist --no-interaction --no-progress
      script:
        - composer test-commonmark-weak