dist: trusty
sudo: required
language: ruby

rvm:
  - 2.2.5

cache:
  bundler: true

addons:
  postgresql: '9.3'
  apt:
    sources:
      - elasticsearch-2.x
    packages:
    - elasticsearch

branches:
  except:
    - ontohub.org
    - staging.ontohub.org
    - develop.ontohub.org

services:
  - redis-server
  - elasticsearch

notifications:
  email: false
  webhooks:
    urls:
      - https://webhooks.gitter.im/e/1e9d1f1a0e20c6c7c6ba
    on_success: always  # options: [always|never|change] default: always
    on_failure: always  # options: [always|never|change] default: always
    on_start: true     # default: false

before_install:
  - 'export DISPLAY=:99.0'
  - 'sh -e /etc/init.d/xvfb start'
  - 'gem uninstall bundler bundle rubygems-update --all -x && gem update --system 2.6.1 && gem install bundler && gem uninstall rubygems-update --all -x && gem update --system 2.6.4'
  - 'gem --version'
  - 'bundle --version'

script:
  - SPEC_OPTS='--format documentation' CUCUMBER_OPTS='--format pretty' ELASTIC_TEST_PORT=9200 bundle exec rake

before_script:
  - psql -c 'create database ontohub_test;' -U postgres
  - sudo apt-add-repository -y ppa:hets/hets
  - sudo apt-add-repository -y 'deb http://archive.canonical.com/ubuntu precise partner'
  - sudo apt-add-repository -y 'deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse'
  - sudo apt-get update
  - sudo apt-get install libsane libgphoto2-2 hets-server subversion git-svn
  - sudo ln -s /usr/bin/hets-server /usr/bin/hets
  - sudo ln -s /usr/lib/hets/hets-server /usr/lib/hets/hets
  - mkdir -p tmp/{git,data/{git,git_daemon,commits}}
  - curl http://localhost:9200
  - RAILS_ENV=test bundle exec rake db:migrate || true
