Skip to content

Commit a876ec9

Browse files
KirillTimGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "CI: Bazel uses '--disk_cache' now." into main
2 parents da07a6b + 5eb90e3 commit a876ec9

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/ci/bazel_tests.sh

+19-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,22 @@ echo "skipping build + test runs"
2222
exit 0
2323
fi
2424

25-
tools/bazel build //:all --verbose_failures
26-
tools/bazel build //python:all --verbose_failures
25+
BAZEL_DISK_CACHE_FOLDER="/ci/cache/bazel-disk-cache-$(hostname)"
26+
readonly BAZEL_DISK_CACHE_FOLDER
27+
# Cleanup the cache if any of the two conditions are true.
28+
BAZEL_DISK_CACHE_GC_OPTIONS="--experimental_disk_cache_gc_max_age=7d --experimental_disk_cache_gc_max_size=10G"
29+
# We don't run a bazel daemon in background, so we do a GC during the build,
30+
# that's why we specify _idle_delay=0.
31+
BAZEL_DISK_CACHE_GC_OPTIONS+=" --experimental_disk_cache_gc_idle_delay=0"
32+
readonly BAZEL_DISK_CACHE_GC_OPTIONS
33+
34+
BAZEL_DISK_CACHE_FLAGS="--disk_cache=${BAZEL_DISK_CACHE_FOLDER} ${BAZEL_DISK_CACHE_GC_OPTIONS}"
35+
readonly BAZEL_DISK_CACHE_FLAGS
36+
37+
# shellcheck disable=SC2086
38+
tools/bazel build //:all ${BAZEL_DISK_CACHE_FLAGS} --verbose_failures
39+
# shellcheck disable=SC2086
40+
tools/bazel build //python:all ${BAZEL_DISK_CACHE_FLAGS} --verbose_failures
2741

2842
# Smoke test that processes run without crashing.
2943
./bazel-bin/traced &
@@ -37,3 +51,6 @@ kill $(jobs -p)
3751
# Check the amalgamated build here to avoid slowing down all the Linux bots.
3852
echo -e "\n\n***** Testing amalgamated build *****\n"
3953
tools/test_gen_amalgamated.py
54+
55+
# Print the size of the bazel cache to make sure it won't grow infinitely.
56+
du -sh "${BAZEL_DISK_CACHE_FOLDER}"

0 commit comments

Comments
 (0)