Track one-time setup with completion markers

This commit is contained in:
David Heinemeier Hansson
2026-07-16 21:53:15 -07:00
parent 7b824b6e1b
commit e82df1d4d0
9 changed files with 162 additions and 18 deletions
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
set -euo pipefail
source "$(dirname "$0")/base-test.sh"
test_home=$(mktemp -d)
trap 'rm -rf "$test_home"' EXIT
done_marker="$test_home/.local/state/omarchy/done/example"
if HOME="$test_home" "$ROOT/bin/omarchy-done" check example; then
fail "done reports an unmarked task as complete"
fi
HOME="$test_home" "$ROOT/bin/omarchy-done" mark example
[[ -f $done_marker ]] || fail "done marks a task complete"
HOME="$test_home" "$ROOT/bin/omarchy-done" check example || fail "done reports a marked task as complete"
HOME="$test_home" "$ROOT/bin/omarchy-done" ensure once || fail "done ensures an unmarked task"
[[ -f $test_home/.local/state/omarchy/done/once ]] || fail "done ensure marks a task complete"
if HOME="$test_home" "$ROOT/bin/omarchy-done" ensure once; then
fail "done ensures a completed task again"
fi
if HOME="$test_home" "$ROOT/bin/omarchy-done" check ../invalid >/dev/null 2>&1; then
fail "done accepts marker path traversal"
fi
pass "done manages completion markers"
+6
View File
@@ -32,6 +32,12 @@ grep -F 'skip-first-run-update-notification' "$first_run_wifi" >/dev/null
grep -F '(( skip_update_notification )) && return 0' "$first_run_wifi" >/dev/null
pass "Omarchy 4 upgrade suppresses the fresh-install update toast"
grep -F '"$root/bin/omarchy-done" mark first-run-user' "$upgrade_to_quattro" >/dev/null
grep -F 'rm -f "$state_dir/first-run-user.done"' "$upgrade_to_quattro" >/dev/null
grep -F '"$root/bin/omarchy-done" mark finalize-user' "$upgrade_to_quattro" >/dev/null
grep -F 'rm -f "$state_dir/finalize-user.done"' "$upgrade_to_quattro" >/dev/null
pass "Omarchy 4 upgrade migrates legacy completion markers"
grep -F 'configure_snapper_policy' "$upgrade_to_quattro" >/dev/null
grep -F '/usr/share/omarchy/install/config/snapper.sh' "$upgrade_to_quattro" >/dev/null
grep -F 'bash -euo pipefail "$snapper_config_script"' "$upgrade_to_quattro" >/dev/null
+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
source "$(dirname "$0")/base-test.sh"
test_home=$(mktemp -d)
test_bin=$(mktemp -d)
log_file=$(mktemp)
hook_path="$test_home/.config/omarchy/hooks/post-update.d/install-voxtype.hook"
cleanup() {
rm -rf "$test_home" "$test_bin"
rm -f "$log_file"
}
trap cleanup EXIT
mkdir -p "$(dirname "$hook_path")"
cat >"$test_bin/omarchy-notification-send" <<'EOF'
#!/bin/bash
echo notification >>"$TEST_LOG"
echo action
EOF
chmod +x "$test_bin/omarchy-notification-send"
cat >"$test_bin/omarchy-launch-floating-terminal-with-presentation" <<'EOF'
#!/bin/bash
echo launch >>"$TEST_LOG"
EOF
chmod +x "$test_bin/omarchy-launch-floating-terminal-with-presentation"
run_invitation_hook() {
cp "$ROOT/install/user/first-run/install-voxtype.hook" "$hook_path"
HOME="$test_home" PATH="$test_bin:$ROOT/bin:$PATH" TEST_LOG="$log_file" bash "$hook_path"
}
run_invitation_hook
for _ in {1..50}; do
[[ $(wc -l <"$log_file") -eq 2 ]] && break
sleep 0.02
done
[[ -f $test_home/.local/state/omarchy/done/voxtype-install-invitation ]] || fail "Voxtype invitation records completion"
[[ -f $hook_path ]] || fail "Voxtype invitation keeps its hook installed"
[[ $(grep -c '^notification$' "$log_file") -eq 1 ]] || fail "Voxtype invitation sends one notification"
[[ $(grep -c '^launch$' "$log_file") -eq 1 ]] || fail "Voxtype invitation handles the notification action"
HOME="$test_home" PATH="$test_bin:$ROOT/bin:$PATH" TEST_LOG="$log_file" bash "$hook_path"
sleep 0.05
[[ -f $hook_path ]] || fail "completed Voxtype invitation keeps its hook installed"
[[ $(grep -c '^notification$' "$log_file") -eq 1 ]] || fail "completed Voxtype invitation hook does not notify again"
[[ $(grep -c '^launch$' "$log_file") -eq 1 ]] || fail "completed Voxtype invitation hook does not launch again"
pass "Voxtype invitation only runs once"