version: 2
aliases:
  # Variables
  - &yarn_install_cache_key v2-yarn-install-{{ checksum "yarn.lock" }}

jobs:

  yarn_test:
    docker:
       - image: node:9
    steps:
      - checkout
      - restore_cache:
          keys:
            - *yarn_install_cache_key
      - run:
          name: "yarn install"
          command: yarn install --frozen-lockfile
      - save_cache:
          key: *yarn_install_cache_key
          paths:
               ./node_modules
      - run:
          name: "yarn test"
          command: yarn test

workflows:
  version: 2
  test:
    jobs:
      - yarn_test:
          filters:
            tags:
              only: /^v[0-9]+\.[0-9]+\.[0-9]+/
