Add ability to skip entire job if cache key exists
percyhanna
I have several jobs that are prerequisites for other jobs. These jobs are used to set up baseline caches for the all of the following jobs, such as installing/updating dependencies. 99% of the time none of the dependencies have changed, so running the job is not necessary at all. However, there is overhead every time the job is run:"Spin up environment" can take 30-60s+ as the Docker image cache is not always consistent.Restoring a large cache can take 10s+That is 40-70s+ wasted when a simple presence check on the cache would allow the entire job to be skipped.SuggestionI suggest adding a skip_if_cache_exists or similar entry to the job configuration. Example:skip_if_cache_exists: source-v1-{{ .Branch }}-{{ .Revision }}This would allow the job to be skipped entirely, avoiding any unnecessary overhead of spinning up the container and restoring caches.
CCI-I-1467
Kurt von Laven
+1 to Kelly Setzer's when condition suggestion. That seems like a more flexible solution that will generalize to more needs. Concretely, this would simplify only checking the yarn cache if it has changed (https://yarnpkg.com/features/zero-installs#does-it-have-security-implications) or implementing CircleCI's own suggestion of splitting large caches into multiple smaller caches (https://circleci.com/docs/2.0/caching/#cache-size). I believe there is no 100% reliable workaround for detecting whether a cache exists that doesn't involve fully restoring it, and attempts to create one are extremely likely to result in rare race conditions.
K
Kelly Setzer
A when condition might be a clean implementation for this.version: 2.1jobs: do_stuff: steps: - restore_cache: keys: - v2-pods-{{ checksum "Podfile.lock" }} - when: condition: cache_miss steps: - run: echo "Do special cocoapods magic" - unless: condition: cache_hit steps: - run: echo "Party like it's 1999"
C
Christian Mühlbacher
Nr.: /bin/bashNr.: /bin/bashcircleci config pack src > orb.ymlcircleci orb publish orb.yml circleci/gcp-cli@dev:alpharm -rf orb.yml