daml/ci/clean-up.yml
Gary Verhaegen 7c4b32aee9
use coreutils date on macos (#9228)
macOS uses BSD date by default which has slightly different options.

CHANGELOG_BEGIN
CHANGELOG_END
2021-03-24 13:35:02 +01:00

38 lines
1.2 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
eval $(dev-env/bin/dade-assist)
exec 1> >(while IFS= read -r line; do echo "$(date -Is) [out]: $line"; done)
exec 2> >(while IFS= read -r line; do echo "$(date -Is) [err]: $line"; done >&2)
# 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
df -h .
if [ $(df -m . | sed 1d | awk '{print $4}') -lt 50000 ]; then
echo "Disk full, cleaning up..."
case $(uname) in
Linux)
$HOME/reset_caches.sh
;;
Darwin)
# Only clean up disk cache
disk_cache="$HOME/.bazel-cache"
rm -rf "$disk_cache"
echo "removed '$disk_cache'"
;;
*)
echo "Unknown uname: '$(uname)'."
exit 1
;;
esac
df -h .
fi
displayName: clean-up disk cache