@@ -95,12 +95,15 @@ commands:
9595 # 2. A Linux cache built on a matching branch name with any `Cargo.lock` checksum
9696 # 3. Any Linux cache
9797 #
98+ # We only restore caches from matching `rust-toolchain` versions, so that we don't
99+ # accumulate multiple versions of build artifacts over time.
100+ #
98101 # The hope is that even if some of the dependencies change between branches and
99102 # revisions, that enough of the slow-changing dependencies will remain static that
100103 # Cargo won't have to rebuild them.
101- - target_dir-linux-{{ .Branch }}-{{ checksum "Cargo.lock" }}
102- - target_dir-linux-{{ .Branch }}-
103- - target_dir-linux-
104+ - target_dir-{{ .Environment.CACHE_VERSION }}- linux-{{ checksum "rust-toolchain" }} -{{ .Branch }}-{{ checksum "Cargo.lock" }}
105+ - target_dir-{{ .Environment.CACHE_VERSION }}- linux-{{ checksum "rust-toolchain" }} -{{ .Branch }}-
106+ - target_dir-{{ .Environment.CACHE_VERSION }}- linux-{{ checksum "rust-toolchain" }} -
104107 - build_container
105108 - make_in_container :
106109 target : test-full
@@ -111,7 +114,7 @@ commands:
111114 condition : << parameters.cache_target >>
112115 steps :
113116 - save_cache :
114- key : target_dir-linux-{{ .Branch }}-{{ checksum "Cargo.lock" }}
117+ key : target_dir-{{ .Environment.CACHE_VERSION }}- linux-{{ checksum "rust-toolchain" }} -{{ .Branch }}-{{ checksum "Cargo.lock" }}
115118 paths :
116119 - " target"
117120
@@ -141,12 +144,15 @@ commands:
141144 # 2. A macOS cache built on a matching branch name with any `Cargo.lock` checksum
142145 # 3. Any macOS cache
143146 #
147+ # We only restore caches from matching `rust-toolchain` versions, so that we don't
148+ # accumulate multiple versions of build artifacts over time.
149+ #
144150 # The hope is that even if some of the dependencies change between branches and
145151 # revisions, that enough of the slow-changing dependencies will remain static that
146152 # Cargo won't have to rebuild them.
147- - target_dir-macos- {{ .Branch }}-{{ checksum "Cargo.lock " }}-{{ .Environment.CACHE_VERSION }}
148- - target_dir-macos-{{ .Branch }}-{{ .Environment.CACHE_VERSION }}
149- - target_dir-macos- {{ .Environment.CACHE_VERSION }}
153+ - target_dir-{{ .Environment.CACHE_VERSION }}-macos- {{ checksum "rust-toolchain " }}-{{ .Branch }}-{{ checksum "Cargo.lock" }}
154+ - target_dir-{{ .Environment.CACHE_VERSION }}- macos-{{ checksum "rust-toolchain" }}-{{ .Branch }}-
155+ - target_dir-{{ .Environment.CACHE_VERSION }}-macos-{{ checksum "rust-toolchain" }}-
150156 - run :
151157 name : " Install Homebrew dependencies"
152158 command : |
@@ -181,7 +187,7 @@ commands:
181187 condition : << parameters.cache_target >>
182188 steps :
183189 - save_cache :
184- key : target_dir-macos- {{ .Branch }}-{{ checksum "Cargo.lock " }}-{{ .Environment.CACHE_VERSION }}
190+ key : target_dir-{{ .Environment.CACHE_VERSION }}-macos- {{ checksum "rust-toolchain " }}-{{ .Branch }}-{{ checksum "Cargo.lock" }}
185191 paths :
186192 - " target"
187193
0 commit comments