diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 7730d29d28f68..26e8c47ad2f5c 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -104,15 +104,6 @@ pr: - name: mingw-check-tidy continue_on_error: true <<: *job-linux-4c - - name: x86_64-gnu-llvm-18 - env: - ENABLE_GCC_CODEGEN: "1" - # We are adding (temporarily) a dummy commit on the compiler - READ_ONLY_SRC: "0" - DOCKER_SCRIPT: x86_64-gnu-llvm.sh - <<: *job-linux-16c - - name: x86_64-gnu-tools - <<: *job-linux-16c # Jobs that run when you perform a try build (@bors try) # These jobs automatically inherit envs.try, to avoid repeating @@ -182,7 +173,7 @@ auto: <<: *job-linux-4c - name: dist-powerpc64le-linux - <<: *job-linux-4c-largedisk + <<: *job-linux-4c - name: dist-riscv64-linux <<: *job-linux-4c @@ -295,7 +286,7 @@ auto: - name: x86_64-gnu-debug # This seems to be needed because a full stage 2 build + run-make tests # overwhelms the storage capacity of the standard 4c runner. - <<: *job-linux-4c-largedisk + <<: *job-linux-4c - name: x86_64-gnu-distcheck <<: *job-linux-8c diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index 4a7dad0090b2e..c3c01da646d32 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -euo pipefail # Free disk space on Linux GitHub action runners # Script inspired by https://github.com/jlumbroso/free-disk-space @@ -54,17 +55,6 @@ printDF() { printSeparationLine "=" } -removeDir() { - dir=${1} - - local before - before=$(getAvailableSpace) - - sudo rm -rf "$dir" || true - - printSavedSpace "$before" "$dir" -} - execAndMeasureSpaceChange() { local operation=${1} # Function to execute local title=${2} @@ -79,39 +69,107 @@ execAndMeasureSpaceChange() { # Remove large packages # REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh cleanPackages() { - sudo apt-get -qq remove -y --fix-missing \ - '^aspnetcore-.*' \ - '^dotnet-.*' \ - '^llvm-.*' \ - 'php.*' \ - '^mongodb-.*' \ - '^mysql-.*' \ - 'azure-cli' \ - 'google-chrome-stable' \ - 'firefox' \ - 'powershell' \ - 'mono-devel' \ - 'libgl1-mesa-dri' \ - 'google-cloud-sdk' \ - 'google-cloud-cli' + # Prevent npm from being removed. + # This command unfortunately also prevents npm from being updated, + # but it should be fine because we don't run `apt upgrade`. + sudo apt-mark hold npm + + sudo apt-get -qq purge -y --autoremove --fix-missing \ + '^aspnetcore-.*' \ + '^dotnet-.*' \ + '^java-*' \ + '^libllvm.*' \ + '^llvm.*' \ + '^mongodb-.*' \ + '^mysql-.*' \ + '^r-base.*' \ + '^vim.*' \ + 'azure-cli' \ + 'cpp-11' \ + 'firefox' \ + 'gcc-10' \ + 'gcc-11' \ + 'gcc-12' \ + 'gcc-9' \ + 'gcc' \ + 'google-chrome-stable' \ + 'google-cloud-cli' \ + 'google-cloud-sdk' \ + 'groff-base' \ + 'groff' \ + 'kubectl' \ + 'libgl1-mesa-dri' \ + 'libicu-dev' \ + 'mercurial-common' \ + 'microsoft-edge-stable' \ + 'mono-devel' \ + 'mono-llvm-tools' \ + 'php.*' \ + 'podman' \ + 'powershell' \ + 'python-babel-localedata' \ + 'python3-breezy' \ + 'skopeo' \ + 'snapd' \ + 'tmux' sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed" sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed failed" + + echo "=> Installed packages sorted by size:" + # sort always fails because `head` stops reading stdin + dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | + sort -nr 2>/dev/null | head -200 || true } # Remove Docker images cleanDocker() { - echo "Removing the following docker images:" + echo "=> Removing the following docker images:" sudo docker image ls - echo "Removing docker images..." + echo "=> Removing docker images..." sudo docker image prune --all --force || true } -# Remove Swap storage -cleanSwap() { - sudo swapoff -a || true - sudo rm -rf /mnt/swapfile || true - free -h +removeAllSnaps() { + # This won't remove the snaps `core` and `snapd` + sudo snap remove $(snap list | awk '!/^Name|^core|^snapd/ {print $1}') +} + +removeUnusedDirectories() { + local dirs_to_remove=( + "/usr/lib/heroku/" + "/usr/local/lib/android" + "/usr/local/share/chromium" + "/usr/local/share/powershell" + "/usr/share/az_"* + "/usr/local/share/cmake-"* + "/usr/share/dotnet" + "/usr/share/icons/" + "/usr/share/miniconda/" + "/usr/share/swift" + + # Environemnt variable set by GitHub Actions + "$AGENT_TOOLSDIRECTORY" + + # Haskell runtime + "/opt/ghc" + "/usr/local/.ghcup" + ) + local before + + for dir in "${dirs_to_remove[@]}"; do + if [ ! -d "$dir" ]; then + echo "::warning::Directory $dir does not exist, skipping." + continue + fi + before=$(getAvailableSpace) + sudo rm -rf "$dir" || true + printSavedSpace "$before" "Removed $dir" + done + + echo "=> largest directories:" + # sort always fails because `head` stops reading stdin + sudo du --max-depth=7 /* -h | sort -nr 2>/dev/null | head -1000 || true } # Display initial disk space stats @@ -121,16 +179,11 @@ AVAILABLE_INITIAL=$(getAvailableSpace) printDF "BEFORE CLEAN-UP:" echo "" -removeDir /usr/local/lib/android -removeDir /usr/share/dotnet - -# Haskell runtime -removeDir /opt/ghc -removeDir /usr/local/.ghcup - -execAndMeasureSpaceChange cleanPackages "Large misc. packages" +execAndMeasureSpaceChange removeAllSnaps "Snaps" +execAndMeasureSpaceChange cleanPackages "Unused packages" execAndMeasureSpaceChange cleanDocker "Docker images" -execAndMeasureSpaceChange cleanSwap "Swap storage" + +removeUnusedDirectories # Output saved space statistic echo ""