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 f0e8e11
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions src/ci/scripts/free-disk-space.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
# ======

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}'
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
}

# macro to print a line of equals
Expand Down Expand Up @@ -162,19 +158,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 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 '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --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 '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..."

Check failure on line 163 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 164 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 165 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 166 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 167 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 168 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 169 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 170 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 All @@ -195,7 +191,7 @@ printSavedSpace $SAVED "Docker images"

BEFORE=$(getAvailableSpace)

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

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

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

AFTER=$(getAvailableSpace)
Expand Down

0 comments on commit f0e8e11

Please sign in to comment.