@@ -10,21 +10,16 @@ defaults: &defaults
1010# 2) Cache keys are prefix matched, and the most recently updated cache that matches will be picked
1111#
1212# There is a weekly job that runs on Monday mornings that builds a new cache from scratch.
13- #
14- # The cache is also saved using the unique git revision to enable the dependent build steps to get a fully populated
15- # cache to work from.
16- cache_keys : &cache_keys
13+ dependency_cache_keys : &dependency_cache_keys
1714 keys :
18- # Dependent steps will find this cache
19- - dd-trace-java-v4-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ .Revision }}
2015 # New branch commits will find this cache
21- - dd-trace-java-v4 -{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-
16+ - dd-trace-java-dep-v1 -{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-
2217 # New branches fall back on main build caches
23- - dd-trace-java-v4 -master-{{ checksum "_circle_ci_cache_base_id" }}-
18+ - dd-trace-java-dep-v1 -master-{{ checksum "_circle_ci_cache_base_id" }}-
2419 # Fall back on the previous cache scheme to not start from scratch when switching
25- - dd-trace-java-v3 -master-
20+ - dd-trace-java-v4 -master-
2621
27- save_cache_paths : &save_cache_paths
22+ dependency_cache_paths : &dependency_cache_paths
2823 paths :
2924 # Cached dependencies and wrappers for gradle
3025 - ~/.gradle
@@ -37,6 +32,23 @@ save_cache_paths: &save_cache_paths
3732 # Cached dependencies for sbt handled by coursier
3833 - ~/.cache/coursier
3934
35+ build_cache_keys : &build_cache_keys
36+ keys :
37+ # Dependent steps will find this cache
38+ - dd-trace-java-build-v1-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ .Revision }}
39+ # New branch commits will find this cache
40+ - dd-trace-java-build-v1-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-
41+ # New branches fall back on main build caches
42+ - dd-trace-java-build-v1-master-{{ checksum "_circle_ci_cache_base_id" }}-
43+
44+ build_cache_paths : &build_cache_paths
45+ paths :
46+ # Gradle version specific cache for incremental builds needs to match version in
47+ # gradle/wrapper/gradle-wrapper.properties
48+ - ~/.gradle/caches/7.5.1
49+ # Makes it easier to upgrade gradle versions
50+ - ~/.gradle/wrapper
51+
4052test_matrix : &test_matrix
4153 parameters :
4254 testJvm : [ "7", "IBM8", "ZULU8","ORACLE8", "11", "ZULU11", "ZULU13", "15", "17" ]
@@ -153,7 +165,7 @@ jobs:
153165 - setup_code
154166
155167 - restore_cache :
156- << : *cache_keys
168+ << : *dependency_cache_keys
157169
158170 - run :
159171 name : Build Project
@@ -163,6 +175,7 @@ jobs:
163175 ./gradlew clean compile shadowJar
164176 << pipeline.parameters.gradle_flags >>
165177 --max-workers=4
178+ --rerun-tasks
166179
167180 - run :
168181 name : Collect Libs
@@ -178,9 +191,36 @@ jobs:
178191 - .gradle
179192 - workspace
180193
194+ # Save a full dependency cache when building on master or a base project branch
195+ - when :
196+ condition :
197+ matches :
198+ pattern : " ^(master|project/.+)$"
199+ value : << pipeline.git.branch >>
200+ steps :
201+ - save_cache :
202+ key : dd-trace-java-dep-v1-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ .Revision }}
203+ << : *dependency_cache_paths
204+
205+ # This part is now disable to speed up builds at the cost of downloading new dependencies a few more times
206+ #
207+ # # Save a full dependency the first time any other PR branch is built (will be skipped
208+ # # during other runs since the cache name will already exist)
209+ # - when:
210+ # condition:
211+ # not:
212+ # matches:
213+ # pattern: "^(master|project/.+)$"
214+ # value: << pipeline.git.branch >>
215+ # steps:
216+ # - save_cache:
217+ # key: dd-trace-java-dep-v1-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-base
218+ # <<: *dependency_cache_paths
219+
220+ # Save the small build cache
181221 - save_cache :
182- key : dd-trace-java-v4 -{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ .Revision }}
183- << : *save_cache_paths
222+ key : dd-trace-java-build-v1 -{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ .Revision }}
223+ << : *build_cache_paths
184224
185225 - display_memory_usage
186226
@@ -199,10 +239,15 @@ jobs:
199239 ./gradlew clean compile shadowJar
200240 << pipeline.parameters.gradle_flags >>
201241 --max-workers=4
242+ --rerun-tasks
243+
244+ - save_cache :
245+ key : dd-trace-java-dep-v1-{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ epoch }}
246+ << : *dependency_cache_paths
202247
203248 - save_cache :
204- key : dd-trace-java-v4 -{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ epoch }}
205- << : *save_cache_paths
249+ key : dd-trace-java-build-v1 -{{ .Branch }}-{{ checksum "_circle_ci_cache_id" }}-{{ epoch }}
250+ << : *build_cache_paths
206251
207252 - display_memory_usage
208253
@@ -225,7 +270,10 @@ jobs:
225270 - setup_code
226271
227272 - restore_cache :
228- << : *cache_keys
273+ << : *dependency_cache_keys
274+
275+ - restore_cache :
276+ << : *build_cache_keys
229277
230278 - run :
231279 name : Run tests
@@ -274,7 +322,10 @@ jobs:
274322 - setup_code
275323
276324 - restore_cache :
277- << : *cache_keys
325+ << : *dependency_cache_keys
326+
327+ - restore_cache :
328+ << : *build_cache_keys
278329
279330 - setup_testcontainers
280331
@@ -325,7 +376,10 @@ jobs:
325376 - setup_code
326377
327378 - restore_cache :
328- << : *cache_keys
379+ << : *dependency_cache_keys
380+
381+ - restore_cache :
382+ << : *build_cache_keys
329383
330384 - setup_testcontainers
331385
@@ -403,7 +457,10 @@ jobs:
403457 - setup_code
404458
405459 - restore_cache :
406- << : *cache_keys
460+ << : *dependency_cache_keys
461+
462+ - restore_cache :
463+ << : *build_cache_keys
407464
408465 - run :
409466 name : Build Project
@@ -447,7 +504,10 @@ jobs:
447504 #
448505 # Let's at least restore the build cache to have something to start from.
449506 - restore_cache :
450- << : *cache_keys
507+ << : *dependency_cache_keys
508+
509+ - restore_cache :
510+ << : *build_cache_keys
451511
452512 - run :
453513 name : Gather muzzle tasks
@@ -489,7 +549,10 @@ jobs:
489549 - setup_code
490550
491551 - restore_cache :
492- << : *cache_keys
552+ << : *dependency_cache_keys
553+
554+ - restore_cache :
555+ << : *build_cache_keys
493556
494557 - run :
495558 name : Install good version of docker-compose
0 commit comments