From 68172c8b4c33b4b2cc44d235a9c71685cd4ac3d5 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 22 May 2026 15:52:24 -0500 Subject: refactor(testing): clone the dotfiles repo into the VM test The dotfiles live in a separate repo now, so the VM test clones that source, bundles it, and clones from the bundle into /tmp/dotfiles-test on the VM. archsetup's in-VM clone of DOTFILES_REPO then resolves against the local path with no network. DOTFILES_SOURCE overrides the source for testing a local checkout instead of the published repo. The cleanup trap tracks the host-side bundle and clone, so a mid-run abort leaves nothing behind. --- scripts/testing/run-test.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'scripts/testing/run-test.sh') diff --git a/scripts/testing/run-test.sh b/scripts/testing/run-test.sh index a02412c..5830ed9 100755 --- a/scripts/testing/run-test.sh +++ b/scripts/testing/run-test.sh @@ -58,10 +58,14 @@ done # safety net that stops a leaked QEMU and reverts the base disk. CLEANUP_DONE=0 BUNDLE_FILE="" +DOTFILES_BUNDLE="" +DOTFILES_HOST_CLONE="" cleanup_run_test() { [ "$CLEANUP_DONE" = "1" ] && return 0 CLEANUP_DONE=1 [ -n "$BUNDLE_FILE" ] && [ -f "$BUNDLE_FILE" ] && rm -f "$BUNDLE_FILE" + [ -n "$DOTFILES_BUNDLE" ] && [ -f "$DOTFILES_BUNDLE" ] && rm -f "$DOTFILES_BUNDLE" + [ -n "$DOTFILES_HOST_CLONE" ] && [ -d "$DOTFILES_HOST_CLONE" ] && rm -rf "$DOTFILES_HOST_CLONE" if [ "$KEEP_VM" = "true" ]; then return 0 fi @@ -166,6 +170,32 @@ vm_exec "$ROOT_PASSWORD" \ rm -f "$BUNDLE_FILE" success "Repository cloned to VM (simulating git clone --depth 1)" +# Transfer the dotfiles repo the same way. Dotfiles live in their own repo now, +# so clone the source, bundle it, and clone from the bundle on the VM. archsetup +# then runs `git clone $DOTFILES_REPO ~/.dotfiles` against /tmp/dotfiles-test — +# no network needed inside the VM. Override DOTFILES_SOURCE to test a local +# checkout instead of the published repo. +step "Creating shallow git clone of dotfiles on VM" +DOTFILES_SOURCE="${DOTFILES_SOURCE:-https://git.cjennings.net/dotfiles.git}" +info "Dotfiles source: $DOTFILES_SOURCE" + +DOTFILES_HOST_CLONE=$(mktemp -d) +git clone --bare "$DOTFILES_SOURCE" "$DOTFILES_HOST_CLONE/dotfiles.git" >> "$LOGFILE" 2>&1 \ + || fatal "Failed to clone dotfiles source: $DOTFILES_SOURCE" + +DOTFILES_BUNDLE=$(mktemp) +git -C "$DOTFILES_HOST_CLONE/dotfiles.git" bundle create "$DOTFILES_BUNDLE" --all >> "$LOGFILE" 2>&1 + +vm_exec "$ROOT_PASSWORD" "rm -rf /tmp/dotfiles-test" >> "$LOGFILE" 2>&1 +copy_to_vm "$DOTFILES_BUNDLE" "/tmp/dotfiles.bundle" "$ROOT_PASSWORD" +vm_exec "$ROOT_PASSWORD" \ + "cd /tmp && git clone /tmp/dotfiles.bundle dotfiles-test && rm /tmp/dotfiles.bundle" \ + >> "$LOGFILE" 2>&1 + +rm -f "$DOTFILES_BUNDLE"; DOTFILES_BUNDLE="" +rm -rf "$DOTFILES_HOST_CLONE"; DOTFILES_HOST_CLONE="" +success "Dotfiles repo cloned to VM (/tmp/dotfiles-test)" + # Transfer archsetup VM config file step "Copying archsetup VM config" copy_to_vm "$ARCHSETUP_VM_CONF" "/tmp/archsetup-test/archsetup-vm.conf" "$ROOT_PASSWORD" -- cgit v1.2.3