language: node_js

node_js:
  - "4"
  - "6"

env:
  - CXX=g++-4.8

addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-4.8
  postgresql: "9.4"

sudo: false

services:
  - postgresql

before_install: if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi

before_script:
  - npm run build
  - wget --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-3.0.2-64bit-static.tar.xz"
  - tar xf ffmpeg-release-3.0.2-64bit-static.tar.xz
  - mkdir -p $HOME/bin
  - cp ffmpeg-*-64bit-static/{ffmpeg,ffprobe,ffserver} $HOME/bin
  - export PATH=$HOME/bin:$PATH
  - export NODE_TEST_IMAGE=true
  - psql -c 'create database peertube_test1;' -U postgres
  - psql -c 'create database peertube_test2;' -U postgres
  - psql -c 'create database peertube_test3;' -U postgres
  - psql -c 'create database peertube_test4;' -U postgres
  - psql -c 'create database peertube_test5;' -U postgres
  - psql -c 'create database peertube_test6;' -U postgres
  - psql -c "create user peertube with password 'peertube';" -U postgres

after_failure:
  - cat test1/logs/all-logs.log
  - cat test2/logs/all-logs.log
  - cat test3/logs/all-logs.log
  - cat test4/logs/all-logs.log
  - cat test5/logs/all-logs.log
  - cat test6/logs/all-logs.log