Skip to content

Commit

Permalink
Revert "Reattempt to speed up deleting"
Browse files Browse the repository at this point in the history
This reverts commit 6b53cfb.
  • Loading branch information
whiteio committed Dec 13, 2024
1 parent ce5b7e5 commit 5ef7bf7
Showing 1 changed file with 17 additions and 29 deletions.
46 changes: 17 additions & 29 deletions src/ci/scripts/free-disk-space.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@
# MACROS
# ======

fast_rmdir() {
if [[ -d "$1" ]] && [[ -n "$1" ]] && [[ ! "$1" = "/" ]] && [[ ! "$1" = "~" ]]; then
echo "Removing directory: $1"
sudo find "$1" -type f -delete -print | wc -l
sudo rm -rf "$1"
fi
}

list_installed_dpkg() {
dpkg --get-selections $@ | grep -v deinstall | awk '{print $1}'
}

# macro to print a line of equals
# # (silly but works)
printSeparationLine() {
Expand Down Expand Up @@ -130,7 +118,7 @@ printSavedSpace $SAVED "Swift"
# Remove Android library
BEFORE=$(getAvailableSpace)

fast_rmdir /usr/local/lib/android || true
sudo rm -rf /usr/local/lib/android || true

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

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

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

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

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
Expand All @@ -162,19 +150,19 @@ printSavedSpace $SAVED "Haskell runtime"

BEFORE=$(getAvailableSpace)

pkgs=$(list_installed_dpkg 'microsoft-edge-*' 'snapd-*' 'aspnetcore-*' 'dotnet-*' 'llvm-*' '*php*' 'mongodb-*' 'mysql-*' azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri 'google-cloud-*' 'gcloud-*' || true)
gcloud_prerm='#!/bin/sh
echo $0
if [ -d "/usr/lib/google-cloud-sdk" ]; then
echo "Cleaning Google Cloud CLI files..."
find /usr/lib/google-cloud-sdk -type f -delete -print | wc -l
rm -rf /usr/lib/google-cloud-sdk
echo "Cleaning Google Cloud CLI manuals..."
find /usr/share/man -type f -name "gcloud*" -delete -print | wc -l
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..."
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..."
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..."

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
Expand Down

0 comments on commit 5ef7bf7

Please sign in to comment.