language: php
sudo: false
git:
  depth: 1
env:
  global:
  - DEFAULT_COMPOSER_FLAGS="--no-interaction --no-progress --optimize-autoloader"
  - REPORT_TESTS_COVERAGE=0
  - SWAGGER_VERSION=2.0
matrix:
  fast_finish: true
  include:
  - php: 7.1
    env: CACHE_NAME=SWAGGER
  - php: 7.1
    env: SWAGGER_VERSION=3.0 CACHE_NAME=OPEN_API
  - php: 7.2
    env: CACHE_NAME=SWAGGER
  - php: 7.2
    env: SWAGGER_VERSION=3.0 CACHE_NAME=OPEN_API REPORT_TESTS_COVERAGE=1
cache:
  directories:
  - "$HOME/.composer/cache"
install:
  - travis_retry composer update $DEFAULT_COMPOSER_FLAGS
  - if [ $SWAGGER_VERSION == 2.0 ]; then composer require 'zircote/swagger-php:2.*'; fi
  - if [ $SWAGGER_VERSION == 3.0 ]; then composer require 'zircote/swagger-php:3.*'; fi
  - composer info -D | sort
before_script:
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
  - chmod +x ./cc-test-reporter
  - ./cc-test-reporter before-build
script:
  - chown -R travis:travis /home/travis/build/DarkaOnLine/L5-Swagger
  - mkdir -p tests/storage/logs/test-reports
  - chmod -R 777 /home/travis/build/DarkaOnLine/L5-Swagger
  - if [ $REPORT_TESTS_COVERAGE != 1 ]; then vendor/bin/phpunit --no-coverage; fi
  - if [ $REPORT_TESTS_COVERAGE == 1 ]; then vendor/bin/phpunit; cp tests/storage/logs/test-reports/clover.xml clover.xml; fi
after_success:
  - if [ $REPORT_TESTS_COVERAGE == 1 ] && [ $TRAVIS_PULL_REQUEST == "false" ]; then ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT; fi
  - if [ $REPORT_TESTS_COVERAGE == 1 ]; then php vendor/bin/php-coveralls -v; fi
notifications:
  email: false
  slack:
    secure: ZymO41QYmcBtaqIcjKagifif5bH+vpUdZe9eN2Q27G2HF7ID0ZP2X6sCCUCVqdJfM3DhmEsNo8h/HiY86u/5zhf5YpZr7vt+CuYinIJ+nydGXWO5CU6nSotmafFgo3u+Yyjz6qIBhnOVZL8prYcbZsn0SIRvvTwT0qOCBGWIEohdxnu6DpC1BRKQ2RNgsGnO88N5+8FYGor1M4+UT38d/JMrgx8MGkW305ioCmW888NmVuNMheEh19wyFqp9FCQED2DsLxU3pi7A5w4knA5eIy89ULPOrNFUMq5LIBA5OdERrnNS6Yk5/kMmepH2A0tj9pFqBzxdFtThQtYYZ1UnxrotfE+YvU587FW3iXowpHAsaGeoLA3XkakCuZ6jpZhKwOWvslBcBt/6Irs0MPmj5EyaIOb8kAACij8nIfWQkQu/2Ik/AZ0L4lw36RRYNMdel8fMZAwcmK1bfh51dJqhTsf2e4iLa9xHCx7/Mib8EriDwRdYeO0GWSRk4cwTyIY2JjpkidgbDy2BHpiFxp9v/mNf6nJYYVG1Arnv/tK0t3WeILkOHy7tkWtGwFrjiRVQ7B2Hq+iBgda0reZSncK56GhmrMiHwO95QPe6hh3oz3lwcl7MoKGCyLASTeXTKNGhR5fds/6fG25bov8DDOaWXbQyeidJwO4UvLY6ksS3onc=
