|
16 | 16 | echo "Disk space before cleanup:" |
17 | 17 | df -h / |
18 | 18 |
|
19 | | -rm -rf ~/.cargo ~/.rustup ~/.dotnet || true |
| 19 | +# ── Docker images — the biggest single win on hosted runners (~30 GB) ─────── |
| 20 | +# Omitting this is why the runtime-test build jobs still ran out of disk while |
| 21 | +# archiving the SDK cache ("tar: Wrote only 8192 of 10240 bytes"). |
| 22 | +if command -v docker >/dev/null 2>&1; then |
| 23 | + docker system prune -af --volumes 2>/dev/null || true |
| 24 | +fi |
| 25 | + |
| 26 | +# ── Home-directory toolchains ────────────────────────────────────────────── |
| 27 | +# Wipes ~/.dotnet — safe on ephemeral CI agents only. On a developer machine |
| 28 | +# set ALLOW_DOTNET_WIPE=1 to opt in. |
| 29 | +if [ "${ALLOW_DOTNET_WIPE:-0}" = "1" ] || [ "${CI:-}" = "true" ] || [ "${TF_BUILD:-}" = "True" ]; then |
| 30 | + rm -rf ~/.cargo ~/.rustup ~/.dotnet || true |
| 31 | +else |
| 32 | + echo "Skipping ~/.dotnet wipe — not a CI agent (set ALLOW_DOTNET_WIPE=1 to override)." |
| 33 | + rm -rf ~/.cargo ~/.rustup || true |
| 34 | +fi |
20 | 35 |
|
| 36 | +# ── System-wide pre-installed software not needed for .NET builds ────────── |
21 | 37 | $SUDO rm -rf /usr/share/swift || true |
22 | 38 | $SUDO rm -rf /opt/microsoft/msedge || true |
23 | 39 | $SUDO rm -rf /usr/local/.ghcup || true |
24 | 40 | $SUDO rm -rf /usr/lib/mono || true |
25 | | -$SUDO rm -rf /usr/local/lib/android || true |
26 | 41 | $SUDO rm -rf /opt/ghc || true |
27 | | -$SUDO rm -rf /opt/hostedtoolcache/CodeQL || true |
28 | 42 |
|
29 | | -if command -v snap >/dev/null 2>&1; then |
30 | | - timeout 60s $SUDO snap remove lxd || true |
31 | | - timeout 60s $SUDO snap remove core20 || true |
| 43 | +# The agent's Android SDK is ~10 GB and worth reclaiming for jobs that don't |
| 44 | +# build Android - but a job that does must keep it, or the build fails with |
| 45 | +# XA5300 ("The Android SDK directory could not be found"). Set |
| 46 | +# KEEP_ANDROID_SDK=1 in such a job. |
| 47 | +if [ "${KEEP_ANDROID_SDK:-0}" = "1" ]; then |
| 48 | + echo "Keeping /usr/local/lib/android (KEEP_ANDROID_SDK=1)." |
| 49 | +else |
| 50 | + $SUDO rm -rf /usr/local/lib/android || true |
32 | 51 | fi |
| 52 | +$SUDO rm -rf /opt/hostedtoolcache/CodeQL || true |
33 | 53 |
|
| 54 | +# ── Hosted tool cache (non-.NET runtimes) ────────────────────────────────── |
| 55 | +# Node is deliberately left in place: several stages use NodeTool@0 and would |
| 56 | +# just re-download it. |
| 57 | +$SUDO rm -rf /opt/hostedtoolcache/Ruby || true |
| 58 | +$SUDO rm -rf /opt/hostedtoolcache/PyPy || true |
| 59 | +$SUDO rm -rf /opt/hostedtoolcache/Python || true |
| 60 | +$SUDO rm -rf /opt/hostedtoolcache/go || true |
| 61 | + |
| 62 | +# ── apt ──────────────────────────────────────────────────────────────────── |
| 63 | +# Only snapd is purged here, plus a cache clean. |
| 64 | +# |
| 65 | +# studio.live's version of this script additionally purges firefox, |
| 66 | +# google-chrome-stable, libllvm*, clang-*, llvm-* and php*/ruby*. Do NOT copy |
| 67 | +# that list into this repo: |
| 68 | +# |
| 69 | +# * Purging `libllvm*` cascades. apt removes reverse-dependencies even |
| 70 | +# without --auto-remove, and Mesa's software rasteriser (llvmpipe) links |
| 71 | +# LLVM, so `xvfb` goes with it. Both Skia desktop stages here run their |
| 72 | +# tests under `xvfb-run`, which then fails with exit 127 |
| 73 | +# ("xvfb-run: command not found") - build 227556. |
| 74 | +# * `google-chrome-stable` is needed by the WebAssembly UI tests, which drive |
| 75 | +# a real Chrome through chromedriver. |
| 76 | +# |
| 77 | +# The Docker prune above already reclaims far more than this list would. |
34 | 78 | if command -v apt-get >/dev/null 2>&1; then |
35 | | - DEBIAN_FRONTEND=noninteractive timeout 120s $SUDO apt-get purge -y snapd || true |
| 79 | + DEBIAN_FRONTEND=noninteractive timeout 120s $SUDO apt-get purge -y snapd 2>/dev/null || true |
| 80 | + DEBIAN_FRONTEND=noninteractive timeout 60s $SUDO apt-get clean 2>/dev/null || true |
| 81 | +fi |
| 82 | + |
| 83 | +if command -v snap >/dev/null 2>&1; then |
| 84 | + timeout 60s $SUDO snap remove lxd 2>/dev/null || true |
| 85 | + timeout 60s $SUDO snap remove core20 2>/dev/null || true |
36 | 86 | fi |
37 | 87 |
|
38 | 88 | echo "Disk space after cleanup:" |
|
0 commit comments