Improve disk-cleanup script

We were sometimes filling up the regular bazel cache (not the disk
cache). Clear it out if that happens.

Change-Id: I1c2eec726a6502eea0e918f5c6ec0754747ba109
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/tools/ci/clean-disk.sh b/tools/ci/clean-disk.sh
index 213a134..0c2ca92 100755
--- a/tools/ci/clean-disk.sh
+++ b/tools/ci/clean-disk.sh
@@ -3,13 +3,19 @@
 # Set default for disk utilisation
 readonly DMAX="${1:-80%}"
 # Cache folder
-readonly CACHE_FOLDER="${HOME}/.cache/bazel/disk_cache/"
+readonly CACHE_FOLDER="${HOME}/.cache/bazel/"
+readonly BUILDS_FOLDER="${HOME}/builds/${BUILDKITE_AGENT_NAME}/spartan-robotics/"
 # Retrieve disk usages in percentage
 readonly DSIZE="$(df -hlP "${CACHE_FOLDER}" | sed 1d | awk '{print $5}')"
 
 if [[ ${DSIZE} > ${DMAX} ]]; then
   echo "$(hostname): Disk over ${DMAX} Clean up needed on node."
+  # Ensure that everything has permissions such that it can be deleted.
+  chmod --recursive 777 ${CACHE_FOLDER}
+  chmod --recursive 777 "${BUILDS_FOLDER}"/*_output_base
   rm -rf "${CACHE_FOLDER}"
+  # Don't delete the git checkout.
+  rm -rf "${BUILDS_FOLDER}"/*_output_base
 else
   echo "$(hostname): No clean up needed. Disk usage is at: ${DSIZE}"
 fi