before_cache.sh 872 B

12345678910111213141516171819202122232425262728
  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. echo "before_cache.sh: cache size"
  8. du -chd 1 "${HOME}/.cache" | sort -rh | head -20
  9. echo "before_cache.sh: ccache stats"
  10. ccache -s 2>/dev/null || true
  11. # Do not keep ccache stats (uploaded to cache otherwise; reset initially anyway).
  12. find "${HOME}/.ccache" -name stats -delete
  13. # Update the third-party dependency cache only if the build was successful.
  14. if ended_successfully; then
  15. # Do not cache downloads. They should not be needed with up-to-date deps.
  16. rm -rf "${DEPS_BUILD_DIR}/build/downloads"
  17. rm -rf "${CACHE_NVIM_DEPS_DIR}"
  18. mv "${DEPS_BUILD_DIR}" "${CACHE_NVIM_DEPS_DIR}"
  19. touch "${CACHE_MARKER}"
  20. echo "Updated third-party dependencies (timestamp: $(_stat "${CACHE_MARKER}"))."
  21. fi