faster disk cleanup check (#8565)

I can't reproduce the `chmod` failure and have no clue how to fix it, so
for now let's just hope it's not too frequent.

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Gary Verhaegen 2021-01-19 20:50:44 +01:00 committed by GitHub
parent fbea4e6ba8
commit 01f11109fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,27 +33,19 @@ steps:
# Location of the disk cache for CI servers set in their init files:
# infra/macos/2-common-box/init.sh:echo "build:darwin --disk_cache=~/.bazel-cache" > ~/.bazelrc
# infra/vsts_agent_linux_startup.sh:echo "build:linux --disk_cache=~/.bazel-cache" > ~/.bazelrc
disk_cache=$HOME/.bazel-cache
if [ $(du -ms "$disk_cache" | awk '{print $1}') -gt 80000 ]; then
echo "Deleting '$disk_cache'..."
if [ $(df -m . | sed 1d | awk '{print $4}') -lt 30000 ]; then
echo "Disk full, cleaning up..."
disk_cache="$HOME/.bazel-cache"
rm -rf "$disk_cache"
else
echo "Disk cache small enough:"
du -hs "$disk_cache"
fi
local_cache=$HOME/.cache/bazel
if [ -d "$local_cache" ]; then
if [ $(du -ms "$local_cache" | awk '{print $1}') -gt 80000 ]; then
echo "Deleting '$local_cache'..."
echo "removed '$disk_cache'"
local_cache="$HOME/.cache/bazel"
if [ -d "$local_cache" ]; then
chmod -R +w "$local_cache"
rm -rf "$local_cache"
else
echo "Local cache small enough:"
du -hs "$local_cache"
echo "removed '$local_cache'"
fi
else
echo "No '$local_cache', moving on."
fi
df -h .
displayName: clean-up disk cache
- bash: ./fmt.sh --test