Skip to content

Commit dbe8381

Browse files
authored
Merge pull request #27 from unoplatform/dev/agzi/ci-linux-host-cleanup
2 parents ddd95d3 + 8865051 commit dbe8381

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Host Cleanup (Linux)
2+
description: Reclaims disk space on Linux CI agents by removing unused pre-installed software
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- name: Cleanup unused host dependencies
8+
if: runner.os == 'Linux'
9+
shell: bash
10+
run: |
11+
# This list is based on what the base image contains and
12+
# may need to be adjusted as new software gets installed.
13+
# Use the `du` command to determine what can be uninstalled.
14+
15+
# Use sudo only when available and non-interactive (no password prompt)
16+
if command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then
17+
SUDO="sudo -n"
18+
else
19+
SUDO=""
20+
fi
21+
22+
echo "Disk space before cleanup:"
23+
df -h /
24+
25+
rm -rf ~/.cargo ~/.rustup ~/.dotnet || true
26+
27+
$SUDO rm -rf /usr/share/swift || true
28+
$SUDO rm -rf /opt/microsoft/msedge || true
29+
$SUDO rm -rf /usr/local/.ghcup || true
30+
$SUDO rm -rf /usr/lib/mono || true
31+
$SUDO rm -rf /usr/local/lib/android || true
32+
$SUDO rm -rf /opt/ghc || true
33+
$SUDO rm -rf /opt/hostedtoolcache/CodeQL || true
34+
35+
if command -v snap >/dev/null 2>&1; then
36+
timeout 60s $SUDO snap remove lxd || true
37+
timeout 60s $SUDO snap remove core20 || true
38+
fi
39+
40+
if command -v apt-get >/dev/null 2>&1; then
41+
DEBIAN_FRONTEND=noninteractive timeout 120s $SUDO apt-get purge -y snapd || true
42+
fi
43+
44+
echo "Disk space after cleanup:"
45+
df -h /

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ jobs:
8484
with:
8585
fetch-depth: 0
8686

87+
- name: Free disk space (Linux)
88+
uses: ./.github/actions/host-cleanup-linux
89+
8790
- name: Setup .NET
8891
uses: actions/setup-dotnet@v4
8992
with:

0 commit comments

Comments
 (0)