@@ -96,32 +96,25 @@ removeUnusedFilesAndDirs() {
9696 )
9797
9898 if isGitHubRunner; then
99+ # Paths common to all runners (both x86 and ARM)
99100 to_remove+=(
100101 " /usr/local/aws-sam-cli"
101102 " /usr/local/doc/cmake"
102- " /usr/local/julia" *
103- " /usr/local/lib/android"
104- " /usr/local/share/chromedriver-" *
105- " /usr/local/share/chromium"
106103 " /usr/local/share/cmake-" *
107- " /usr/local/share/edge_driver"
108104 " /usr/local/share/emacs"
109105 " /usr/local/share/gecko_driver"
110106 " /usr/local/share/icons"
111107 " /usr/local/share/powershell"
112108 " /usr/local/share/vcpkg"
113109 " /usr/local/share/vim"
114110 " /usr/share/apache-maven-" *
115- " /usr/share/gradle-" *
116111 " /usr/share/kotlinc"
117- " /usr/share/miniconda"
118112 " /usr/share/php"
119113 " /usr/share/ri"
120114 " /usr/share/swift"
121115
122116 # binaries
123117 " /usr/local/bin/azcopy"
124- " /usr/local/bin/bicep"
125118 " /usr/local/bin/ccmake"
126119 " /usr/local/bin/cmake-" *
127120 " /usr/local/bin/cmake"
@@ -135,16 +128,53 @@ removeUnusedFilesAndDirs() {
135128 " /usr/local/bin/phpunit"
136129 " /usr/local/bin/pulumi-" *
137130 " /usr/local/bin/pulumi"
138- " /usr/local/bin/stack"
139-
140- # Haskell runtime
141- " /usr/local/.ghcup"
142131
143132 # Azure
144133 " /opt/az"
145134 " /usr/share/az_" *
135+
136+ # Microsoft Edge and powershell
137+ " /opt/microsoft"
138+
139+ " /opt/pipx"
140+ " /opt/pipx_bin"
141+ )
142+
143+ # Paths only present in x86 runners
144+ local github_runner_x86_paths=(
145+ " /usr/local/julia" *
146+ " /usr/local/lib/android"
147+ " /usr/local/share/chromedriver-" *
148+ " /usr/local/share/chromium"
149+ " /usr/local/share/edge_driver"
150+ " /usr/share/gradle-" *
151+ " /usr/share/miniconda"
152+
153+ # binaries
154+ " /usr/local/bin/bicep"
155+ " /usr/local/bin/stack"
156+
157+ # Haskell runtime
158+ " /usr/local/.ghcup"
146159 )
147160
161+ if isX86; then
162+ to_remove+=(" ${github_runner_x86_paths[@]} " )
163+ else
164+ # warn if x86-only paths are present in other runners
165+ local existing_github_runner_x86_paths=()
166+ local x86_path
167+ for x86_path in " ${github_runner_x86_paths[@]} " ; do
168+ if [ -e " $x86_path " ]; then
169+ existing_github_runner_x86_paths+=(" $x86_path " )
170+ fi
171+ done
172+
173+ if [ " ${# existing_github_runner_x86_paths[@]} " -ne 0 ]; then
174+ echo " ::warning::You can remove the following paths to save space: ${existing_github_runner_x86_paths[*]} "
175+ fi
176+ fi
177+
148178 if [ -n " ${AGENT_TOOLSDIRECTORY:- } " ]; then
149179 # Environment variable set by GitHub Actions
150180 to_remove+=(
@@ -201,10 +231,22 @@ cleanPackages() {
201231 ' ^dotnet-.*'
202232 ' ^llvm-.*'
203233 ' ^mongodb-.*'
234+ ' ^temurin-.*-jdk'
235+ ' buildah'
204236 ' firefox'
237+ ' google-cloud-cli'
238+ ' google-cloud-sdk'
239+ ' kubectl'
205240 ' libgl1-mesa-dri'
206241 ' mono-devel'
207242 ' php.*'
243+ ' podman'
244+ ' skopeo'
245+ )
246+ local x86_only_packages=(
247+ ' google-chrome-stable'
248+ ' microsoft-edge-stable'
249+ ' powershell'
208250 )
209251
210252 if isGitHubRunner; then
@@ -213,12 +255,20 @@ cleanPackages() {
213255 )
214256
215257 if isX86; then
216- packages+=(
217- ' google-chrome-stable'
218- ' google-cloud-cli'
219- ' google-cloud-sdk'
220- ' powershell'
221- )
258+ packages+=(" ${x86_only_packages[@]} " )
259+ else
260+ # warn if x86-only packages are installed on other runners
261+ local installed_x86_only_packages=()
262+ local package
263+ for package in " ${x86_only_packages[@]} " ; do
264+ if dpkg-query -W -f=' ${binary:Package}\n' " $package " > /dev/null 2>&1 ; then
265+ installed_x86_only_packages+=(" $package " )
266+ fi
267+ done
268+
269+ if [ " ${# installed_x86_only_packages[@]} " -ne 0 ]; then
270+ echo " ::warning::You can remove the following packages to save space: ${installed_x86_only_packages[*]} "
271+ fi
222272 fi
223273 else
224274 packages+=(
@@ -235,11 +285,19 @@ cleanPackages() {
235285 || echo " ::warning::The command [sudo apt-get clean] failed"
236286}
237287
238- # Remove Docker images.
239- # Ubuntu 22 runners have docker images already installed.
240- # They aren't present in ubuntu 24 runners.
288+ # Remove preinstalled Docker images.
241289cleanDocker () {
290+ local images
291+ images=$( sudo docker image ls -q)
292+
293+ if [ -z " $images " ]; then
294+ echo " => No docker images to remove."
295+ return
296+ fi
297+
242298 echo " => Removing the following docker images:"
299+ # Use "docker image ls" without "-q" to get the full table output which contains
300+ # also the image names and sizes.
243301 sudo docker image ls
244302 echo " => Removing docker images..."
245303 sudo docker image prune --all --force || true
@@ -253,7 +311,8 @@ cleanSwap() {
253311}
254312
255313sufficientSpaceEarlyExit () {
256- local available_space_kb=$( df -k . --output=avail | tail -n 1)
314+ local available_space_kb
315+ available_space_kb=$( df -k . --output=avail | tail -n 1)
257316
258317 if [ " $available_space_kb " -ge " $space_target_kb " ]; then
259318 echo " Sufficient disk space available (${available_space_kb} KB >= ${space_target_kb} KB). Skipping cleanup."
@@ -267,7 +326,8 @@ sufficientSpaceEarlyExit() {
267326checkAlternative () {
268327 local gha_alt_disk=" /mnt"
269328
270- local available_space_kb=$( df -k " $gha_alt_disk " --output=avail | tail -n 1)
329+ local available_space_kb
330+ available_space_kb=$( df -k " $gha_alt_disk " --output=avail | tail -n 1)
271331
272332 # mount options that trade durability for performance
273333 # ignore-tidy-linelength
@@ -276,7 +336,8 @@ checkAlternative() {
276336 # GHA has a 2nd disk mounted at /mnt that is almost empty.
277337 # Check if it's a valid mountpoint and it has enough available space.
278338 if mountpoint " $gha_alt_disk " && [ " $available_space_kb " -ge " $space_target_kb " ]; then
279- local blkdev=$( df -k " $gha_alt_disk " --output=source | tail -n 1)
339+ local blkdev
340+ blkdev=$( df -k " $gha_alt_disk " --output=source | tail -n 1)
280341 echo " Sufficient space available on $blkdev mounted at $gha_alt_disk "
281342 # see cleanSwap(), swapfile may be mounted under /mnt
282343 sudo swapoff -a || true
0 commit comments