version: 2
jobs:
  build:
    docker:
      - image: circleci/node:14
    working_directory: ~/repo

    steps:
      - checkout
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      # Need this for the artillery CLI to be able to load the plugin in integration
      # tests:
      - run: ln -s ~/repo ~/$CIRCLE_PROJECT_REPONAME

      - run: npm install

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