From af30018bd90935be8683116660e17757c83edee5 Mon Sep 17 00:00:00 2001 From: Rick Peters Date: Wed, 30 Sep 2026 08:29:41 +0200 Subject: [PATCH] ci: cache pacman packages (build, test, suites), the VMs' packages and the CachyOS ISO --- .github/workflows/iso-2-gitea-build.yml | 79 +++++++++++++++++++++---- AGENTS.md | 1 + 2 files changed, 69 insertions(+), 11 deletions(-) diff --git a/.github/workflows/iso-2-gitea-build.yml b/.github/workflows/iso-2-gitea-build.yml index 9393992..6351930 100644 --- a/.github/workflows/iso-2-gitea-build.yml +++ b/.github/workflows/iso-2-gitea-build.yml @@ -34,11 +34,19 @@ jobs: outputs: steamify: ${{ steps.tag.outputs.steamify }} steps: - - name: Tools + # First only what the cache action needs (node, git), then the caches, then the rest from the restored cache. + - name: Node and git run: | pacman-key --init && pacman-key --populate - # nodejs: the actions below run in this container - pacman -Syu --noconfirm --needed archiso mkinitcpio-archiso git squashfs-tools grub sudo nodejs curl jq + pacman -Syu --noconfirm --needed nodejs git + - name: Cache - pacman packages + uses: actions/cache@v4 + with: + path: /var/cache/pacman/pkg + key: pacman-build-${{ github.run_id }} + restore-keys: pacman-build- + - name: Tools + run: pacman -S --noconfirm --needed archiso mkinitcpio-archiso squashfs-tools grub sudo curl jq - uses: actions/checkout@v4 @@ -103,11 +111,29 @@ jobs: run: shell: bash steps: - - name: Tools and KVM + # First only what the cache action needs (node, git), then the caches, then the rest from the restored cache. + - name: Node and git run: | pacman-key --init && pacman-key --populate - # nodejs: the actions below run in this container - pacman -Syu --noconfirm --needed qemu-desktop edk2-ovmf openssh libarchive procps-ng util-linux python git nodejs sudo + pacman -Syu --noconfirm --needed nodejs git + - name: Cache - pacman packages + uses: actions/cache@v4 + with: + path: /var/cache/pacman/pkg + key: pacman-test-${{ github.run_id }} + restore-keys: pacman-test- + # The guests' packages (VM_CACHE, shared into the VMs): downloaded once for every run. + - name: Cache - the VMs' packages + uses: actions/cache@v4 + with: + path: /root/vms/pkg-cache + key: vmpkg-${{ needs.build.outputs.steamify }}-${{ github.run_id }} + restore-keys: | + vmpkg-${{ needs.build.outputs.steamify }}- + vmpkg- + - name: Tools and KVM + run: | + pacman -S --noconfirm --needed qemu-desktop edk2-ovmf openssh libarchive procps-ng util-linux python git sudo # Fail at once, with a reason, when the runner cannot run a VM with KVM. [ -c /dev/kvm ] || { echo "::error::no /dev/kvm in this container: the runner needs KVM (and privileged containers)"; exit 1; } nproc; free -g | sed -n 2p; df -h . | tail -n 1 @@ -169,11 +195,29 @@ jobs: run: shell: bash steps: - - name: Tools and KVM + # First only what the cache action needs (node, git), then the caches, then the rest from the restored cache. + - name: Node and git run: | pacman-key --init && pacman-key --populate - # nodejs: the actions below run in this container - pacman -Syu --noconfirm --needed qemu-desktop edk2-ovmf openssh libarchive procps-ng util-linux python git nodejs sudo + pacman -Syu --noconfirm --needed nodejs git + - name: Cache - pacman packages + uses: actions/cache@v4 + with: + path: /var/cache/pacman/pkg + key: pacman-test-${{ github.run_id }} + restore-keys: pacman-test- + # The guests' packages (VM_CACHE, shared into the VMs): downloaded once for every run. + - name: Cache - the VMs' packages + uses: actions/cache@v4 + with: + path: /root/vms/pkg-cache + key: vmpkg-${{ needs.build.outputs.steamify }}-${{ github.run_id }} + restore-keys: | + vmpkg-${{ needs.build.outputs.steamify }}- + vmpkg- + - name: Tools and KVM + run: | + pacman -S --noconfirm --needed qemu-desktop edk2-ovmf openssh libarchive procps-ng util-linux python git sudo # Fail at once, with a reason, when the runner cannot run a VM with KVM. [ -c /dev/kvm ] || { echo "::error::no /dev/kvm in this container: the runner needs KVM (and privileged containers)"; exit 1; } nproc; free -g | sed -n 2p; df -h . | tail -n 1 @@ -195,6 +239,20 @@ jobs: # The suites run on a plain CachyOS VM (Plasma, no Steamify): the newest CachyOS ISO, installed once; # every block then starts from a fresh overlay of that VM. + # The CachyOS ISO (~3 GB) is cached per release (the release get-iso.sh would download). + - name: CachyOS release + id: cachyos + run: | + rel="$(curl -fsL https://cachyos.org/download/ | grep -oE 'cachyos-desktop-linux-[0-9]+' | head -n 1)" + echo "release=${rel:?no CachyOS release found}" >> "$GITHUB_OUTPUT" + - name: Cache - the CachyOS ISO + uses: actions/cache@v4 + with: + path: | + steamify-cachyos-dev/cachyos.iso + steamify-cachyos-dev/cachyos.iso.version + key: cachyos-iso-${{ steps.cachyos.outputs.release }} + - name: Plain CachyOS VM env: CI: "1" @@ -206,9 +264,8 @@ jobs: mkdir -p ~/.ssh ~/vms/pkg-cache ssh-keygen -q -t ed25519 -N "" -C steamify-vm -f ~/.ssh/steamify-vm_ed25519 cd steamify-cachyos-dev - ./get-iso.sh + ./get-iso.sh # does nothing when the cached ISO is the current release VM_DIR="$HOME/vms/steamify-vm" scripts/vminstall.sh --iso cachyos.iso - rm -f cachyos.iso # Two suites at a time, 4 GB and 2 vCPUs each (vmsuite.sh). - name: vmtest.sh (every suite) diff --git a/AGENTS.md b/AGENTS.md index 90e052f..a9d05a9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -131,4 +131,5 @@ Full write-up, with every trap: `steamify-iso-release` in steamify-cachyos-dev. GitHub doesn't have, and the release with them. GitHub releases can't hold the ISO (2 GB per file). - Gitea needs `[repository.release] FILE_MAX_SIZE` above the ISO (413 otherwise) and the runner `container: privileged: true` (archiso mounts `/proc`); the workflow's `--privileged` option is ignored. +- Caches (`actions/cache`, the runner's cache server): pacman's package cache per job kind (build, test), the VMs' packages (`VM_CACHE`, `~/vms/pkg-cache`) and the CachyOS ISO for the suites, per release. Each job first installs only node and git, restores the caches, then installs the rest. - CachyOS's own `Desktop ISO` workflow (`build.yml`) is removed here; the test job of iso-2-gitea-build.yml replaces it.