ci: Make cache keys depend on checksums of dependency manifests

Caches in Circle are immutable -- even if a path in a cache changes in builds
after the cache was created, the cache is not updated if it already exists. This
was making the zulip-venv-cache and zulip-npm-cache directories useless on
Circle.

This commit changes the cache keys to depend on the checksums of the dependency
manifests (requirements/{dev,thumbor}.txt, package.json and yarn.lock). This
would ensure that the caches are updated when the environments change. It may
result in the occasional build being "uncached" -- when a dependency manifest
changes -- but builds without such changes will be much faster, and such builds
are a majority.
This commit is contained in:
Puneeth Chaganti 2018-04-01 02:11:06 +05:30 committed by Tim Abbott
parent da4ac38e37
commit 26dfa3266b
1 changed files with 8 additions and 8 deletions

View File

@ -22,10 +22,10 @@ jobs:
- restore_cache: - restore_cache:
keys: keys:
- v1-npm-base.trusty.1 - v1-npm-base.trusty-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- restore_cache: - restore_cache:
keys: keys:
- v1-venv-base.trusty.1 - v1-venv-base.trusty-{{ checksum "requirements/thumbor.txt" }}-{{ checksum "requirements/dev.txt" }}
- run: - run:
name: install dependencies name: install dependencies
@ -51,11 +51,11 @@ jobs:
- save_cache: - save_cache:
paths: paths:
- /srv/zulip-npm-cache - /srv/zulip-npm-cache
key: v1-npm-base.trusty.1 key: v1-npm-base.trusty-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- save_cache: - save_cache:
paths: paths:
- /srv/zulip-venv-cache - /srv/zulip-venv-cache
key: v1-venv-base.trusty.1 key: v1-venv-base.trusty-{{ checksum "requirements/thumbor.txt" }}-{{ checksum "requirements/dev.txt" }}
# TODO: in Travis we also cache ~/zulip-emoji-cache, ~/node, ~/misc # TODO: in Travis we also cache ~/zulip-emoji-cache, ~/node, ~/misc
# The moment of truth! Run the tests. # The moment of truth! Run the tests.
@ -103,10 +103,10 @@ jobs:
- restore_cache: - restore_cache:
keys: keys:
- v1-npm-base.xenial.1 - v1-npm-base.xenial-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- restore_cache: - restore_cache:
keys: keys:
- v1-venv-base.xenial.1 - v1-venv-base.xenial-{{ checksum "requirements/thumbor.txt" }}-{{ checksum "requirements/dev.txt" }}
- run: - run:
name: install dependencies name: install dependencies
@ -118,11 +118,11 @@ jobs:
- save_cache: - save_cache:
paths: paths:
- /srv/zulip-npm-cache - /srv/zulip-npm-cache
key: v1-npm-base.xenial.1 key: v1-npm-base.xenial-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- save_cache: - save_cache:
paths: paths:
- /srv/zulip-venv-cache - /srv/zulip-venv-cache
key: v1-venv-base.xenial.1 key: v1-venv-base.xenial-{{ checksum "requirements/thumbor.txt" }}-{{ checksum "requirements/dev.txt" }}
- run: - run:
name: run backend tests name: run backend tests