From 957a266deaecf4bb1e9a972a6db02725ac9e16c6 Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 10 Dec 2024 23:26:10 +0000 Subject: [PATCH 1/9] Add free-disk-space script --- src/ci/scripts/free-disk-space.sh | 179 ++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100755 src/ci/scripts/free-disk-space.sh diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh new file mode 100755 index 0000000000000..706ccaeb67f4e --- /dev/null +++ b/src/ci/scripts/free-disk-space.sh @@ -0,0 +1,179 @@ +#!/bin/bash +# Free disk space on Linux GitHub action runners + +# # ====== +# MACROS +# ====== + +# macro to print a line of equals +# # (silly but works) +printSeparationLine() { + str=${1:=} + num=${2:-80} + counter=1 + output="" + while [ $counter -le "$num" ] + do + output="${output}${str}" + counter=$((counter+1)) + done + echo "${output}" +} + +# macro to compute available space +# REF: https://unix.stackexchange.com/a/42049/60849 +# REF: https://stackoverflow.com/a/450821/408734 +getAvailableSpace() { df -a "$1" | awk 'NR > 1 {avail+=$4} END {print avail}'; } + +# macro to make Kb human readable (assume the input is Kb) +# REF: https://unix.stackexchange.com/a/44087/60849 +formatByteCount() { numfmt --to=iec-i --suffix=B --padding=7 "$1"'000'; } + +# macro to output saved space +printSavedSpace() { + saved=${1} + title=${2:-} + + echo "" + printSeparationLine '*' 80 + if [ -n "${title}" ]; then + echo "=> ${title}: Saved $(formatByteCount "$saved")" + else + echo "=> Saved $(formatByteCount "$saved")" + fi + printSeparationLine '*' 80 + echo "" +} + +# macro to print output of dh with caption +printDH() { + caption=${1:-} + + printSeparationLine '=' 80 + echo "${caption}" + echo "" + echo "$ dh -h /" + echo "" + df -h / + echo "$ dh -a /" + echo "" + df -a / + echo "$ dh -a" + echo "" + df -a + printSeparationLine '=' 80 +} + +# ====== +# SCRIPT +# # ====== + +# Display initial disk space stats + +AVAILABLE_INITIAL=$(getAvailableSpace) +AVAILABLE_ROOT_INITIAL=$(getAvailableSpace '/') + +printDH "BEFORE CLEAN-UP:" +echo "" + + +# Remove Android library +BEFORE=$(getAvailableSpace) + +sudo rm -rf /usr/local/lib/android || true + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Android library" + +# Remove .NET runtime + +BEFORE=$(getAvailableSpace) + +# https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11 +sudo rm -rf /usr/share/dotnet || true + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED ".NET runtime" + +# Remove Haskell runtime +BEFORE=$(getAvailableSpace) + +sudo rm -rf /opt/ghc || true +sudo rm -rf /usr/local/.ghcup || true + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Haskell runtime" + +# Remove large packages +# REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh + +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 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)) +printSavedSpace $SAVED "Large misc. packages" + +# Remove Docker images + +BEFORE=$(getAvailableSpace) + +sudo docker image prune --all --force || true + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Docker images" + +# Remove tool cache +# REF: https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159 + +BEFORE=$(getAvailableSpace) + +sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Tool cache" + +# Remove Swap storage + +BEFORE=$(getAvailableSpace) + +sudo swapoff -a || true +sudo rm -f /mnt/swapfile || true +free -h + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Swap storage" + + +# Output saved space statistic + +AVAILABLE_END=$(getAvailableSpace) +AVAILABLE_ROOT_END=$(getAvailableSpace '/') + +echo "" +printDH "AFTER CLEAN-UP:" + +echo "" +echo "" + +echo "/dev/root:" +printSavedSpace $((AVAILABLE_ROOT_END - AVAILABLE_ROOT_INITIAL)) +echo "overall:" +printSavedSpace $((AVAILABLE_END - AVAILABLE_INITIAL)) From a0665ac79ca5122a619d07744b8efd20aabc5083 Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 10 Dec 2024 23:28:47 +0000 Subject: [PATCH 2/9] Replace usage of free-disk-space github action with free-disk-space script --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6df348b72140..b712760b998a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,7 +109,7 @@ jobs: # intensive jobs to run on free runners, which however also have # less disk space. - name: free up disk space - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be + run: src/ci/scripts/free-disk-space.sh if: matrix.free_disk # Rust Log Analyzer can't currently detect the PR number of a GitHub From 2d374ca4fd9e7867442ce69f00eab2d3eaf960b2 Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 11 Dec 2024 00:37:27 +0000 Subject: [PATCH 3/9] Undo linting changes --- src/ci/scripts/free-disk-space.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index 706ccaeb67f4e..50be23602fa5e 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -23,11 +23,10 @@ printSeparationLine() { # macro to compute available space # REF: https://unix.stackexchange.com/a/42049/60849 # REF: https://stackoverflow.com/a/450821/408734 -getAvailableSpace() { df -a "$1" | awk 'NR > 1 {avail+=$4} END {print avail}'; } - +getAvailableSpace() { echo $(df -a $1 | awk 'NR > 1 {avail+=$4} END {print avail}'); } # macro to make Kb human readable (assume the input is Kb) # REF: https://unix.stackexchange.com/a/44087/60849 -formatByteCount() { numfmt --to=iec-i --suffix=B --padding=7 "$1"'000'; } +formatByteCount() { echo $(numfmt --to=iec-i --suffix=B --padding=7 $1'000'); } # macro to output saved space printSavedSpace() { From de0761bcb49f2fbbdf2c74427d6134f65fd4cc15 Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 11 Dec 2024 19:36:23 +0000 Subject: [PATCH 4/9] Remove snapd and microsoft-edge-stable --- src/ci/scripts/free-disk-space.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index 50be23602fa5e..ae95c65e37dca 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -120,6 +120,8 @@ sudo apt-get remove -y '^mysql-.*' --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 || 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..." From 6b53cfb1c519be382b2eee7a214a503a78d656a0 Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 11 Dec 2024 22:54:34 +0000 Subject: [PATCH 5/9] Reattempt to speed up deleting --- src/ci/scripts/free-disk-space.sh | 46 +++++++++++++++++++------------ 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index ae95c65e37dca..f5081d3dea662 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -5,6 +5,18 @@ # 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() { @@ -79,7 +91,7 @@ echo "" # Remove Android library BEFORE=$(getAvailableSpace) -sudo rm -rf /usr/local/lib/android || true +fast_rmdir /usr/local/lib/android || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -90,7 +102,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 +fast_rmdir /usr/share/dotnet || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -99,8 +111,8 @@ printSavedSpace $SAVED ".NET runtime" # Remove Haskell runtime BEFORE=$(getAvailableSpace) -sudo rm -rf /opt/ghc || true -sudo rm -rf /usr/local/.ghcup || true +fast_rmdir /opt/ghc || true +fast_rmdir /usr/local/.ghcup || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -111,19 +123,19 @@ 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..." -sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..." +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..." AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) From 03ccfd403e8e841b6bf8751e6b6b409e58132107 Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 11 Dec 2024 23:14:05 +0000 Subject: [PATCH 6/9] Attempt to free more disk space --- src/ci/scripts/free-disk-space.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index f5081d3dea662..c7f206b8fe4a9 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -88,6 +88,23 @@ printDH "BEFORE CLEAN-UP:" echo "" +fast_rmdir /usr/local/share/boost || true +fast_rmdir "$AGENT_TOOLSDIRECTORY" || true +fast_rmdir /opt/hostedtoolcache || true +fast_rmdir /usr/local/graalvm || true +fast_rmdir /usr/local/share/powershell || true +fast_rmdir /usr/local/share/chromium || true +fast_rmdir /usr/local/lib/node_modules || true + + +BEFORE=$(getAvailableSpace) + +fast_rmdir /usr/share/swift || true + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Swift" + # Remove Android library BEFORE=$(getAvailableSpace) From ce5b7e57656f8b3e7fafda4c05c060bd5748f0f9 Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 11 Dec 2024 23:23:31 +0000 Subject: [PATCH 7/9] Add before and after measurements --- src/ci/scripts/free-disk-space.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index c7f206b8fe4a9..3164f9d947f85 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -87,15 +87,37 @@ AVAILABLE_ROOT_INITIAL=$(getAvailableSpace '/') printDH "BEFORE CLEAN-UP:" echo "" +BEFORE=$(getAvailableSpace) -fast_rmdir /usr/local/share/boost || true fast_rmdir "$AGENT_TOOLSDIRECTORY" || true -fast_rmdir /opt/hostedtoolcache || true -fast_rmdir /usr/local/graalvm || true + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Agent tools" + +BEFORE=$(getAvailableSpace) + fast_rmdir /usr/local/share/powershell || true + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Powershell" + +BEFORE=$(getAvailableSpace) + fast_rmdir /usr/local/share/chromium || true + +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Chromium" + +BEFORE=$(getAvailableSpace) + fast_rmdir /usr/local/lib/node_modules || true +AFTER=$(getAvailableSpace) +SAVED=$((AFTER-BEFORE)) +printSavedSpace $SAVED "Node modules" BEFORE=$(getAvailableSpace) From b2911036fa00a3988294e595348af253f59c9ab9 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 13 Dec 2024 20:34:15 +0000 Subject: [PATCH 8/9] Revert "Reattempt to speed up deleting" This reverts commit 6b53cfb1c519be382b2eee7a214a503a78d656a0. --- src/ci/scripts/free-disk-space.sh | 58 ++++++++++++------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index 3164f9d947f85..3f516042caf27 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -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() { @@ -89,7 +77,7 @@ echo "" BEFORE=$(getAvailableSpace) -fast_rmdir "$AGENT_TOOLSDIRECTORY" || true +sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -97,7 +85,7 @@ 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)) @@ -105,7 +93,7 @@ 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)) @@ -113,7 +101,7 @@ 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)) @@ -121,7 +109,7 @@ printSavedSpace $SAVED "Node modules" BEFORE=$(getAvailableSpace) -fast_rmdir /usr/share/swift || true +sudo rm -rf /usr/share/swift || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -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)) @@ -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)) @@ -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)) @@ -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)) @@ -206,7 +194,7 @@ printSavedSpace $SAVED "Tool cache" BEFORE=$(getAvailableSpace) sudo swapoff -a || true -sudo rm -f /mnt/swapfile || true +sudo rm -rf /mnt/swapfile || true free -h AFTER=$(getAvailableSpace) From 101becaf2d2e1567eef458e19d85fb007d8ddc89 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 13 Dec 2024 22:07:04 +0000 Subject: [PATCH 9/9] Fix line length linter warnings --- src/ci/scripts/free-disk-space.sh | 67 +++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index 3f516042caf27..771f1354434af 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -150,19 +150,60 @@ 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..." -sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] 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 --fix-missing \ + || echo "::warning::The command [sudo apt-get remove -y azure-cli --fix-missing] \ + failed to complete successfully. Proceeding..." +sudo apt-get remove -y google-cloud-sdk --fix-missing \ + || echo "::warning::The command [sudo apt-get remove -y google-chrome-stable --fix-missing] \ + failed to complete successfully. Proceeding..." +sudo apt-get remove -y firefox --fix-missing \ + || echo "::warning::The command [sudo apt-get remove -y firefox --fix-missing] \ + failed to complete successfully. Proceeding..." +sudo apt-get remove -y powershell --fix-missing \ + || echo "::warning::The command [sudo apt-get remove -y powershell --fix-missing] \ + failed to complete successfully. Proceeding..." +sudo apt-get remove -y mono-devel --fix-missing \ + || echo "::warning::The command [sudo apt-get remove -y mono-devel --fix-missing] \ + failed to complete successfully. Proceeding..." +sudo apt-get remove -y libgl1-mesa-dri --fix-missing \ + || echo "::warning::The command [sudo apt-get remove -y 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))