File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ name : ' Clear unnecessary files'
2+ description : ' Clear out unnecessary files to make space on the VM'
3+ runs :
4+ using : ' composite'
5+ steps :
6+ - name : Clear unnecessary files
7+ shell : bash
8+ env :
9+ DEBIAN_FRONTEND : noninteractive
10+ run : |
11+ set +e
12+
13+ # Skip slow "updating man-db" dpkg step
14+ echo 'set man-db/auto-update false' | sudo debconf-communicate; sudo dpkg-reconfigure man-db
15+
16+ echo "=== Disk space before cleanup ==="
17+ df -h
18+ BEFORE_AVAIL=$(df / | awk 'NR==2 {print $4}')
19+
20+ echo "Cleaning up unnecessary packages..."
21+ time sudo apt-get remove --purge -y firefox google-chrome-stable powershell
22+ time sudo apt-get autoremove -y
23+ time sudo apt-get clean
24+
25+ echo "Removing large directories..."
26+ DIRS_TO_REMOVE=(
27+ "/usr/share/dotnet/"
28+ "/usr/local/.ghcup/"
29+ "/usr/local/share/powershell"
30+ "/usr/local/share/chromium"
31+ "/usr/local/lib/android"
32+ "/usr/local/lib/node_modules"
33+ )
34+
35+ for dir in "${DIRS_TO_REMOVE[@]}"; do
36+ if [ -d "$dir" ]; then
37+ echo "Removing $dir"
38+ time sudo rm -Rf "$dir"
39+ fi
40+ done
41+
42+ echo "Disabling swap"
43+ sudo swapoff -a
44+ sudo rm -f /swapfile
45+
46+ echo "=== Disk space after cleanup ==="
47+ df -h
48+
49+ AFTER_AVAIL=$(df / | awk 'NR==2 {print $4}')
50+ SPACE_SAVED=$((AFTER_AVAIL - BEFORE_AVAIL))
51+ SPACE_SAVED_GB=$((SPACE_SAVED / 1024 / 1024))
52+ echo "Space freed: ${SPACE_SAVED_GB}GB (${SPACE_SAVED}KB)"
Original file line number Diff line number Diff line change @@ -271,6 +271,10 @@ jobs:
271271 with :
272272 cache-provider : ${{ matrix.provider || needs.runners.outputs.provider }}
273273
274+ - name : Clear unnecessary files
275+ if : ${{ needs.runners.outputs.provider == 'gha' }}
276+ uses : ./.github/actions/clear-files
277+
274278 - name : Set mmap_rnd_bits
275279 if : ${{ env.CONTAINER_NAME == 'ci_native_tsan' || env.CONTAINER_NAME == 'ci_native_msan' }}
276280 # Prevents crashes due to high ASLR entropy
You can’t perform that action at this time.
0 commit comments