version: 2
jobs:
  build:
    docker:
      - image: circleci/node:10-browsers
    steps:
      - checkout
      - run:
          name: Download dependencies
          command: npm ci
      - save_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
          paths:
            - node_modules
  test:
    docker:
      - image: circleci/node:10-browsers
    steps:
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
      - run:
          name: Run tests
          command: npm run test:ci -- --maxWorkers=2
      - run:
          name: Upload coverage report
          command: bash <(curl -s https://codecov.io/bash)
  deploy:
    docker:
      - image: meetfrank/circleci-node-awsebcli:latest
    steps:
      - checkout
      - run:
          name: Upgrade awsebcli
          command: |
            sudo pip install awsebcli --upgrade
      - deploy:
          name: Deploy master to Production
          command: eb deploy onboarding-client --label ${CIRCLE_SHA1} --timeout 20

workflows:
  version: 2
  build-test-and-deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      - deploy:
          requires:
            - test
          context: elastic-beanstalk-deployment
          filters:
            branches:
              only: master

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:10-browsers
    steps:
      - checkout
      - run:
          name: Download dependencies
          command: npm ci
      - save_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
          paths:
            - node_modules
  test:
    docker:
      - image: circleci/node:10-browsers
    steps:
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
      - run:
          name: Run tests
          command: npm run test:ci -- --maxWorkers=2
      - run:
          name: Upload coverage report
          command: bash <(curl -s https://codecov.io/bash)
  deploy:
    docker:
      - image: meetfrank/circleci-node-awsebcli:latest
    steps:
      - checkout
      - run:
          name: Upgrade awsebcli
          command: |
            sudo pip install awsebcli --upgrade
      - deploy:
          name: Deploy master to Production
          command: eb deploy onboarding-client --label ${CIRCLE_SHA1} --timeout 20

workflows:
  version: 2
  build-test-and-deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      # - deploy:
      #     requires:
      #       - test
      #     context: elastic-beanstalk-deployment
      #     filters:
      #       branches:
      #         only: master

Remove deployment to prevent site from being down while updating dependencies
Remove deployment to prevent site from being down while updating dependencies
