[Unit]
Description=Clear quarry CI's Go build cache (weekly; it refills by itself)
# The cache grew to 22 GB in two weeks on a 301 GB disk. Go only drops
# entries unused for five days, and a busy CI touches everything.
[Service]
Type=oneshot
User=ciworker
Group=ciworker
Environment=HOME=/srv/ci-work
Environment=GOCACHE=/srv/ci-work/gocache
Nice=10
# Skipped while a build or test is running: clearing the cache under a
# compile fails that run. The timer tries again next week.
ExecStart=/bin/sh -c 'if ps -eo comm --no-headers | grep -qE "^(go|compile|link|vet)$|\\.test$"; then echo "CI is busy; skipped"; exit 0; fi; before=$(du -sm "$GOCACHE" | cut -f1); /usr/local/go/bin/go clean -cache; echo "cleared $before MB; now $(du -sm "$GOCACHE" | cut -f1) MB"'