get weird with it

This commit is contained in:
Daylin Morgan 2024-06-14 15:02:01 -05:00
parent e4d08c4195
commit 0b1e72fbc2
Signed by: daylin
GPG key ID: 950D13E9719334AD
3 changed files with 45 additions and 73 deletions

View file

@ -1,6 +1,16 @@
name: 'Maximize build disk space'
description: 'Maximize the available disk space by removing unneeded software'
inputs:
purge-packages:
description: whether to remove apt packages
required: false
default: 'true'
apt-manifest-url:
description: url to apt-package manifest (default ubuntu-22.04.4)
required: false
default: 'https://releases.ubuntu.com/jammy/ubuntu-22.04.4-live-server-amd64.manifest'
runs:
using: "composite"
steps:
@ -10,39 +20,40 @@ runs:
echo "==> Available space before cleanup"
echo
df -h
# sudo du /usr/local -h --max-depth=1 | sort -rh || true
- name: Maximize build disk space
shell: bash
run: |
set -euo pipefail
non_manifest_packages() {
comm -2 -3 \
<(sudo apt-mark showmanual | sort) \
<(curl --silent "${{ inputs.apt-manifest-url }}" | grep --perl-regexp --only-matching '^[\w-.+]+' | sort)
}
echo "Removing unwanted software... "
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache
sudo docker image prune --all --force > /dev/null
sudo rm -rf /usr/local
sudo apt-get remove -y '^aspnetcore-.*' > /dev/null
sudo apt-get remove -y '^dotnet-.*' > /dev/null
sudo apt-get remove -y '^llvm-.*' > /dev/null
sudo apt-get remove -y 'php.*' > /dev/null
sudo apt-get remove -y '^mongodb-.*' > /dev/null
sudo apt-get remove -y '^mysql-.*' > /dev/null
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing > /dev/null
sudo apt-get remove -y google-cloud-sdk --fix-missing > /dev/null
sudo apt-get remove -y google-cloud-cli --fix-missing > /dev/null
sudo apt-get autoremove -y > /dev/null
sudo apt-get clean > /dev/null
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /opt &
sudo rm -rf "$AGENT_TOOLSDIRECTORY" &
sudo swapoff -a
sudo rm -f /mnt/swapfile
free -h
if [[ "${{ inputs.purge-packages }}" == 'true' ]]; then
sudo apt-get purge \
--allow-remove-essential \
-q \
$(non_manifest_packages) &
fi
wait
sudo rm -rf /var/lib/docker &
sudo rm -rf /usr/{local,share} &
{
sudo swapoff -a
sudo rm -f /mnt/swapfile
} &
wait
echo "... done"
- name: Disk space report after modification

View file

@ -4,9 +4,9 @@ on:
workflow_dispatch:
inputs:
host:
description: 'host name to build'
description: 'list of hosts to build'
required: true
default: 'othalan'
default: 'othalan algiz'
type: string
lockFile:
description: 'flake.lock file'
@ -15,9 +15,9 @@ on:
workflow_call:
inputs:
host:
description: 'host name to build'
description: 'list of hosts to build'
required: true
default: 'othalan'
default: 'othalan aligz'
type: string
@ -29,40 +29,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
# # The default disk size of these runners is ~14GB
# # Cleanup the disk, see upstream discussion https://github.com/actions/runner-images/issues/2840.
# - name: Cleanup Disk Space
# run: |
# echo "Before removing files:"
# df -h
# sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# sudo rm -rf /opt
# sudo rm -rf /usr/share/dotnet
# sudo rm -rf /usr/local/{lib/android,share/boost}
# sudo docker image prune --all --force
# echo "After removing files:"
# df -h
- name: Maximize build space
uses: AdityaGarg8/remove-unwanted-software@v3
with:
remove-android: 'true'
remove-dotnet: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
remove-large-packages: 'true'
remove-cached-tools: 'true'
remove-swapfile: 'true'
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
echo "Free space:"
df -h
- uses: actions/checkout@v4
- uses: ./.github/actions/clean-disk
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@v7
@ -80,4 +50,6 @@ jobs:
- name: Build
run: |
nix run . --accept-flake-config -- cache --host "${{ inputs.host }}" --flake .
for host in ${{ inputs.host }}; do
nix run . --accept-flake-config -- cache --host "$host" --flake .
done

View file

@ -16,22 +16,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
# The default disk size of these runners is ~14GB
# Cleanup the disk, see upstream discussion https://github.com/actions/runner-images/issues/2840.
# - name: Cleanup Disk Space
# run: |
# echo "Before removing files:"
# df -h
# sudo rm -rf /usr/share/dotnet
# sudo rm -rf /opt/ghc
# sudo rm -rf /opt
# sudo rm -rf "/usr/local/share/boost"
# sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# echo "After removing files:"
# df -h
- uses: actions/checkout@v4
- uses: ./.github/actions/clean-disk
with:
purge-packages: false
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@v7