version: 2.0
jobs:
  build:
    docker:
      - image: circleci/node:10.16-browsers
    steps:
      - checkout

      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          - v1-dependencies-

      - run: npm install

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

      - run: npm run build:umd

      - run:
          name: Compatibility Test
          command: |
            if [ -z "$CIRCLE_PR_NUMBER" ];
            then
              npm run test:compat
            fi
      - run: npm run test

      - store_test_results:
          path: /tmp/test-results
