language: node_js
node_js:
  - "9"

matrix:
  include:
    - os: linux
      dist: trusty
      sudo: required
      env: 
        - QUALITY=yes
        - PROXY_VALIDATION=yes
    - os: linux
      dist: precise
      sudo: required
    - os: osx
      osx_image: xcode7.2
  allow_failures:
    - os: osx
    
branches:
  only: master
  
notifications:
    webhooks: https://www.travisbuddy.com/?insertMode=update

before_script:
    - if [[ $PROXY_VALIDATION == "yes" ]]; then mkdir -vp /home/travis/.ssh/; fi
    - if [[ $PROXY_VALIDATION == "yes" ]]; then ssh-keygen -f /home/travis/.ssh/id_ecdsa -t ecdsa -N ''; fi
    - if [[ $PROXY_VALIDATION == "yes" ]]; then cat /home/travis/.ssh/*.pub > /home/travis/.ssh/authorized_keys; fi
    - if [[ $PROXY_VALIDATION == "yes" ]]; then chmod 600 /home/travis/.ssh/*; fi
    - if [[ $PROXY_VALIDATION == "yes" ]]; then chmod 700 /home/travis/.ssh/.; fi
    - if [[ $PROXY_VALIDATION == "yes" ]]; then ssh -f -o "StrictHostKeyChecking no" -D 9999 -q -N travis@localhost; fi
    - travis_retry git clone -b gh-pages https://git@$GH_REPO_REF docs
    - travis_retry npm install
    - travis_retry npm install coveralls istanbul mocha chai codecov codacy-coverage mocha-lcov-reporter eslint jsdoc
    - travis_retry npm install -g coveralls istanbul mocha chai codecov codacy-coverage mocha-lcov-reporter eslint jsdoc
    - travis_retry sudo apt-get install tinyproxy curl
    - if [[ $PROXY_VALIDATION == "yes" ]]; then tinyproxy; fi
    - if [[ $PROXY_VALIDATION == "yes" ]]; then travis_retry curl -v -I --proxy socks://127.0.0.1:9999 https://www.google.com; fi  

script:
    - travis_retry npm run test
    - if [[ $PROXY_VALIDATION == "yes" ]]; then export socks_proxy=socks4://127.0.0.1:9999; fi
    - if [[ $PROXY_VALIDATION == "yes" ]]; then travis_retry npm run test; fi
    - npm run lint  

after_success:
    - if [[ $QUALITY == "yes" ]]; then travis_retry npm run cover; fi
    - if [[ $QUALITY == "yes" ]]; then travis_retry npm run coveralls; fi
    - if [[ $QUALITY == "yes" ]]; then travis_retry npm run codecov; fi
    - if [[ $QUALITY == "yes" ]]; then travis_retry npm run codacy; fi
    - if [[ $QUALITY == "yes" ]]; then mv docs/docs.sh .; cd docs; rm -rvf ./*; mv ../docs.sh .; chmod +x docs.sh; ./docs.sh; fi    
    
env:
  global:
    - GH_REPO_NAME: node-binance-api
    - GH_REPO_REF: github.com/jaggedsoft/node-binance-api.git
    - JSDOC_FILES: $TRAVIS_BUILD_DIR/node-binance-api.js
