language: node_js
# When changing node version also update it on lines 31 and 49.
node_js:
  - "8"
  - "6"

sudo: false

cache:
  directories:
    - node_modules

addons:
  apt:
    sources:
      - sourceline: 'deb https://dl.yarnpkg.com/debian/ stable main'
        key_url: 'https://dl.yarnpkg.com/debian/pubkey.gpg'
    packages:
      - yarn

env:
  global:
    - GITHUB_OAUTH_KEY=003a44d58f12089d0c0261338298af3813330949
  matrix:
    - DB=sqlite3 NODE_ENV=testing
    - DB=mysql NODE_ENV=testing-mysql

matrix:
  include:
    - node_js: "8"
      env: TEST_SUITE=lint
  fast_finish: true

branches:
  except:
    - /^greenkeeper-.+$/

before_install:
  - if [ $DB == "mysql" ]; then mysql -e 'create database ghost_testing'; fi

install:
  - yarn
  - if [ "$DB" == "sqlite3" ]; then yarn add --force sqlite3; fi # fix sqlite caching issues

after_success:
  - |
      if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
        if [[ "$DB" = "sqlite3" && "$TRAVIS_NODE_VERSION" = "8" ]]; then
          echo "Generate coverage..."
          grunt coverage
          npm install -g codeclimate-test-reporter
          codeclimate-test-reporter < core/test/coverage/unit/lcov.info
        else
          echo "False DB and NODE_VERSION. No coverage generated."
        fi
      else
        echo "This is a PR. No coverage generated."
      fi
