@@ -23,16 +23,18 @@ version: 2.1
2323# (See https://support.circleci.com/hc/en-us/articles/360012618473-Creating-a-daily-cache.)
2424# **NOTE 2 **: If you change the cache key prefix, also sync the cache_key_fallback to match.
2525# **NOTE 3 **: Keep the static part of the cache key as prefix to enable correct fallbacks.
26+ # **NOTE 4 **: To make sure modified patches can be applied without needing to manually update the cache key,
27+ # the fallback cache key will not match if patches have been modified.
2628# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
27- var_3 : &cache_key v8-angular-node-16-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "aio/yarn.lock" }}
29+ var_3 : &cache_key v8-angular-node-16-{{ checksum "month.txt" }}-{{ checksum "patches.hash"}}-{{ checksum " .bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "aio/yarn.lock" }}
2830# We invalidate the cache if the Bazel version changes because otherwise the `bazelisk` cache
2931# folder will contain all previously used versions and ultimately cause the cache restoring to
3032# be slower due to its growing size.
31- var_4 : &cache_key_fallback v8-angular-node-16-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}
33+ var_4 : &cache_key_fallback v8-angular-node-16-{{ checksum "month.txt" }}-{{ checksum "patches.hash"}}-{{ checksum " .bazelversion" }}
3234
3335# Windows needs its own cache key because binaries in node_modules are different.
34- var_3_win : &cache_key_win v10-angular-win-node-16-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}
35- var_4_win : &cache_key_win_fallback v10-angular-win-node-16-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}
36+ var_3_win : &cache_key_win v10-angular-win-node-16-{{ checksum "month.txt" }}-{{ checksum "patches.hash"}}-{{ checksum " .bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}
37+ var_4_win : &cache_key_win_fallback v10-angular-win-node-16-{{ checksum "month.txt" }}-{{ checksum "patches.hash"}}-{{ checksum " .bazelversion" }}
3638
3739# Workspace initially persisted by the `setup` job, and then enhanced by `build-npm-packages`.
3840# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
@@ -182,6 +184,12 @@ commands:
182184 # snapshot stamping would have the `-with-local-changes` suffix.
183185 command : date +%Y-%m > month.txt
184186
187+ capture_patches_for_cache_key :
188+ description : Hashes all patches so that the cache can be reset upon changes.
189+ steps :
190+ - run : |
191+ md5sum tools/esm-interop/patches/npm/* > patches.hash
192+
185193 yarn_install :
186194 description : Install dependencies
187195 steps :
@@ -214,6 +222,7 @@ jobs:
214222 steps :
215223 - checkout
216224 - save_month_to_file
225+ - capture_patches_for_cache_key
217226 - init_environment
218227 - devinfra/rebase-pr-on-target-branch :
219228 base_revision : << pipeline.git.base_revision >>
@@ -590,6 +599,7 @@ jobs:
590599 steps :
591600 - checkout
592601 - save_month_to_file
602+ - capture_patches_for_cache_key
593603 - init_environment
594604
595605 # Setup the proper NodeJS version. The image comes pre-installed with `nvm-windows`.
0 commit comments