before_cache.sh 929 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env bash
  2. set -e
  3. set -o pipefail
  4. CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  5. source "${CI_DIR}/common/build.sh"
  6. source "${CI_DIR}/common/suite.sh"
  7. mkdir -p "${HOME}/.cache"
  8. echo "before_cache.sh: cache size"
  9. du -chd 1 "${HOME}/.cache" | sort -rh | head -20
  10. echo "before_cache.sh: ccache stats"
  11. ccache -s 2>/dev/null || true
  12. # Do not keep ccache stats (uploaded to cache otherwise; reset initially anyway).
  13. find "${HOME}/.ccache" -name stats -delete
  14. # Update the third-party dependency cache only if the build was successful.
  15. if ended_successfully && [ -d "${DEPS_BUILD_DIR}" ]; then
  16. # Do not cache downloads. They should not be needed with up-to-date deps.
  17. rm -rf "${DEPS_BUILD_DIR}/build/downloads"
  18. rm -rf "${CACHE_NVIM_DEPS_DIR}"
  19. mv "${DEPS_BUILD_DIR}" "${CACHE_NVIM_DEPS_DIR}"
  20. touch "${CACHE_MARKER}"
  21. echo "Updated third-party dependencies (timestamp: $(_stat "${CACHE_MARKER}"))."
  22. fi