Add a smoketest, run on CoreDesktop's with coredesktop-dev
check / lint-and-test (push) Successful in 1m37s
check / packages (push) Successful in 23s

`coredesktop-dev smoketest run --with HamPack` installs HamPack on a VM with
CoreDesktop and checks a fresh install, an update with nothing to do, a
one-app rebuild, a failing build and hampackremove, with smoketest/health
checking every package, Flatpak and app is in place.

HAMPACK_SKIP_WINDOWS_APPS skips the Windows installers, which the test VMs'
desktop would start with no one to click through them; smoketest/setup sets
it in each VM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-26 10:15:11 -07:00
co-authored by Claude Opus 5.5
parent bc536407c4
commit e8fbe256df
16 changed files with 417 additions and 2 deletions
+41
View File
@@ -0,0 +1,41 @@
# HamPack's smoketest
End-to-end tests of HamPack on a real Arch + GNOME virtual machine with
CoreDesktop installed: `sibling add`, `update` and `hampackremove`, with real
pacman, AUR, Flatpak and source builds. The bats tests in `tests/` check the
logic with fake commands; these check what fakes can't.
They run with CoreDesktop's smoketest, from the `coredesktop-dev` sibling
project, with HamPack's working copy beside CoreDesktop's (in `~/Projects`):
```
coredesktop-dev smoketest list --with HamPack
coredesktop-dev smoketest run --with HamPack # the quick (pr) scenarios, CoreDesktop's too
coredesktop-dev smoketest run --with HamPack HamPack/30 # just this one
coredesktop-dev smoketest run --with HamPack --tier all # everything, including fresh installs
```
Each working copy's `HEAD` is tested, so commit first. The first run builds
the `installed+HamPack` image, CoreDesktop's installed image after `sibling add
HamPack` at the commit this branch started from. That takes an hour or two,
building the source apps; later runs reuse it. See coredesktop-dev's README for
what the smoketest needs and how its images work.
## Files
| File | What it is |
|------|------------|
| `project.conf` | HamPack's name, parent (CoreDesktop) and URL, for the driver |
| `setup` | Runs in each VM first: sets `HAMPACK_SKIP_WINDOWS_APPS`, since no one is there to click through the Windows installers |
| `health` | Runs in the VM; checks every package, Flatpak and app HamPack installs, at its version, with its libraries and desktop file |
| `lib.sh` | Helpers for the scenarios, on top of CoreDesktop's `smoketest/lib/scenario.sh` |
| `scenarios/NN-name.sh` | One scenario each |
Scenarios are written like CoreDesktop's (see its `smoketest/README.md`), with
HamPack named where it matters: `upstream_commit HamPack MESSAGE SCRIPT`
releases a new HamPack commit, and `health HamPack` checks HamPack alone.
## Not covered
The Windows applications (VARA, Winlink Express), anything that needs a radio,
and whether the apps work beyond starting: check those by hand.
+83
View File
@@ -0,0 +1,83 @@
#!/bin/bash
#
# Purpose : HamPack's smoketest health checks. Run in a test VM with HamPack
# installed; prints what it checked, and exits 1 if anything's wrong.
# The Windows applications aren't checked: the smoketest skips them.
HAMPACK_DIR="${HAMPACK_DIR:-$HOME/.local/share/siblings/HamPack}"
APPLICATIONS_DIR="$HOME/.local/share/applications"
# shellcheck source=../lib.sh
source "$HAMPACK_DIR/lib.sh"
problems=()
problem() {
echo "PROBLEM: $*"
problems+=("$*")
}
# Arch packages (or the packages providing them) and groups
packages_installed() {
local p
while read -r p; do
pacman -T "$p" > /dev/null 2>&1 || pacman -Qg "$p" > /dev/null 2>&1 || problem "package $p isn't installed"
done < <(source "$HAMPACK_DIR/packages.conf"; printf '%s\n' "${UTILITIES[@]}" "${APPLICATIONS[@]}")
echo "checked packages.conf's packages"
}
flatpaks_installed() {
local id
while read -r id; do
flatpak info "$id" > /dev/null 2>&1 || problem "Flatpak $id isn't installed"
done < <(source "$HAMPACK_DIR/packages.conf"; printf '%s\n' "${FLATPAKS[@]}")
echo "checked packages.conf's Flatpaks"
}
# True if FILE is an ELF binary
is_elf() {
[ "$(head -c 4 "$1" 2> /dev/null | tail -c 3)" = ELF ]
}
# parse_conf callback for binaries.conf and compile.conf: the app is where it
# should be, at the version in the conf, with every library it links to, and
# with its desktop file
check_app() {
local app="${CONF[_name]}" path recorded missing desktop=""
path="$(expand_vars "${CONF[install]}")"
if [ ! -e "$path" ]; then
problem "$app isn't installed at $path"
return
fi
recorded="$(get_recorded_version "$app")"
[ "$recorded" = "${CONF[version]}" ] \
|| problem "$app is recorded at version ${recorded:-(none)}, not ${CONF[version]}"
if is_elf "$path"; then
missing="$(ldd "$path" 2> /dev/null | grep 'not found')"
[ -z "$missing" ] || problem "$app can't find libraries: $(echo "$missing" | awk '{print $1}' | tr '\n' ' ')"
fi
if [ -n "${CONF[desktop]}" ]; then
desktop="$APPLICATIONS_DIR/$(basename "$(expand_vars "${CONF[desktop]}")")"
elif [ "$1" = binary ] && [ "${CONF[gui]}" = true ]; then
desktop="$APPLICATIONS_DIR/$app.desktop"
fi
[ -z "$desktop" ] || [ -f "$desktop" ] || problem "$app has no desktop file at $desktop"
echo "checked $app"
}
check_binary() { check_app binary; }
check_compiled() { check_app compiled; }
packages_installed
flatpaks_installed
parse_conf "$HAMPACK_DIR/binaries.conf" check_binary
parse_conf "$HAMPACK_DIR/compile.conf" check_compiled
systemctl is-enabled --quiet graywolf 2> /dev/null || problem "graywolf's service isn't enabled"
uv tool list 2> /dev/null | grep -q '^not1mm ' || problem "not1mm isn't installed"
[ -f "$APPLICATIONS_DIR/k6gte-not1mm.desktop" ] || problem "not1mm has no desktop file"
[ -x "$HOME/.local/bin/hampackremove" ] || problem "hampackremove isn't installed"
echo "checked graywolf's service, not1mm and hampackremove"
if (( ${#problems[@]} > 0 )); then
echo "${#problems[@]} problem(s)"
exit 1
fi
echo "HamPack is healthy"
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
#
# Purpose : Helpers for HamPack's smoketest scenarios, on top of CoreDesktop's
# smoketest/lib/scenario.sh. Scenarios source this.
# hampack_file FILE: print HamPack's FILE at the commit under test
hampack_file() {
git -C "$(project_dir HamPack)" show "$(project_sha HamPack):$1"
}
# The apps in compile.conf at the commit under test, one per line
compiled_apps() {
hampack_file compile.conf | sed -n 's/^\[\(.*\)\]$/\1/p'
}
# compiled_version APP: APP's version= in compile.conf at the commit under test
compiled_version() {
hampack_file compile.conf | awk -v app="[$1]" '
$0 == app { found = 1; next }
/^\[/ { found = 0 }
found && /^version=/ { sub(/^version=/, ""); print; exit }'
}
+8
View File
@@ -0,0 +1,8 @@
# HamPack's smoketest, run with coredesktop-dev on top of CoreDesktop's:
# `coredesktop-dev smoketest run --with HamPack`. See README.md here.
# shellcheck disable=SC2034
NAME=HamPack
PARENT=CoreDesktop
# What `sibling add` is given; in the test VM, git sends it to a fake upstream
# holding the commit under test
URLS=(https://gitea.young.computer/david/HamPack.git)
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="a fresh install of CoreDesktop, then sibling add HamPack, as the READMEs say"
IMAGE=base
TIER="nightly"
scenario() {
install_chain
health
}
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="update with nothing new for HamPack builds and downloads nothing"
IMAGE=installed
TIER="pr"
source "$(dirname "${BASH_SOURCE[0]}")/../lib.sh"
# smoketest_prepare has already updated the machine to the commit under test
scenario() {
local app
cd_update
assert_status 0
while read -r app; do
assert_output " $app $(compiled_version "$app") is up to date."
done < <(compiled_apps)
refute_output " Building "
refute_output " Downloading "
refute_output " Installing:"
health
}
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="a new version of one app in compile.conf rebuilds that app and no other"
IMAGE=installed
TIER="pr"
source "$(dirname "${BASH_SOURCE[0]}")/../lib.sh"
# Dump1090 is pinned to a commit with ref=, so a new version= rebuilds the same
# source: the quickest build there is
scenario() {
local old
old="$(compiled_version Dump1090)"
upstream_commit HamPack "Rebuild Dump1090" \
'sed -i "/^\[Dump1090\]/,/^\$/ s/^version=.*/&-smoketest/" compile.conf'
cd_update
assert_status 0
assert_output "Updating Dump1090 from $old to $old-smoketest"
[ "$(grep -c ' Building ' <<< "$OUTPUT")" -eq 1 ] || fail "update built more than Dump1090 (see $LAST_LOG)"
health HamPack
}
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="a build that fails is reported, keeps the installed app, and is retried on the next update"
IMAGE=installed
TIER="pr"
source "$(dirname "${BASH_SOURCE[0]}")/../lib.sh"
scenario() {
local old
old="$(compiled_version Dump1090)"
upstream_commit HamPack "Break Dump1090's build" \
'sed -i "/^\[Dump1090\]/,/^\$/ { s/^version=.*/&-smoketest/; s/^steps=/steps=false, /; }" compile.conf'
cd_update
assert_status 1
assert_output "Error: build of Dump1090 failed"
assert_output "HamPack's update.sh failed"
assert_vm "Dump1090 is still installed, at its old version" \
"test -x ~/.local/bin/dump1090 && grep -qx Dump1090=$(q "$old") ~/.local/state/HamPack/.installed_versions"
upstream_commit HamPack "Fix Dump1090's build" 'sed -i "s/^steps=false, /steps=/" compile.conf'
cd_update
assert_status 0
assert_output "Updating Dump1090 from $old to $old-smoketest"
health HamPack
}
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="hampackremove removes what HamPack installed and leaves CoreDesktop working"
IMAGE=installed
TIER="pr"
scenario() {
local recorded kept pkg
recorded="$(vm_value 'cat ~/.local/state/HamPack/installed-packages 2> /dev/null || true')"
# It asks to confirm, then (with nothing more on stdin) says no to anything else
run_in_vm hampackremove 'printf "y\n" | TERM=dumb ~/.local/bin/hampackremove'
assert_status 0
assert_output "HamPack has been removed."
assert_vm "HamPack's clone, state and apps are gone" '
! test -e ~/.local/share/siblings/HamPack && ! test -e ~/.local/state/HamPack &&
! test -e ~/.local/bin/direwolf && ! test -e ~/.local/bin/dump1090 &&
! test -e ~/.local/bin/POTACAT.AppImage && ! test -e ~/.local/bin/hampackremove'
refute_vm "graywolf's service is gone" 'systemctl cat graywolf'
# Each package HamPack installed is gone, unless something else needs it
kept="$(sed -n 's/^Kept because other software needs them: //p' <<< "$OUTPUT")"
for pkg in $recorded; do
if vm_exec "pacman -Qq $(q "$pkg")" > /dev/null 2>&1; then
[[ " $kept " == *" $pkg "* ]] || fail "$pkg is still installed, and wasn't reported as kept"
fi
done
echo "ok: HamPack's packages are gone, but for those kept: ${kept:-none}"
health CoreDesktop
cd_update
assert_status 0
health CoreDesktop
}
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
#
# Purpose : Run in each smoketest VM before HamPack is installed or tested.
# The VMs have a desktop, but no one to click through the Windows
# installers, which would wait for clicks until the run timed out.
# Set for the GNOME session now and after reboots, so every
# install, update and sibling add in the VM sees it.
set -e
mkdir -p ~/.config/environment.d
echo HAMPACK_SKIP_WINDOWS_APPS=1 > ~/.config/environment.d/90-hampack-smoketest.conf
systemctl --user set-environment HAMPACK_SKIP_WINDOWS_APPS=1