language: php
php:
  - 7.2

addons:
  apt:
    packages:
    - libxml2-utils

env:
  global:
    - CORE_BRANCH=master
    - APP_NAME=notes
  matrix:
    - DB=mysql

branches:
  only:
    - master
    - /^stable\d*$/

before_install:
  #- export DISPLAY=:99.0
  #- export CHROME_BIN=chromium-browser
  #- sh -e /etc/init.d/xvfb start
  #- sudo apt-get update
  #- sudo apt-get install firefox
  - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
  - . ./before_install.sh $APP_NAME $CORE_BRANCH $DB
  - cd ../server/
  - php occ app:enable notes
  - cd apps/$APP_NAME

script:
  # Check info.xml schema validity
  - wget https://apps.nextcloud.com/schema/apps/info.xsd
  - xmllint appinfo/info.xml --schema info.xsd --noout
  - rm info.xsd
  # Check PHP syntax errors
  - find . -name \*.php -exec php -l "{}" \;
  # Check app validity
  - php ../../occ app:check-code notes
  # Run PHP unit tests (skipped due to errors)
  # - phpunit --coverage-clover clover.xml -c phpunit.xml
  # - phpunit -c phpunit.integration.xml

  # execute js tests
  - cd js
  - npm install
  - npm install -g gulp
  #- gulp test
  - gulp

  # Create coverage report
  - sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' ]; then wget https://scrutinizer-ci.com/ocular.phar; fi"
  - sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' ]; then php ocular.phar code-coverage:upload --format=php-clover clover.xml; fi"

#matrix:
#  include:
#    - php: 7.1
#      env: DB=mysql
#    - php: 7.0
#      env: "DB=mysql CORE_BRANCH=stable9.1"
#    - php: 5.6
#      env: "DB=sqlite CORE_BRANCH=stable9"
#  fast_finish: true

