version: 2
jobs:
  build:
    docker:
      - image: circleci/node
    steps:
      # Checkout repository
      - checkout

      # Restore cache
      - restore_cache:
          key: yarn-cache-{{ checksum "yarn.lock" }}

      # Install dependencies
      - run:
          name: Install Dependencies
          command: NODE_ENV=dev yarn

      # Keep cache
      - save_cache:
          key: yarn-cache-{{ checksum "yarn.lock" }}
          paths:
            - "node_modules"

      # Lint
      - run:
          name: Lint
          command: yarn lint

      # Tests
      - run:
          name: Tests
          command: yarn jest

      # Coverage
      - run:
          name: Coverage
          command: yarn codecov
      
      # Build
      - run:
          name: Build
          command: yarn build
