Skip to content

Commit 4312f38

Browse files
authored
ci: add script to free disk space (#7534)
* feat: free disk space Signed-off-by: Shreemaan Abhishek <[email protected]> * lint Signed-off-by: Shreemaan Abhishek <[email protected]> * cleanup Signed-off-by: Shreemaan Abhishek <[email protected]> * make target and tools/hack Signed-off-by: Shreemaan Abhishek <[email protected]> * lint Signed-off-by: Shreemaan Abhishek <[email protected]> * modular action Signed-off-by: Shreemaan Abhishek <[email protected]> --------- Signed-off-by: Shreemaan Abhishek <[email protected]>
1 parent 3c310a2 commit 4312f38

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
@@ -208,6 +208,7 @@ jobs:
208208
steps:
209209
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
210210
- uses: ./tools/github-actions/setup-deps
211+
- uses: ./tools/github-actions/reclaim-storage
211212

212213
- name: Download EG Binaries
213214
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.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
@@ -55,3 +55,7 @@ tools.clean: # Remove all tools
5555
.PHONY: clean
5656
clean: ## Remove all files that are created during builds.
5757
clean: tools.clean
58+
59+
.PHONY: reclaim-storage
60+
reclaim-storage: ## Removes unnecessary packages and artifacts from GitHub Actions Runner
61+
bash ./tools/hack/reclaim-storage.sh

0 commit comments

Comments
 (0)