daml/ci/clean-up.yml
Gary Verhaegen 95c2184dcc
bump disk cleanup threashold (#8807)
I've seen [a build] failing with "disk full" after starting with 41GB
free.

[a build]: https://dev.azure.com/digitalasset/daml/_build/results?buildId=69270&view=logs&j=870bb40c-6da0-5bff-67ed-547f10fa97f2&t=deecee86-545a-596e-8b0d-fb7d606fe9f2

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-10 13:39:29 +00:00

28 lines
1.0 KiB
YAML

# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
steps:
- bash: |
set -euo pipefail
# 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
if [ $(df -m . | sed 1d | awk '{print $4}') -lt 50000 ]; then
echo "Disk full, cleaning up..."
disk_cache="$HOME/.bazel-cache"
rm -rf "$disk_cache"
echo "removed '$disk_cache'"
local_cache="$HOME/.cache/bazel"
if [ -d "$local_cache" ]; then
for pid in $(pgrep -a -f bazel | awk '{print $1}'); do
kill -s KILL $pid
done
chmod -R +w "$local_cache"
rm -rf "$local_cache"
echo "removed '$local_cache'"
fi
fi
df -h .
displayName: clean-up disk cache