#!/usr/bin/env bash set -euo pipefail # Cleans common build/test artifacts to reclaim disk space in this repo. # Defaults to a safe set; pass SAFE_ONLY=0 to include bin/obj. DRY_RUN=${DRY_RUN:-0} SAFE_ONLY=${SAFE_ONLY:-1} log() { printf "[cleanup] %s\n" "$*"; } run() { if [[ "$DRY_RUN" == "1" ]]; then log "DRY_RUN: $*" else eval "$@" fi } ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)" cd "$ROOT" paths=( "out" "ops/devops/artifacts" "ops/devops/ci-110-runner/artifacts" "ops/devops/sealed-mode-ci/artifacts" "TestResults" "tests/TestResults" "local-nugets/packages" ".nuget/packages" ) if [[ "$SAFE_ONLY" != "1" ]]; then while IFS= read -r dir; do paths+=("$dir") done < <(find . -maxdepth 4 -type d \( -name bin -o -name obj -o -name TestResults \) 2>/dev/null) fi log "Safe only: $SAFE_ONLY ; Dry run: $DRY_RUN" for p in "${paths[@]}"; do if [[ -d "$p" ]]; then log "Removing $p" run "rm -rf '$p'" fi done log "Done."