Skip to content

Commit 7f38958

Browse files
committed
ci: remove more unused files and directories in free runners
1 parent 8c61cd4 commit 7f38958

File tree

1 file changed

+63
-21
lines changed

1 file changed

+63
-21
lines changed

Diff for: src/ci/scripts/free-disk-space.sh

+63-21
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,72 @@ printDF() {
6969
printSeparationLine "="
7070
}
7171

72-
removeDir() {
73-
dir=${1}
74-
75-
local before
76-
if [ ! -d "$dir" ]; then
77-
echo "::warning::Directory $dir does not exist, skipping."
78-
else
79-
before=$(getAvailableSpace)
80-
sudo rm -rf "$dir"
81-
printSavedSpace "$before" "Removed $dir"
82-
fi
83-
}
84-
85-
removeUnusedDirectories() {
86-
local dirs_to_remove=(
72+
removeUnusedFilesAndDirs() {
73+
local to_remove=(
74+
"/etc/mysql"
75+
"/usr/local/aws-sam-cli"
76+
"/usr/local/doc/cmake"
77+
"/usr/local/julia"*
8778
"/usr/local/lib/android"
88-
"/usr/share/dotnet"
79+
"/usr/local/share/chromedriver-"*
80+
"/usr/local/share/chromium"
81+
"/usr/local/share/cmake-"*
82+
"/usr/local/share/edge_driver"
83+
"/usr/local/share/gecko_driver"
84+
"/usr/local/share/icons"
85+
"/usr/local/share/vim"
86+
"/usr/local/share/emacs"
87+
"/usr/local/share/powershell"
88+
"/usr/local/share/vcpkg"
89+
"/usr/share/apache-maven-"*
90+
"/usr/share/gradle-"*
91+
"/usr/share/java"
92+
"/usr/share/kotlinc"
93+
"/usr/share/miniconda"
94+
"/usr/share/php"
95+
"/usr/share/ri"
96+
"/usr/share/swift"
97+
98+
# binaries
99+
"/usr/local/bin/azcopy"
100+
"/usr/local/bin/bicep"
101+
"/usr/local/bin/ccmake"
102+
"/usr/local/bin/cmake-"*
103+
"/usr/local/bin/cmake"
104+
"/usr/local/bin/cpack"
105+
"/usr/local/bin/ctest"
106+
"/usr/local/bin/helm"
107+
"/usr/local/bin/kind"
108+
"/usr/local/bin/kustomize"
109+
"/usr/local/bin/minikube"
110+
"/usr/local/bin/packer"
111+
"/usr/local/bin/phpunit"
112+
"/usr/local/bin/pulumi-"*
113+
"/usr/local/bin/pulumi"
114+
"/usr/local/bin/stack"
89115

90116
# Haskell runtime
91117
"/usr/local/.ghcup"
118+
119+
# Azure
120+
"/opt/az"
121+
"/usr/share/az_"*
122+
123+
# Environment variable set by GitHub Actions
124+
"$AGENT_TOOLSDIRECTORY"
92125
)
93126

94-
for dir in "${dirs_to_remove[@]}"; do
95-
removeDir "$dir"
127+
for element in "${to_remove[@]}"; do
128+
if [ ! -e "$element" ]; then
129+
# The file or directory doesn't exist.
130+
# Maybe it was removed in a newer version of the runner or it's not present in a
131+
# specific architecture (e.g. ARM).
132+
echo "::warning::Directory or file $element does not exist, skipping."
133+
fi
96134
done
135+
136+
# Remove all files and directories at once to save time.
137+
sudo rm -rf "${to_remove[@]}"
97138
}
98139

99140
execAndMeasureSpaceChange() {
@@ -141,7 +182,9 @@ cleanPackages() {
141182
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed failed"
142183
}
143184

144-
# Remove Docker images
185+
# Remove Docker images.
186+
# Ubuntu 22 runners have docker images already installed.
187+
# They aren't present in ubuntu 24 runners.
145188
cleanDocker() {
146189
echo "=> Removing the following docker images:"
147190
sudo docker image ls
@@ -166,8 +209,7 @@ echo ""
166209
execAndMeasureSpaceChange cleanPackages "Unused packages"
167210
execAndMeasureSpaceChange cleanDocker "Docker images"
168211
execAndMeasureSpaceChange cleanSwap "Swap storage"
169-
170-
removeUnusedDirectories
212+
execAndMeasureSpaceChange removeUnusedFilesAndDirs "Unused files and directories"
171213

172214
# Output saved space statistic
173215
echo ""

0 commit comments

Comments
 (0)