sudo: required
language: php

matrix:
  include:
  - php: '7.2'
    env: SWOOLE_VERSION="v4.5.1"
  - php: '7.3'
    env: SWOOLE_VERSION="v4.5.1"
  - php: '7.4'
    env: SWOOLE_VERSION="v4.5.1"
  - php: '7.2'
    env: SWOOLE_VERSION="v4.4.18"
  - php: '7.3'
    env: SWOOLE_VERSION="v4.4.18"
  - php: '7.4'
    env: SWOOLE_VERSION="v4.4.18"
  - php: '7.2'
    env: SWOOLE_VERSION="master"
  - php: '7.3'
    env: SWOOLE_VERSION="master"
  - php: '7.4'
    env: SWOOLE_VERSION="master"
  - php: 'nightly'
    env: SWOOLE_VERSION="master" DISABLE_XDEBUG=false INSTALL_REDIS_EXT=true
  allow_failures:
  - env: SWOOLE_VERSION="master"
  - php: nightly

services:
  - redis-server

addons:
  apt:
    packages:
    - unzip

install:
  - if [[ $INSTALL_REDIS_EXT == true ]]; then
      wget https://github.com/phpredis/phpredis/archive/develop.zip;
      unzip develop.zip;
      cd phpredis-develop;
      phpize;
      ./configure;
      make && make install;
      cd ../;
    fi
  - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
  - wget https://github.com/swoole/swoole-src/archive/$SWOOLE_VERSION.tar.gz -O swoole.tar.gz && mkdir -p swoole && tar -xf swoole.tar.gz -C swoole --strip-components=1 && rm swoole.tar.gz && cd swoole && phpize && ./configure --enable-openssl --enable-http2 && make -j && make install && cd -
  - echo "extension = swoole.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

before_script:
  - if [[ $DISABLE_XDEBUG != false ]]; then
      phpenv config-rm xdebug.ini;
    fi
  - curl -sSfL -o ~/.phpenv/versions/$(phpenv version-name)/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
  - export TEST_PHPUNIT_PATH=~/.phpenv/versions/$(phpenv version-name)/bin/phpunit
  - php ./.travis/composer-no-phpunit.php
  - composer update
  - php --ri swoole

script:
  - ./tests/run

after_failure:
  - php ./.travis/output-server-log.php