dist: trusty
language: node_js

branches:
  only:
    - webpack-4
    - master
    - next

cache:
  yarn: true
  directories:
    - ".jest-cache"
    - ".eslintcache"

stages:
  - basic
  - advanced

matrix:
  include:
    - os: linux
      node_js: "12"
      env: NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=basic
      stage: basic
    - os: linux
      node_js: "12"
      env: NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=lintunit
      stage: advanced
    - os: linux
      node_js: "12"
      env: NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
      stage: advanced
    - os: linux
      node_js: "12"
      env: NO_WATCH_TESTS=1 ALTERNATIVE_SORT=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
      stage: advanced
    - os: linux
      node_js: "10"
      env:
        - NODEJS_VERSION=v13.0.0-nightly201910156afed1dc85
        - YARN_EXTRA_ARGS="--ignore-engines"
        - NO_WATCH_TESTS=1
        - JEST="--maxWorkers=2 --cacheDirectory .jest-cache"
        - JOB_PART=integration
      stage: advanced
  fast_finish: true

before_install:
  - |
    if [ "$NODEJS_VERSION" != "" ];
    then
      mkdir /opt/node
      curl --silent "https://nodejs.org/download/nightly/$NODEJS_VERSION/node-$NODEJS_VERSION-linux-x64.tar.gz" | tar -zxf - --directory /opt/node
      export PATH="/opt/node/node-$NODEJS_VERSION-linux-x64/bin:$PATH"
      node --version
    fi

install:
  - yarn --frozen-lockfile $YARN_EXTRA_ARGS
  - yarn link --frozen-lockfile $YARN_EXTRA_ARGS || true
  - yarn link webpack --frozen-lockfile $YARN_EXTRA_ARGS

script: yarn travis:$JOB_PART

after_success:
  - cat ./coverage/lcov.info | node_modules/.bin/coveralls --verbose
  - bash <(curl -s https://codecov.io/bash) -F $JOB_PART -X gcov
  - rm -f .jest-cache/haste-map* .jest-cache/perf-cache*

notifications:
  slack:
    secure: JduSdKWwbnLCwo7Z4E59SGE+Uw832UwnXzQiKEpg1BV45MYDPRiGltly1tRHmPh9OGjvGx3XSkC2tNGOBLtL4UL2SCkf012x0t7jDutKRfcv/njynl8jk8l+UhPmaWiHXDQAgGiiKdL4RfzPLW3HeVHCOWm0LKMzcarTa8tw+rE=
