@@ -12,6 +12,7 @@ test-defaults: &test-defaults
12
12
<< : *defaults
13
13
environment :
14
14
CIRCLE_TEST_REPORTS : /tmp/circle-test-reports
15
+ TEST_RESULTS_FILE : /tmp/test-results/results.json
15
16
16
17
17
18
all-branches-and-tags : &all-branches-and-tags
@@ -258,11 +259,42 @@ jobs:
258
259
- restore_cache :
259
260
keys :
260
261
- v2-home-sbt-{{ checksum "build/sbt" }}-{{ checksum "project/target/streams/$global/update/$global/streams/update_cache_2.10/inputs" }}
262
+ - restore_cache :
263
+ keys :
264
+ - v1-test-results-{{ .Branch }}-{{ .BuildNum }}
265
+ - v1-test-results-{{ .Branch }}-
266
+ - v1-test-results-master-
267
+ - run :
268
+ name : Merge cached test results with results provided by circle (if any)
269
+ command : |
270
+ [[ -f "$CIRCLE_INTERNAL_TASK_DATA/circle-test-results/results.json" ]] && circle_exists=1
271
+ [[ -f "$TEST_RESULTS_FILE" ]] && cached_exists=1
272
+ if [[ -z "$circle_exists" ]] || [[ -z "$cached_exists" ]]; then
273
+ # Only one exists, CirclePlugin will try to look for both so we're good.
274
+ exit 0
275
+ fi
276
+
277
+ # Otherwise, combine the two, preferring newer results from circle test results
278
+ echo "Found both cached and circle test results, merging"
279
+ jq -s 'def meld:
280
+ reduce .[] as $o
281
+ ({}; reduce ($o|keys)[] as $key (.; .[$key] += [$o[$key]] ));
282
+ def grp: map([{key: "\(.source)~\(.classname)", value: .}] | from_entries) | meld;
283
+ ((.[0].tests | grp) * (.[1].tests | grp)) | map(values) | flatten | {tests: .}' \
284
+ "$TEST_RESULTS_FILE" \
285
+ "$CIRCLE_INTERNAL_TASK_DATA/circle-test-results/results.json" \
286
+ > /tmp/new-test-results.json
287
+ # Overwrite the previously cached results with the merged file
288
+ mv -f /tmp/new-test-results.json "$TEST_RESULTS_FILE"
261
289
- run :
262
290
name : Run all tests
263
291
command : ./dev/run-scala-tests.py \
264
292
| tee -a "/tmp/run-scala-tests.log"
265
293
no_output_timeout : 15m
294
+ - save_cache :
295
+ key : v1-test-results-{{ .Branch }}-{{ .BuildNum }}
296
+ paths :
297
+ - " /tmp/test-results"
266
298
- store_artifacts :
267
299
path : /tmp/run-scala-tests.log
268
300
destination : run-scala-tests.log
0 commit comments