version: 2
jobs:
  build-common: &common-build
    docker:
      - image: node
    working_directory: ~/sinon
    steps:
      - run:
          name: Versions
          command: |
            npm version
      - checkout
      - restore_cache:
          keys:
            - v1-npm-{{ .Branch }}-{{ checksum "package.json" }}
            - v1-npm-master-{{ checksum "package.json" }}
      - run:
          name: Install dependencies
          command: |
              npm config set strict-ssl false
              NODE_VERSION=$(node --version)
              if [[ ${NODE_VERSION:0:3} != "v6." ]]; then
                # Avoid downloading chromium unnecessarily
                npm config set ignore-scripts true
              fi
              npm install
              npm config set ignore-scripts false
      - run:
          name: Pre-Test
          # ESLint only supports Node >=4 and Mochify requires Node >= 6
          command: |
              NODE_VERSION=$(node --version)
              if [[ ${NODE_VERSION:0:3} == "v6." ]]; then
                npm run lint;
                npm run test-headless;
                npm run test-webworker;
              fi
      - run:
          name: Test
          command: npm run test-node
      - save_cache:
          key: v1-npm-{{ .Branch }}-{{ checksum "package.json" }}
          paths:
            - node_modules

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

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

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

workflows:
  version: 2
  build:
    jobs:
      - node-4
      - node-6
      - node-8

version: 2
jobs:
  build-common: &common-build
    docker:
      - image: node
    working_directory: ~/sinon
    steps:
      - run:
          name: Versions
          command: |
            npm version
      - checkout
      - restore_cache:
          keys:
            - v1-npm-{{ .Branch }}-{{ checksum "package.json" }}
            - v1-npm-master-{{ checksum "package.json" }}
      - run:
          name: Install dependencies
          command: |
              npm config set strict-ssl false
              # Avoid downloading chromium unnecessarily
              npm config set ignore-scripts true
              npm install
              npm config set ignore-scripts false
      - run:
          name: Pre-Test
          # ESLint only supports Node >=4
          command: |
              NODE_VERSION=$(node --version)
              if [[ ${NODE_VERSION:0:3} == "v6." ]]; then
                npm run lint;
              fi
      - run:
          name: Test
          command: npm run test-node
      - save_cache:
          key: v1-npm-{{ .Branch }}-{{ checksum "package.json" }}
          paths:
            - node_modules

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

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

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

workflows:
  version: 2
  build:
    jobs:
      - node-4
      - node-6
      - node-8

Remove headless test runs from CircleCI
Remove headless test runs from CircleCI
