dist: trusty
language: node_js
node_js:
- 12

addons:
  apt:
    packages:
      - pulseaudio

env:
  global:
    - DISPLAY=:99.0

  matrix:
    - BROWSER=chrome  BVER=stable
    - BROWSER=chrome  BVER=stable CHROMEEXPERIMENT=false
    - BROWSER=chrome  BVER=stable PLANB=forever
    - BROWSER=chrome  BVER=stable CHROMEEXPERIMENT=false PLANB=forever
    - BROWSER=chrome  BVER=beta
    - BROWSER=chrome  BVER=beta CHROMEEXPERIMENT=false
    - BROWSER=chrome  BVER=beta CHROMEEXPERIMENT=false PLANB=forever
    - BROWSER=chrome  BVER=unstable
    - BROWSER=firefox BVER=stable
    - BROWSER=firefox BVER=beta
    - BROWSER=firefox BVER=nightly
    - BROWSER=firefox BVER=esr
    - BROWSER=Electron

matrix:
  fast_finish: true

before_script:
  - export CHROME_BIN=browsers/bin/chrome-${BVER}
  - export FIREFOX_BIN=browsers/bin/firefox-${BVER}
  - sh -e /etc/init.d/xvfb start
  - pulseaudio --start
  - if [ "$BROWSER" = "Electron" ]; then npm i karma-electron electron@3 karma-stability-reporter; fi

script:
  - node_modules/.bin/grunt
  - npm test || npm test

after_failure:
  - for file in *.log; do echo $file; echo "======================"; cat $file; done || true
