Skip to content

Commit

Permalink
Speed up
Browse files Browse the repository at this point in the history
  • Loading branch information
whiteio committed Dec 11, 2024
1 parent de0761b commit bbf9343
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions src/ci/scripts/free-disk-space.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
# MACROS
# ======

setup_rmz() {
curl -fsSL --tlsv1.2 --proto '=https' https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash > /dev/null 2>&1

Check failure on line 9 in src/ci/scripts/free-disk-space.sh

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
cargo binstall -qy rmz
ln -s ~/.cargo/bin/rmz /usr/local/bin/rmz
}

# macro to print a line of equals
# # (silly but works)
printSeparationLine() {
Expand Down Expand Up @@ -71,15 +77,15 @@ printDH() {

AVAILABLE_INITIAL=$(getAvailableSpace)
AVAILABLE_ROOT_INITIAL=$(getAvailableSpace '/')
setup_rmz

printDH "BEFORE CLEAN-UP:"
echo ""


# Remove Android library
BEFORE=$(getAvailableSpace)

sudo rm -rf /usr/local/lib/android || true
sudo rmz -f /usr/local/lib/android || true

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
Expand All @@ -90,7 +96,7 @@ printSavedSpace $SAVED "Android library"
BEFORE=$(getAvailableSpace)

# https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11
sudo rm -rf /usr/share/dotnet || true
sudo rmz -f /usr/share/dotnet || true

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
Expand All @@ -99,8 +105,8 @@ printSavedSpace $SAVED ".NET runtime"
# Remove Haskell runtime
BEFORE=$(getAvailableSpace)

sudo rm -rf /opt/ghc || true
sudo rm -rf /usr/local/.ghcup || true
sudo rmz -f /opt/ghc || true
sudo rmz -f /usr/local/.ghcup || true

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
Expand All @@ -111,18 +117,18 @@ printSavedSpace $SAVED "Haskell runtime"

BEFORE=$(getAvailableSpace)

sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..."
sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y google-cloud-sdk --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-sdk --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y google-cloud-cli --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-cli --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y microsoft-edge-stable --fix-missing || echo "::debug::The command [sudo apt-get remove -y microsoft-edge-stable --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y snapd --fix-missing || echo "::debug::The command [sudo apt-get remove -y snapd --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..."
pkgs=$(list_installed_dpkg 'aspnetcore-*' 'dotnet-*' 'llvm-*' '*php*' 'mongodb-*' 'mysql-*' azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri 'google-cloud-*' 'gcloud-*' || true)

Check failure on line 120 in src/ci/scripts/free-disk-space.sh

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars

gcloud_prerm='#!/bin/sh
echo $0
if [ -d "/usr/lib/google-cloud-sdk" ]; then
sudo rmz -f /usr/lib/google-cloud-sdk
fi'

echo "$gcloud_prerm" | sudo tee /var/lib/dpkg/info/google-cloud-cli-anthoscli.prerm >/dev/null
echo "$gcloud_prerm" | sudo tee /var/lib/dpkg/info/google-cloud-cli.prerm >/dev/null

sudo apt-get remove --autoremove -y $pkgs || echo "::warning::The command [sudo apt-get remove -y] failed to complete successfully. Proceeding..."

Check failure on line 131 in src/ci/scripts/free-disk-space.sh

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..."

Check failure on line 132 in src/ci/scripts/free-disk-space.sh

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars

AFTER=$(getAvailableSpace)
Expand All @@ -144,7 +150,7 @@ printSavedSpace $SAVED "Docker images"

BEFORE=$(getAvailableSpace)

sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
sudo rmz -f "$AGENT_TOOLSDIRECTORY" || true

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
Expand All @@ -155,7 +161,7 @@ printSavedSpace $SAVED "Tool cache"
BEFORE=$(getAvailableSpace)

sudo swapoff -a || true
sudo rm -f /mnt/swapfile || true
sudo rmz -f /mnt/swapfile || true
free -h

AFTER=$(getAvailableSpace)
Expand Down

0 comments on commit bbf9343

Please sign in to comment.