version: 2

jobs:
  build-node-common: &build-node-common
    steps:
      - checkout

      - restore_cache:
          keys:
          - dependencies-{{ checksum "package-lock.json" }}
          # fallback to using the latest cache if no exact match is found
          - dependencies-

      - run:
          name: Install dependencies
          command: npm i

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

      - run:
          name: Test
          command: npm test

  build-node-6:
    <<: *build-node-common
    docker:
      - image: node:6

  build-node-7:
    <<: *build-node-common
    docker:
      - image: node:7

  build-node-8:
    <<: *build-node-common
    docker:
      - image: node:8

workflows:
  version: 2
  build_node_versions:
    jobs:
      - build-node-6
      - build-node-7
      - build-node-8

version: 2

jobs:
  build-node-common: &build-node-common
    docker:
      - image: node

    steps:
      - checkout

      - restore_cache:
          keys:
          - dependencies-{{ checksum "package-lock.json" }}
          # fallback to using the latest cache if no exact match is found
          - dependencies-

      - run:
          name: Install dependencies
          command: npm i

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

      - run:
          name: Test
          command: npm test

  build-node-6:
    <<: *build-node-common
    docker:
      - image: node:6

  build-node-7:
    <<: *build-node-common
    docker:
      - image: node:7

  build-node-8:
    <<: *build-node-common
    docker:
      - image: node:8

workflows:
  version: 2
  build_node_versions:
    jobs:
      - build-node-6
      - build-node-7
      - build-node-8

Add docker type to common job
Add docker type to common job
