Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 67c7c1a

Browse files
authored
Clean up bazel cache after build. (#419)
Both to bound the size and to spend less time transferring files.
1 parent 778bb81 commit 67c7c1a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/travis/build_bazel.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@ chmod +x bazel-${BAZEL_VERSION}-installer-${BAZEL_OS}-x86_64.sh
3535
echo "build --disk_cache=$HOME/bazel-cache" > ~/.bazelrc
3636
echo "build --experimental_strict_action_env" >> ~/.bazelrc
3737
du -sk $HOME/bazel-cache || true
38+
touch $HOME/start-time
3839

3940
bazel build $BAZEL_OPTIONS -k //...
4041
bazel test $BAZEL_OPTIONS -k $(bazel query "kind(test, //...) except attr('tags', 'manual|noci', //...)")
4142

42-
du -sk $HOME/bazel-cache || true
43+
set +e
44+
# Travis doesn't restore atime, so update mtime of files accessed during build.
45+
find $HOME/bazel-cache -type f -anewer $HOME/start-time -print0 | xargs -0 touch
46+
# Clean up cache.
47+
echo "Deleting $(find $HOME/bazel-cache -type f -mtime +7 | wc -l) old files."
48+
find $HOME/bazel-cache -type f -mtime +7 -delete
49+
du -sk $HOME/bazel-cache

0 commit comments

Comments
 (0)