diff options
Diffstat (limited to 'scripts/testing')
| -rw-r--r-- | scripts/testing/archsetup-vm.conf | 3 | ||||
| -rwxr-xr-x | scripts/testing/run-test.sh | 30 |
2 files changed, 32 insertions, 1 deletions
diff --git a/scripts/testing/archsetup-vm.conf b/scripts/testing/archsetup-vm.conf index 12350a7..a6d2205 100644 --- a/scripts/testing/archsetup-vm.conf +++ b/scripts/testing/archsetup-vm.conf @@ -3,8 +3,9 @@ # # Usage: ./archsetup --config-file /tmp/archsetup-test/archsetup-vm.conf -# Use local test copy instead of cloning from remote +# Use local test copies instead of cloning from remote ARCHSETUP_REPO=/tmp/archsetup-test +DOTFILES_REPO=/tmp/dotfiles-test USERNAME=cjennings PASSWORD=archsetup 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" |
