@@ -69,31 +69,75 @@ printDF() {
69
69
printSeparationLine " ="
70
70
}
71
71
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" *
87
78
" /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"
89
115
90
116
# Haskell runtime
91
117
" /usr/local/.ghcup"
118
+
119
+ # Azure
120
+ " /opt/az"
121
+ " /usr/share/az_" *
122
+
123
+ # Environment variable set by GitHub Actions
124
+ " $AGENT_TOOLSDIRECTORY "
92
125
)
93
126
94
- for dir in " ${dirs_to_remove[@]} " ; do
95
- removeDir " $dir "
127
+ # Filter existing files and directories because:
128
+ # - We don't know if GitHub guarantees the existence of these files and
129
+ # directories in the future and we don't want CI to fail in case
130
+ # a file or directory is removed from the runners.
131
+ # - Some files and directories don't exist on ARM runners because they have less software
132
+ # installed than x86 runners.
133
+ for element in " ${to_remove[@]} " ; do
134
+ if [ ! -e " $element " ]; then
135
+ echo " ::warning::Directory or file $element does not exist, skipping."
136
+ fi
96
137
done
138
+
139
+ # Remove all files and directories at once to save time.
140
+ sudo rm -rf " ${to_remove[@]} "
97
141
}
98
142
99
143
execAndMeasureSpaceChange () {
@@ -141,7 +185,9 @@ cleanPackages() {
141
185
sudo apt-get clean || echo " ::warning::The command [sudo apt-get clean] failed failed"
142
186
}
143
187
144
- # Remove Docker images
188
+ # Remove Docker images.
189
+ # Ubuntu 22 runners have docker images already installed.
190
+ # They aren't present in ubuntu 24 runners.
145
191
cleanDocker () {
146
192
echo " => Removing the following docker images:"
147
193
sudo docker image ls
@@ -166,8 +212,7 @@ echo ""
166
212
execAndMeasureSpaceChange cleanPackages " Unused packages"
167
213
execAndMeasureSpaceChange cleanDocker " Docker images"
168
214
execAndMeasureSpaceChange cleanSwap " Swap storage"
169
-
170
- removeUnusedDirectories
215
+ execAndMeasureSpaceChange removeUnusedFilesAndDirs " Unused files and directories"
171
216
172
217
# Output saved space statistic
173
218
echo " "
0 commit comments