version: 2
jobs:
  build:
    docker:
      - image: circleci/node:8.12

    steps:
      - checkout

      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          - v1-dependencies-

      - run: npm install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: npm run lint
      - run: npm run test

      ## Process test artifacts (reports, coverage etc)
      - store_artifacts:
          path: mochawesome-report
      - run: (cat ./coverage/lcov.info | npx coveralls) || true
      - store_artifacts:
          path: coverage
