Avoid payload on restore_cache hit

We have the standard caching setup, but seems to us that the payload step always gets fully run despite having successfully been replaced by the restore_cache step. Whats going on? Do we need to somehow conditionally NOT trigger the payload step? How would we do that?

      - restore_cache:
          name: cache lookup
          key: codedeps-v01__{{ .Branch }}-{{ checksum "requirements.txt" }}
      - run:
          name: payload step
          command: |
            pip3 install -r requirements.txt;
      - save_cache:
          name: cache archive
          key: codedeps-v01__{{ .Branch }}-{{ checksum "requirements.txt" }}
            - ".venv"
Found a cache from build 123 at codedeps-v01__main-i3EhQuerKkzhtjTwNK7QenX5IVfE8uHskp+207efLCY=-
Size: 1011 MiB
Cached paths:
  * /home/circleci/project/.venv

Downloading cache archive...
Unarchiving cache...

NOTE: The example shows the familiar dependency caching for demo purposes. We are less interested in the python details & more interested in the circle-ci mechanics as our use-case is more general & caches other resources. Thanks.

1 Like