|
| 1 | +name: 'Bootc Ubuntu Setup' |
| 2 | +description: 'Default host setup' |
| 3 | +inputs: |
| 4 | + libvirt: |
| 5 | + description: 'Install libvirt and virtualization stack' |
| 6 | + required: false |
| 7 | + default: 'false' |
| 8 | +runs: |
| 9 | + using: 'composite' |
| 10 | + steps: |
| 11 | + # The default runners have TONS of crud on them... |
| 12 | + - name: Free up disk space on runner |
| 13 | + shell: bash |
| 14 | + run: | |
| 15 | + set -xeuo pipefail |
| 16 | + sudo df -h |
| 17 | + unwanted_pkgs=('^aspnetcore-.*' '^dotnet-.*' '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' |
| 18 | + azure-cli google-chrome-stable firefox mono-devel) |
| 19 | + unwanted_dirs=(/usr/share/dotnet /opt/ghc /usr/local/lib/android /opt/hostedtoolcache/CodeQL) |
| 20 | + # Start background removal operations as systemd units; if this causes |
| 21 | + # races in the future around disk space we can look at waiting for cleanup |
| 22 | + # before starting further jobs, but right now we spent a lot of time waiting |
| 23 | + # on the network and scripts and such below, giving these plenty of time to run. |
| 24 | + n=0 |
| 25 | + runcleanup() { |
| 26 | + sudo systemd-run -r -u action-cleanup-${n} -- "$@" |
| 27 | + n=$(($n + 1)) |
| 28 | + } |
| 29 | + runcleanup docker image prune --all --force |
| 30 | + for x in ${unwanted_dirs[@]}; do |
| 31 | + runcleanup rm -rf "$x" |
| 32 | + done |
| 33 | + # Apt removals in foreground, as we can't parallelize these |
| 34 | + for x in ${unwanted_pkgs[@]}; do |
| 35 | + /bin/time -f '%E %C' sudo apt-get remove -y $x |
| 36 | + done |
| 37 | + # We really want support for heredocs |
| 38 | + - name: Update podman and install just |
| 39 | + shell: bash |
| 40 | + run: | |
| 41 | + set -eux |
| 42 | + # Require the runner is ubuntu-24.04 |
| 43 | + IDV=$(. /usr/lib/os-release && echo ${ID}-${VERSION_ID}) |
| 44 | + test "${IDV}" = "ubuntu-24.04" |
| 45 | + # plucky is the next release |
| 46 | + echo 'deb http://azure.archive.ubuntu.com/ubuntu plucky universe main' | sudo tee /etc/apt/sources.list.d/plucky.list |
| 47 | + /bin/time -f '%E %C' sudo apt update |
| 48 | + # skopeo is currently older in plucky for some reason hence --allow-downgrades |
| 49 | + /bin/time -f '%E %C' sudo apt install -y --allow-downgrades crun/plucky podman/plucky skopeo/plucky just |
| 50 | + # This is the default on e.g. Fedora derivatives, but not Debian |
| 51 | + - name: Enable unprivileged /dev/kvm access |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + set -xeuo pipefail |
| 55 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 56 | + sudo udevadm control --reload-rules |
| 57 | + sudo udevadm trigger --name-match=kvm |
| 58 | + ls -l /dev/kvm |
| 59 | + # Used by a few workflows, but generally useful |
| 60 | + - name: Set architecture variable |
| 61 | + id: set_arch |
| 62 | + shell: bash |
| 63 | + run: echo "ARCH=$(arch)" >> $GITHUB_ENV |
| 64 | + # We often use Rust, so set up opinionated default caching |
| 65 | + - name: Setup Rust cache |
| 66 | + uses: Swatinem/rust-cache@v2 |
| 67 | + with: |
| 68 | + cache-all-crates: true |
| 69 | + # Only generate caches on push to git main |
| 70 | + save-if: ${{ github.ref == 'refs/heads/main' }} |
| 71 | + # Suppress actually using the cache for builds running from |
| 72 | + # git main so that we avoid incremental compilation bugs |
| 73 | + lookup-only: ${{ github.ref == 'refs/heads/main' }} |
| 74 | + # Install libvirt stack if requested |
| 75 | + - name: Install libvirt and virtualization stack |
| 76 | + if: ${{ inputs.libvirt == 'true' }} |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + set -xeuo pipefail |
| 80 | + export BCVK_VERSION=0.6.0 |
| 81 | + /bin/time -f '%E %C' sudo apt install -y libkrb5-dev pkg-config libvirt-dev genisoimage qemu-utils qemu-kvm virtiofsd libvirt-daemon-system |
| 82 | + # Something in the stack is overriding this, but we want session right now for bcvk |
| 83 | + echo LIBVIRT_DEFAULT_URI=qemu:///session >> $GITHUB_ENV |
| 84 | + td=$(mktemp -d) |
| 85 | + cd $td |
| 86 | + # Install bcvk |
| 87 | + target=bcvk-$(arch)-unknown-linux-gnu |
| 88 | + /bin/time -f '%E %C' curl -LO https://github.com/bootc-dev/bcvk/releases/download/v${BCVK_VERSION}/${target}.tar.gz |
| 89 | + tar xzf ${target}.tar.gz |
| 90 | + sudo install -T ${target} /usr/bin/bcvk |
| 91 | + cd - |
| 92 | + rm -rf "$td" |
| 93 | +
|
| 94 | + # Also bump the default fd limit as a workaround for https://github.com/bootc-dev/bcvk/issues/65 |
| 95 | + sudo sed -i -e 's,^\* hard nofile 65536,* hard nofile 524288,' /etc/security/limits.conf |
| 96 | + - name: Cleanup status |
| 97 | + shell: bash |
| 98 | + run: | |
| 99 | + set -xeuo pipefail |
| 100 | + systemctl list-units 'action-cleanup*' |
| 101 | + df -h |
0 commit comments