Skip to content

Commit d7af8f3

Browse files
zirainshreealt
andauthored
[release-1.5] ci: add script to free disk space (#7534) (#7538)
ci: add script to free disk space (#7534) * feat: free disk space * lint * cleanup * make target and tools/hack * lint * modular action --------- Signed-off-by: Shreemaan Abhishek <[email protected]> Signed-off-by: zirain <[email protected]> Co-authored-by: shreealt <[email protected]>
1 parent 8ab8cec commit d7af8f3

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

.github/workflows/build_and_test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ jobs:
159159
steps:
160160
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
161161
- uses: ./tools/github-actions/setup-deps
162+
- uses: ./tools/github-actions/reclaim-storage
162163

163164
- name: Download EG Binaries
164165
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: reclaim-storage
2+
description: Remove unnecessary packages and artifacts from GitHub Actions Runner
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- shell: bash
8+
run: make reclaim-storage

tools/hack/reclaim-storage.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
log() { echo "==> $*"; }
5+
6+
log "Initial disk usage:"
7+
df -h || true
8+
9+
# Remove large, unused language/tool runtimes
10+
TO_DELETE=(
11+
/usr/local/lib/android
12+
/usr/share/dotnet
13+
/opt/ghc
14+
/usr/local/.ghcup
15+
/usr/share/swift
16+
)
17+
18+
for path in "${TO_DELETE[@]}"; do
19+
if [ -d "$path" ]; then
20+
log "Removing $path"
21+
sudo rm -rf "$path"
22+
fi
23+
done
24+
25+
log "Removing large packages..."
26+
EXTRA_PKGS="azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri google-cloud-sdk google-cloud-cli"
27+
28+
sudo apt-get remove -y "$EXTRA_PKGS" --fix-missing || true
29+
sudo apt-get autoremove -y || true
30+
sudo apt-get clean || true
31+
32+
# Swap removal
33+
if [ -f /mnt/swapfile ]; then
34+
log "Disabling and removing swapfile"
35+
sudo swapoff -a || true
36+
sudo rm -f /mnt/swapfile || true
37+
fi
38+
39+
log "Final disk usage:"
40+
df -h || true
41+
42+
log "Completed disk space reclamation."

tools/make/tools.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ tools.clean: # Remove all tools
5454
.PHONY: clean
5555
clean: ## Remove all files that are created during builds.
5656
clean: tools.clean
57+
58+
.PHONY: reclaim-storage
59+
reclaim-storage: ## Removes unnecessary packages and artifacts from GitHub Actions Runner
60+
bash ./tools/hack/reclaim-storage.sh

0 commit comments

Comments
 (0)