Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/actions/host-cleanup-linux/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Host Cleanup (Linux)
description: Reclaims disk space on Linux CI agents by removing unused pre-installed software

runs:
using: 'composite'
steps:
- name: Cleanup unused host dependencies
if: runner.os == 'Linux'
shell: bash
run: |
# This list is based on what the base image contains and
# may need to be adjusted as new software gets installed.
# Use the `du` command to determine what can be uninstalled.

# Use sudo only when available and non-interactive (no password prompt)
if command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then
SUDO="sudo -n"
else
SUDO=""
fi

echo "Disk space before cleanup:"
df -h /

rm -rf ~/.cargo ~/.rustup ~/.dotnet || true

$SUDO rm -rf /usr/share/swift || true
$SUDO rm -rf /opt/microsoft/msedge || true
$SUDO rm -rf /usr/local/.ghcup || true
$SUDO rm -rf /usr/lib/mono || true
$SUDO rm -rf /usr/local/lib/android || true
$SUDO rm -rf /opt/ghc || true
$SUDO rm -rf /opt/hostedtoolcache/CodeQL || true

if command -v snap >/dev/null 2>&1; then
timeout 60s $SUDO snap remove lxd || true
timeout 60s $SUDO snap remove core20 || true
fi

if command -v apt-get >/dev/null 2>&1; then
DEBIAN_FRONTEND=noninteractive timeout 120s $SUDO apt-get purge -y snapd || true
fi

echo "Disk space after cleanup:"
df -h /
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ jobs:
with:
fetch-depth: 0

- name: Free disk space (Linux)
uses: ./.github/actions/host-cleanup-linux

Comment thread
agneszitte marked this conversation as resolved.
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
Expand Down
Loading