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
24 changes: 2 additions & 22 deletions .github/actions/ci/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,8 @@ runs:
using: "composite"

steps:
- name: 'Cleanup unused image dependencies (Linux)'
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 below to determine what can be
# uninstalled.

rm -fR ~/.cargo
rm -fR ~/.rustup
rm -fR ~/.dotnet
sudo rm -fR /usr/share/swift
sudo rm -fR /opt/microsoft/msedge
sudo rm -fR /usr/local/.ghcup
sudo rm -fR /usr/lib/mono
sudo snap remove lxd
sudo snap remove core20
sudo apt remove snapd

df -h
# du -h -d 3 /
- name: Free disk space (Linux)
uses: ./.github/actions/host-cleanup-linux

Comment thread
agneszitte marked this conversation as resolved.
- name: Download Artifacts
uses: actions/download-artifact@v4
Expand Down
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
Comment thread
agneszitte marked this conversation as resolved.
fi

echo "Disk space after cleanup:"
df -h /
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:
fetch-depth: 0
ref: ${{ env.CheckoutRef }}

- name: Free disk space (Linux)
uses: ./.github/actions/host-cleanup-linux
Comment thread
agneszitte marked this conversation as resolved.
Comment thread
agneszitte marked this conversation as resolved.

- name: "Build Package"
uses: ./.github/actions/ci/build-packages

Expand Down Expand Up @@ -193,7 +196,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ env.CheckoutRef }}

- name: "Run Tests"
uses: ./.github/actions/ci/run-tests
with:
Expand Down
Loading