version: 2
jobs:
  build:

    docker:
      - image: circleci/openjdk:8-jdk-node-browsers

    environment:
      TZ: /usr/share/zoneinfo/America/Los_Angeles
      TRAVIS_REPO_SLUG: facebook/react

    parallelism: 4

    steps:
      - checkout

      - run: echo $CIRCLE_COMPARE_URL | cut -d/ -f7

      - restore_cache:
          name: Restore node_modules cache
          keys:
            - v1-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
            - v1-node-{{ arch }}-{{ .Branch }}-
            - v1-node-{{ arch }}-

      - run:
          name: Nodejs Version
          command: node --version

      - run:
          name: Install Packages
          command: yarn install --frozen-lockfile

      - run:
          name: Test Packages
          command: ./scripts/circleci/test_entry_point.sh

      - save_cache:
          name: Save node_modules cache
          key: v1-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
          paths:
            - node_modules

      - store_artifacts:
          path: ./node_modules.tgz

      - store_artifacts:
          path: ./scripts/error-codes/codes.json