# https://circleci.com/docs/2.0/language-javascript/

aliases:
  - &restore-cache
    keys:
      - v1-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
      - v1-dependencies-{{ .Branch }}-
      - v1-dependencies-

  - &save-cache
    paths:
      - node_modules
    key: v1-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}

version: 2
jobs:
  build-node-11:
    docker:
      - image: circleci/node:11
    working_directory: ~/repo
    steps:
      - checkout
      - restore-cache: *restore-cache
      - run: yarn install --frozen-lockfile
      - save-cache: *save-cache
      - run: yarn run lint
      - run: yarn run test-ci
      - run: yarn codecov
      - store_artifacts:
          path: test/coverage
          prefix: coverage

  build-node-10:
    docker:
      - image: circleci/node:10
    working_directory: ~/repo
    steps:
      - checkout
      - restore-cache: *restore-cache
      - run: yarn install --frozen-lockfile
      - save-cache: *save-cache
      - run: yarn run test-ci

workflows:
  version: 2
  build:
    jobs:
      - build-node-11
      - build-node-10
