language: php
sudo: required
dist: trusty

jobs:
  include:
    - php: '5.5.38'
    - php: '5.6.25'
    - php: '5.6.25'
      env: PROTOBUF_C_EXT=true
    - php: '7.0'
    - php: '7.1'
    - php: '7.2'
    - php: '7.2'
      env: PROTOBUF_C_EXT=true
    - php: '7.3'
    - php: '7.3'
      env: PROTOBUF_C_EXT=true
    - php: '7.2'
      install:
      - travis_retry pecl install protobuf-3.6.1
      script:
      - ./dev/sh/test-composer-conflict.sh
    - stage: 'deploy'
      php: '7.2'
      install:
      - travis_retry composer install
      script:
      - ./dev/sh/build-docs.sh
      - ./dev/sh/push-docs.sh
      after_success: skip

stages:
  - test
  - name: deploy
    if: ((type != pull_request) AND (branch = master)) OR (tag IS present)

install:
  - travis_retry pecl install grpc
  - if [[ $PROTOBUF_C_EXT =~ ^true ]]; then travis_retry pecl install protobuf-3.7.1; fi
  - travis_retry composer install
script:
  - vendor/bin/phpunit --coverage-clover=coverage.xml
  - vendor/bin/phpcs -s --standard=./ruleset.xml
  - if [[ $TRAVIS_PHP_VERSION =~ ^7 ]]; then ./dev/sh/build-docs.sh; fi
after_success:
  - bash <(curl -s https://codecov.io/bash)
