language: node_js

services:
  - xvfb

dist: bionic

##### WARNING
# node-pre-gyp tests are not concurrency safe
# such that in the below travis builds we cannot
# have more than one run with the same node version
# otherwise they will clobber each other
#####

matrix:
  include:
    - os: linux
      node_js: 10
      env:
        - node_pre_gyp_mock_s3=true
      before_install:
        - npm install request
        - npm install --package-lock-only
      script:
        - npm run lint
        - npm run coverage
      after_script:
        - npm run upload-coverage
    - os: linux
      node_js: 12
      env:
        - node_pre_gyp_mock_s3=true
      script:
        - npm run coverage
      after_script:
        - npm run upload-coverage
    - os: linux
      node_js: 14
      env:
        - node_pre_gyp_mock_s3=true
    - os: linux
      node_js: 16
      env:
        - node_pre_gyp_mock_s3=true
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libavahi-compat-libdnssd-dev', 'libzmq3-dev']
    - os: linux
      node_js: 8
      env:
        - node_pre_gyp_mock_s3=true
    # Test node webkit
    - os: linux
      node_js: 10.23 # check concurrency warning message at the top
      addons:
        apt:
          sources: [ 'ubuntu-toolchain-r-test' ]
          packages: ['xvfb','libasound2','libx11-6','libglib2.0-0','libgtk2.0-0','libatk1.0-0','libgdk-pixbuf2.0-0','libcairo2','libfreetype6','libfontconfig1','libxcomposite1','libasound2','libxdamage1','libxext6','libxfixes3','libnss3','libnspr4','libgconf-2-4','libexpat1','libdbus-1-3','libudev1']
      script:
        # use python2.x since it breaks with python3.x which is the default installation 
        # https://github.com/nwjs/node/issues/46
        - ln -s /usr/bin/python2 ~/bin/python
        - ln -s /usr/bin/python2-config ~/bin/python-config
        - ./scripts/test-node-webkit.sh

install:
  - npm ci --engine-strict

script:
  - npm test
