diff --git a/.github/scripts/cli-create-lvm.sh b/.github/scripts/cli-create-lvm.sh new file mode 100755 index 000000000..a28fbe27d --- /dev/null +++ b/.github/scripts/cli-create-lvm.sh @@ -0,0 +1,64 @@ +#!/bin/bash +########################################### +## GitHub runner create LVM volume merging /mnt with / for more space +## +## Written: Jordan Carlin, jcarlin@hmc.edu +## Created: 30 Jan 2025 +## Based on https://github.com/easimon/maximize-build-space/blob/master/action.yml +## +## Purpose: Combine free space from multiple disks into a single logical volume for GitHub Actions runner +## A component of the CORE-V-WALLY configurable RISC-V project. +## https://github.com/openhwgroup/cvw +## +## Copyright (C) 2021-25 Harvey Mudd College & Oklahoma State University +## +## SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +## +## Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +## except in compliance with the License, or, at your option, the Apache License version 2.0. You +## may obtain a copy of the License at +## +## https:##solderpad.org/licenses/SHL-2.1/ +## +## Unless required by applicable law or agreed to in writing, any work distributed under the +## License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +## either express or implied. See the License for the specific language governing permissions +## and limitations under the License. +################################################################################################ + +ROOT_SAVE_SPACE="${1:-20}" # in GB, needed for installing packages, etc. +MOUNT="${2:-$GITHUB_WORKSPACE}" + +# First disable and remove swap file on /mnt +sudo swapoff -a +sudo rm -f /mnt/swapfile + +# Create / LVM physical volume +ROOT_FREE_SPACE=$(df --block-size=1024 --output=avail / | tail -1) +ROOT_LVM_SIZE=$(((ROOT_FREE_SPACE - (ROOT_SAVE_SPACE * 1024 * 1024)) * 1024)) +sudo touch /pv.img && sudo fallocate -z -l $ROOT_LVM_SIZE /pv.img +ROOT_LOOP_DEV=$(sudo losetup --find --show /pv.img) +sudo pvcreate -f "$ROOT_LOOP_DEV" + +# Create /mnt LVM physical volume +MNT_FREE_SPACE=$(df --block-size=1024 --output=avail /mnt | tail -1) +MNT_LVM_SIZE=$(((MNT_FREE_SPACE - (1 * 1024)) * 1024)) # Leave 1MB free on /mnt +sudo touch /mnt/pv.img && sudo fallocate -z -l $MNT_LVM_SIZE /mnt/pv.img +MNT_LOOP_DEV=$(sudo losetup --find --show /mnt/pv.img) +sudo pvcreate -f "$MNT_LOOP_DEV" + +# Create LVM volume group +sudo vgcreate runnervg "$ROOT_LOOP_DEV" "$MNT_LOOP_DEV" + +# Recreate swap +sudo lvcreate -L 4G -n swap runnervg +sudo mkswap /dev/mapper/runnervg-swap +sudo swapon /dev/mapper/runnervg-swap + +# Create LVM logical volume +sudo lvcreate -l 100%FREE -n runnerlv runnervg +sudo mkfs.ext4 /dev/mapper/runnervg-runnerlv +sudo mkdir -p "$MOUNT" +sudo mount /dev/mapper/runnervg-runnerlv "$MOUNT" +sudo chown runner:runner "$MOUNT" +sudo rm -rf "$MOUNT/lost+found" diff --git a/.github/cli-space-cleanup.sh b/.github/scripts/cli-space-cleanup.sh similarity index 100% rename from .github/cli-space-cleanup.sh rename to .github/scripts/cli-space-cleanup.sh diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 10e36cbab..00d72ee50 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -127,9 +127,11 @@ jobs: run: | df -h if [ -z ${{ matrix.image }} ]; then - ./.github/cli-space-cleanup.sh + ./.github/scripts/cli-space-cleanup.sh + ./.github/scripts/cli-create-lvm.sh else - nsenter -t 1 -m -u -n -i bash -c "$(cat .github/cli-space-cleanup.sh)" + nsenter -t 1 -m -u -n -i bash -c "$(cat .github/scripts/cli-space-cleanup.sh)" + nsenter -t 1 -m -u -n -i bash -c "$(cat .github/scripts/cli-create-lvm.sh)" fi df -h # Run main tool chain installation script, either as a user or system wide @@ -159,16 +161,16 @@ jobs: with: name: installation-logs-${{ matrix.name }} path: ${{ env.RISCV }}/logs/ + # Only the linux-testvectors are needed, so remove the rest of the buildroot to save space + - name: Remove Buildroot to Save Space + run: | + rm -rf $RISCV/buildroot/ || sudo rm -rf $RISCV/ + df -h # Make riscof and zsbl only as that is the only testsuite used by standard regression - name: make tests run: | source setup.sh make riscof zsbl --jobs $(nproc --ignore 1) - # Only the linux-testvectors are needed, so remove the rest of the buildroot to save space - - name: Remove Buildroot to Save Space - run: | - rm -rf $RISCV/buildroot/output/build || sudo rm -rf $RISCV/buildroot/output/build - df -h # Run standard regression, skipping distros that are known to be broken with Verilator - name: Regression if: ${{ matrix.regressionFail != true }}