From eac1f78568026f60982c255f6fe2cb5e09129be3 Mon Sep 17 00:00:00 2001 From: Liangsheng Yin Date: Tue, 4 Aug 2026 21:55:06 -0700 Subject: [PATCH] [CI] Free hosted-runner disk space only when it is low (#33644) --- .github/workflows/_pr-test-stage-cpu.yml | 7 ++++++- .github/workflows/rerun-test.yml | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_pr-test-stage-cpu.yml b/.github/workflows/_pr-test-stage-cpu.yml index 0972a2cc6..889035f58 100644 --- a/.github/workflows/_pr-test-stage-cpu.yml +++ b/.github/workflows/_pr-test-stage-cpu.yml @@ -62,7 +62,12 @@ jobs: steps: - name: Free disk space run: | - sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc + # The image ships ~65G free and the suite peaks around 30G; deleting + # these trees is ~1M unlinks (~80s), so only pay it when actually low. + avail_gb=$(df --output=avail -BG / | tail -1 | tr -dc '0-9') + if [ "${avail_gb}" -lt 40 ]; then + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc + fi df -h - name: Checkout code diff --git a/.github/workflows/rerun-test.yml b/.github/workflows/rerun-test.yml index f188c0695..13f5b15a3 100644 --- a/.github/workflows/rerun-test.yml +++ b/.github/workflows/rerun-test.yml @@ -245,7 +245,12 @@ jobs: steps: - name: Free disk space run: | - sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc + # The image ships ~65G free and the suite peaks around 30G; deleting + # these trees is ~1M unlinks (~80s), so only pay it when actually low. + avail_gb=$(df --output=avail -BG / | tail -1 | tr -dc '0-9') + if [ "${avail_gb}" -lt 40 ]; then + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc + fi df -h - name: Checkout code