Skip to content

Commit 62bbc22

Browse files
committed
ci: add GitHub action(s) to clean up runner disk space
Define composite actions to remove large toolsets, unused packages, Docker images, and caches from the GitHub runner, freeing up disk space for builds. Note that the content of the cleanup-space/actions.yaml file is copied from the following `tapd` PR: lightninglabs/taproot-assets#1878 There's one distinct difference from the `tapd` file. In this repo, we separate the cleanup of the android folder into a separate action. The reason for this separation is that we need to be able to control when the android folder is cleaned up, during the job, as some jobs will fail if the android folder is removed in the beginning of the job. Not all of the targeted files when running the script, should ever have been used when building the binaries for LNC, but we keep the script consistent between the repos for simplicity.
1 parent 782a956 commit 62bbc22

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "Clean up android sdk/ndk"
2+
description: "Removes Android SDK/NDK to free up disk space on the runner."
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Remove android toolchain
8+
shell: bash
9+
run: |
10+
echo "Removing android toolchain to free up disk space..."
11+
sudo rm -rf /usr/local/lib/android
12+
df -h
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Clean up runner disk space"
2+
description: "Removes large, non-essential toolsets to free up disk space on the runner."
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Free up disk space
8+
shell: bash
9+
run: |
10+
echo "Removing large toolsets to free up disk space..."
11+
echo "Disk space before cleanup:"
12+
df -h
13+
14+
# Remove dotnet to save disk space.
15+
sudo rm -rf /usr/share/dotnet
16+
# Remove ghc to save disk space.
17+
sudo rm -rf /opt/ghc
18+
# Remove large packages.
19+
sudo rm -rf /usr/share/swift
20+
sudo rm -rf /usr/local/julia*
21+
sudo rm -rf /opt/hostedtoolcache
22+
23+
# Remove docker images to save space.
24+
docker image prune -a -f || true
25+
26+
# Remove large apt packages.
27+
sudo apt-get remove -y \
28+
'^aspnetcore-.*' \
29+
'^dotnet-.*' \
30+
'^llvm-.*' \
31+
'php.*' \
32+
'^mongodb-.*' \
33+
'^mysql-.*' \
34+
azure-cli \
35+
google-chrome-stable \
36+
firefox \
37+
powershell \
38+
mono-devel \
39+
libgl1-mesa-dri 2>/dev/null || true
40+
sudo apt-get autoremove -y
41+
sudo apt-get clean
42+
43+
# Remove caches.
44+
sudo rm -rf /usr/local/share/boost
45+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
46+
47+
echo "Disk space after cleanup:"
48+
df -h

0 commit comments

Comments
 (0)