Skip to content

Commit 475d80b

Browse files
committed
Auto merge of rust-lang#136247 - marcoieni:free-more-space-ubuntu-24, r=<try>
[experiment] ci: free more space in ubuntu 24 free runners try-job: x86_64-gnu-debug try-job: armhf-gnu try-job: dist-powerpc64le-linux try-job: dist-ohos
2 parents e6f12c8 + 08e10c4 commit 475d80b

File tree

2 files changed

+81
-42
lines changed

2 files changed

+81
-42
lines changed

src/ci/github-actions/jobs.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ runners:
55
env: { }
66

77
- &job-linux-4c
8-
os: ubuntu-22.04
8+
os: ubuntu-24.04
99
# Free some disk space to avoid running out of space during the build.
1010
free_disk: true
1111
<<: *base-job
@@ -46,7 +46,7 @@ runners:
4646
- &job-aarch64-linux
4747
# Free some disk space to avoid running out of space during the build.
4848
free_disk: true
49-
os: ubuntu-22.04-arm
49+
os: ubuntu-24.04-arm
5050

5151
- &job-aarch64-linux-8c
5252
os: ubuntu-22.04-arm64-8core-32gb
@@ -178,7 +178,7 @@ auto:
178178
<<: *job-linux-4c
179179

180180
- name: dist-powerpc64le-linux
181-
<<: *job-linux-4c-largedisk
181+
<<: *job-linux-4c
182182

183183
- name: dist-riscv64-linux
184184
<<: *job-linux-4c
@@ -291,7 +291,7 @@ auto:
291291
- name: x86_64-gnu-debug
292292
# This seems to be needed because a full stage 2 build + run-make tests
293293
# overwhelms the storage capacity of the standard 4c runner.
294-
<<: *job-linux-4c-largedisk
294+
<<: *job-linux-4c
295295

296296
- name: x86_64-gnu-distcheck
297297
<<: *job-linux-8c

src/ci/scripts/free-disk-space.sh

+77-38
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/bin/bash
2+
set -euo pipefail
23

34
# Free disk space on Linux GitHub action runners
45
# Script inspired by https://github.com/jlumbroso/free-disk-space
56

