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 e0d0d4b
Showing 1 changed file with 22 additions and 34 deletions.
56 changes: 22 additions & 34 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 @@ -89,39 +77,39 @@ echo ""

BEFORE=$(getAvailableSpace)

fast_rmdir "$AGENT_TOOLSDIRECTORY" || true
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Agent tools"

BEFORE=$(getAvailableSpace)

fast_rmdir /usr/local/share/powershell || true
sudo rm -rf /usr/local/share/powershell || true

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Powershell"

BEFORE=$(getAvailableSpace)

fast_rmdir /usr/local/share/chromium || true
sudo rm -rf /usr/local/share/chromium || true

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Chromium"

BEFORE=$(getAvailableSpace)

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

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Node modules"

BEFORE=$(getAvailableSpace)

fast_rmdir /usr/share/swift || true
sudo rm -rf /usr/share/swift || true

AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
Expand All @@ -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..."

Check failure on line 153 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 remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..."

Check failure on line 154 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 remove -y '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..."

Check failure on line 155 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 remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..."

Check failure on line 156 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 remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..."

Check failure on line 157 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 remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..."

Check failure on line 158 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 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..."

Check failure on line 159 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 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..."

Check failure on line 160 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 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..."

Check failure on line 161 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 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..."

Check failure on line 162 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 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 e0d0d4b

Please sign in to comment.