From 26dfa3266bcda58148e1e78d7b519968a048ad27 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Sun, 1 Apr 2018 02:11:06 +0530 Subject: [PATCH] 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. --- .circleci/config.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b36218b21e..16c079605f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,10 +22,10 @@ jobs: - restore_cache: keys: - - v1-npm-base.trusty.1 + - v1-npm-base.trusty-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }} - restore_cache: keys: - - v1-venv-base.trusty.1 + - v1-venv-base.trusty-{{ checksum "requirements/thumbor.txt" }}-{{ checksum "requirements/dev.txt" }} - run: name: install dependencies @@ -51,11 +51,11 @@ jobs: - save_cache: paths: - /srv/zulip-npm-cache - key: v1-npm-base.trusty.1 + key: v1-npm-base.trusty-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }} - save_cache: paths: - /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 # The moment of truth! Run the tests. @@ -103,10 +103,10 @@ jobs: - restore_cache: keys: - - v1-npm-base.xenial.1 + - v1-npm-base.xenial-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }} - restore_cache: keys: - - v1-venv-base.xenial.1 + - v1-venv-base.xenial-{{ checksum "requirements/thumbor.txt" }}-{{ checksum "requirements/dev.txt" }} - run: name: install dependencies @@ -118,11 +118,11 @@ jobs: - save_cache: paths: - /srv/zulip-npm-cache - key: v1-npm-base.xenial.1 + key: v1-npm-base.xenial-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }} - save_cache: paths: - /srv/zulip-venv-cache - key: v1-venv-base.xenial.1 + key: v1-venv-base.xenial-{{ checksum "requirements/thumbor.txt" }}-{{ checksum "requirements/dev.txt" }} - run: name: run backend tests