7+
# When updating to a new ubuntu version:
8+
# - Check that there are no docker images preinstalled with `docker image ls`
9+
# - Check that there are no big packages preinstalled that we aren't using
10+
611
# print a line of the specified character
712
printSeparationLine() {
813
for ((i = 0; i < 80; i++)); do
@@ -14,11 +19,15 @@ printSeparationLine() {
1419
# compute available space
1520
# REF: https://unix.stackexchange.com/a/42049/60849
1621
# REF: https://stackoverflow.com/a/450821/408734
17-
getAvailableSpace() { echo $(df -a | awk 'NR > 1 {avail+=$4} END {print avail}'); }
22+
getAvailableSpace() {
23+
df -a | awk 'NR > 1 {avail+=$4} END {print avail}'
24+
}
1825

1926
# make Kb human readable (assume the input is Kb)
2027
# REF: https://unix.stackexchange.com/a/44087/60849
21-
formatByteCount() { echo $(numfmt --to=iec-i --suffix=B --padding=7 $1'000'); }
28+
formatByteCount() {
29+
numfmt --to=iec-i --suffix=B --padding=7 "$1"'000'
30+
}
2231

2332
# macro to output saved space
2433
printSavedSpace() {
@@ -58,11 +67,35 @@ removeDir() {
5867
dir=${1}
5968

6069
local before
61-
before=$(getAvailableSpace)
70+
if [ ! -d "$dir" ]; then
71+
echo "::warning::Directory $dir does not exist, skipping."
72+
else
73+
before=$(getAvailableSpace)
74+
sudo rm -rf "$dir"
75+
printSavedSpace "$before" "Removed $dir"
76+
fi
77+
}
78+
79+
removeUnusedDirectories() {
80+
local dirs_to_remove=(
81+
"/usr/local/lib/android"
82+
"/etc/mysql"
83+
"/usr/share/php"
84+
85+
# Haskell runtime
86+
"/usr/local/.ghcup"
6287

63-
sudo rm -rf "$dir" || true
88+
# Azure
89+
"/opt/az"
90+
"/usr/share/az_"*
6491

65-
printSavedSpace "$before" "$dir"
92+
# Environemnt variable set by GitHub Actions
93+
"$AGENT_TOOLSDIRECTORY"
94+
)
95+
96+
for dir in "${dirs_to_remove[@]}"; do
97+
removeDir "$dir"
98+
done
6699
}
67100

68101
execAndMeasureSpaceChange() {
@@ -79,34 +112,46 @@ execAndMeasureSpaceChange() {
79112
# Remove large packages
80113
# REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
81114
cleanPackages() {
82-
sudo apt-get -qq remove -y --fix-missing \
83-
'^aspnetcore-.*' \
84-
'^dotnet-.*' \
85-
'^llvm-.*' \
86-
'php.*' \
87-
'^mongodb-.*' \
88-
'^mysql-.*' \
89-
'azure-cli' \
90-
'google-chrome-stable' \
91-
'firefox' \
92-
'powershell' \
93-
'mono-devel' \
94-
'libgl1-mesa-dri' \
95-
'google-cloud-sdk' \
96-
'google-cloud-cli'
97-
115+
sudo apt-get purge -y --autoremove --fix-missing \
116+
'.*-icon-theme$' \
117+
'^aspnetcore-.*' \
118+
'^dotnet-.*' \
119+
'^java-*' \
120+
'^libllvm.*' \
121+
'^llvm-.*' \
122+
'^mercurial.*' \
123+
'^mysql-.*' \
124+
'^vim.*' \
125+
'^fonts-.*' \
126+
'azure-cli' \
127+
'buildah' \
128+
'cpp-13' \
129+
'firefox' \
130+
'gcc-12' \
131+
'gcc-13' \
132+
'gcc-14' \
133+
'gcc' \
134+
'g++-14' \
135+
'gfortran-14' \
136+
'google-chrome-stable' \
137+
'google-cloud-cli' \
138+
'groff-base' \
139+
'kubectl' \
140+
'libgl1-mesa-dri' \
141+
'microsoft-edge-stable' \
142+
'php.*' \
143+
'podman' \
144+
'powershell' \
145+
'skopeo' \
146+
'snapd' \
147+
'tmux'
148+
149+
echo "=> apt-get autoremove"
98150
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed"
151+
echo "=> apt-get clean"
99152
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed failed"
100153
}
101154

102-
# Remove Docker images
103-
cleanDocker() {
104-
echo "Removing the following docker images:"
105-
sudo docker image ls
106-
echo "Removing docker images..."
107-
sudo docker image prune --all --force || true
108-
}
109-
110155
# Remove Swap storage
111156
cleanSwap() {
112157
sudo swapoff -a || true
@@ -121,17 +166,11 @@ AVAILABLE_INITIAL=$(getAvailableSpace)
121166
printDF "BEFORE CLEAN-UP:"
122167
echo ""
123168

124-
removeDir /usr/local/lib/android
125-
removeDir /usr/share/dotnet
126-
127-
# Haskell runtime
128-
removeDir /opt/ghc
129-
removeDir /usr/local/.ghcup
130-
131-
execAndMeasureSpaceChange cleanPackages "Large misc. packages"
132-
execAndMeasureSpaceChange cleanDocker "Docker images"
169+
execAndMeasureSpaceChange cleanPackages "Unused packages"
133170
execAndMeasureSpaceChange cleanSwap "Swap storage"
134171

172+
removeUnusedDirectories
173+
135174
# Output saved space statistic
136175
echo ""
137176
printDF "AFTER CLEAN-UP:"

0 commit comments

Comments
 (0)