Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free disk space on GHA worker nodes #19327

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inputs:
cache:
description: "Cache Maven repo (true/false/restore)"
default: true
cleanup-node:
description: "Clean up node (true/false) to increase free disk space"
default: false # Disabled by default as it adds ~4 minutes of test runtime. Should be enabled case by case.
download_dependencies:
description: "Download all Maven dependencies so Maven can work in offline mode"
default: true
Expand All @@ -33,6 +36,10 @@ runs:
- name: Fetch base ref to find merge-base for GIB
shell: bash
run: .github/bin/git-fetch-base-ref.sh
- name: Free additional disk space
if: ${{ format('{0}', inputs.cleanup-node) == 'true' }}
shell: bash
run: ./.github/bin/free-disk-space.sh
- uses: actions/setup-java@v3
if: ${{ inputs.java-version != '' }}
with:
Expand Down
14 changes: 0 additions & 14 deletions .github/bin/cleanup-node.sh

This file was deleted.

70 changes: 70 additions & 0 deletions .github/bin/free-disk-space.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash
set -euo pipefail

function list_installed_packages()
{
apt list --installed "$1" 2>/dev/null | awk -F'/' 'NR>1{print $1}' | tr '\n' ' '
}

function free_up_disk_space_ubuntu()
{
local packages=(
'azure-cli'
'aspnetcore-*'
'dotnet-*'
'firefox*'
'google-chrome-*'
'google-cloud-*'
'libmono-*'
'llvm-*'
'imagemagick'
'postgresql-*'
'rubu-*'
'spinxsearch'
'unixodbc-dev'
'mercurial'
'esl-erlang'
'microsoft-edge-stable'
'mono-*'
'msbuild'
'mysql-server-core-*'
'php-*'
'php7*'
'powershell*'
'mongo*'
'microsoft-edge*'
'subversion')

for package in "${packages[@]}"; do
installed_packages=$(list_installed_packages "${package}")
echo "Removing packages by pattern ${package}: ${installed_packages}"
sudo apt-get --auto-remove -y purge ${installed_packages}
done

echo "Autoremoving packages"
sudo apt-get autoremove -y

echo "Autocleaning"
sudo apt-get autoclean -y

echo "Removing toolchains"
sudo rm -rf \
/usr/local/graalvm \
/usr/local/lib/android/ \
/usr/share/dotnet/ \
/opt/ghc/ \
/usr/local/share/boost/ \
"${AGENT_TOOLSDIRECTORY}"

echo "Prune docker images"
sudo docker system prune --all -f
}

echo "Disk space usage before cleaning:"
df -k .

echo "Clearing up disk usage:"
free_up_disk_space_ubuntu

echo "Disk space usage after cleaning:"
df -k .
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ jobs:
github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.args.named.sha &&
format('refs/pull/{0}/head', github.event.client_payload.pull_request.number) || '' }}
- uses: ./.github/actions/setup
with:
cleanup-node: true
- name: Maven Install
run: |
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
Expand Down Expand Up @@ -436,6 +438,7 @@ jobs:
- uses: ./.github/actions/setup
with:
cache: restore
cleanup-node: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the equivalent of docker system prune?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does more things, see .github/bin/free-disk-space.sh for the impl.

- name: Maven Install
run: |
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
Expand Down Expand Up @@ -640,10 +643,7 @@ jobs:
with:
cache: restore
java-version: ${{ matrix.jdk != '' && matrix.jdk || '17' }}
- name: Cleanup node
# This is required as a virtual environment update 20210219.1 left too little space for MemSQL to work
if: matrix.modules == 'plugin/trino-singlestore'
run: .github/bin/cleanup-node.sh
cleanup-node: ${{ format('{0}', matrix.modules == 'plugin/trino-singlestore') }}
- name: Maven Install
run: |
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
Expand Down
Loading