Skip to content

Commit 0c2ea9d

Browse files
[build] Expand machine disk cleanup and add pre-build space checks in CI (#17538)
1 parent 6891613 commit 0c2ea9d

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

.github/workflows/bazel.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,25 @@ jobs:
105105
sudo rm -rf /usr/local/share/boost || true
106106
sudo rm -rf /usr/share/swift || true
107107
sudo rm -rf /usr/local/julia* || true
108+
sudo rm -rf /usr/lib/google-cloud-sdk || true
109+
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
110+
docker image prune -af 2>/dev/null || true
108111
sync
109112
after=$(df -BG / | tail -1 | awk '{print $4}')
110113
echo "Space after: ${after}"
114+
- name: Remove extra tools to free disk space (Windows)
115+
if: inputs.os == 'windows'
116+
shell: pwsh
117+
run: |
118+
Write-Host "Removing extra tools to free disk space..."
119+
Write-Host "Space before: C: $([math]::Round((Get-PSDrive C).Free / 1GB, 1))GB free, D: $([math]::Round((Get-PSDrive D).Free / 1GB, 1))GB free"
120+
Remove-Item -Path "C:\Miniconda" -Recurse -Force -ErrorAction SilentlyContinue
121+
Remove-Item -Path "C:\tools\ghc" -Recurse -Force -ErrorAction SilentlyContinue
122+
Remove-Item -Path "C:\Program Files\LLVM" -Recurse -Force -ErrorAction SilentlyContinue
123+
Remove-Item -Path "C:\Program Files\PostgreSQL" -Recurse -Force -ErrorAction SilentlyContinue
124+
Remove-Item -Path "C:\Program Files\MongoDB" -Recurse -Force -ErrorAction SilentlyContinue
125+
Remove-Item -Path "C:\Program Files\MySQL" -Recurse -Force -ErrorAction SilentlyContinue
126+
Write-Host "Space after: C: $([math]::Round((Get-PSDrive C).Free / 1GB, 1))GB free, D: $([math]::Round((Get-PSDrive D).Free / 1GB, 1))GB free"
111127
- name: Calculate fetch depth
112128
id: depth
113129
shell: bash
@@ -217,6 +233,12 @@ jobs:
217233
crates: rust/Cargo.Bazel.lock
218234
repository-cache: true
219235
bazelrc: common --color=yes
236+
- name: Disk usage after cache restore
237+
if: inputs.os != 'macos'
238+
shell: bash
239+
run: |
240+
df -h "$GITHUB_WORKSPACE"
241+
if [[ "$RUNNER_OS" == "Windows" ]]; then df -h /c; fi
220242
- name: Setup Fluxbox and Xvfb
221243
if: inputs.os == 'ubuntu' && inputs.browser != ''
222244
run: |
@@ -242,6 +264,24 @@ jobs:
242264
- name: Configure RubyGems credentials via OIDC
243265
if: inputs.gem-trusted-publishing
244266
uses: rubygems/configure-rubygems-credentials@main
267+
- name: Check disk space before build
268+
if: inputs.os != 'macos'
269+
shell: bash
270+
run: |
271+
df -h "$GITHUB_WORKSPACE"
272+
if [[ "$RUNNER_OS" == "Windows" ]]; then
273+
# On Windows the workspace is on D: but C: is the constrained drive
274+
avail=$(df -k /c | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
275+
echo "Available disk space before build (C:): ${avail}GB"
276+
df -h /c
277+
else
278+
avail=$(df -k "$GITHUB_WORKSPACE" | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
279+
echo "Available disk space before build: ${avail}GB"
280+
fi
281+
if [ "$avail" -lt 10 ]; then
282+
echo "::error::Insufficient disk space: ${avail}GB available (need >=10GB)"
283+
exit 1
284+
fi
245285
- name: Run Bazel
246286
id: run-bazel
247287
shell: bash

MODULE.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ single_version_override(
2626
version = "33.5",
2727
)
2828

29-
bazel_dep(name = "rules_android", version = "0.7.2")
3029
bazel_dep(name = "rules_closure", version = "0.16.0")
3130
bazel_dep(name = "rules_dotnet", version = "0.21.5")
3231

0 commit comments

Comments
 (0)