Cache Miss Should Ideally Trigger on_fail steps

nodejs

#1

If I can restore my dependencies from cache, I may not want to even try reinstalling them. If I have a clear and unambiguous caching strategy (ie. restore from cache only if nothing has changed), then maybe I can skip my dependency steps entirely.

CircleCI 2.0 seems to provide semantics that would enable this: when: on_fail would allow me to say I only want to run certain steps if the previous restore_cache step has missed. But, a cache miss doesn’t seem to trigger on_fail???

For example, this doesn’t seem to work:

steps:
      - checkout
      - restore_cache:
        # restores unless package.json changes:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          when: on_fail
          # ideally, we only run this if we failed to reload the cache, above
          name: 'Install Dependencies'
          command: 'yarn install'

#2