From 0b1e72fbc2ce830018e721868d237a67dcba5d8c Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Fri, 14 Jun 2024 15:02:01 -0500 Subject: [PATCH] get weird with it --- .github/actions/clean-disk/action.yml | 59 ++++++++++++++++----------- .github/workflows/build.yml | 44 ++++---------------- .github/workflows/checks.yml | 15 +------ 3 files changed, 45 insertions(+), 73 deletions(-) diff --git a/.github/actions/clean-disk/action.yml b/.github/actions/clean-disk/action.yml index feff264..02f7782 100644 --- a/.github/actions/clean-disk/action.yml +++ b/.github/actions/clean-disk/action.yml @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e29093e..f9b834e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c48ebea..f2113c3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -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