Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

build(hooks): run the host tests with nextest, end to end only where touched

leepokaia1ca92cc93ed
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
index b06f6c88..dfbadd2a 100755
--- a/.githooks/pre-commit
+++ b/.githooks/pre-commit
@@ -46,12 +46,49 @@ staged_copy() {
git archive "$(git write-tree)" | tar -x -C "$snapshot"
}
+# The host tests a commit needs, as a nextest filter: unit tests always, plus the end-to-end tests of
+# the areas it touches; "all" for everything else (the hub, the store, the API, bots, agents and chats,
+# which every end-to-end test goes through, and the tests' shared helpers).
+host_tests() {
+ targets=""
+ for file in $(printf '%s\n' "$staged_files" | grep -E '^(host/|packaging/updates/|docs/reference/fixtures/)'); do
+ case "$file" in
+ host/src/routines/*) add="routines_e2e routine_retry_e2e routine_unread_e2e" ;;
+ host/src/network/*|host/src/network_cli.rs|host/crates/network/*) add="network_e2e two_computers" ;;
+ host/src/send_cli*) add="send_cli_e2e" ;;
+ host/src/chat/memory/*|host/crates/memory/*) add="memory_e2e memory_files_e2e compaction_e2e" ;;
+ host/src/voice.rs|host/src/chat/calls*) add="calls_e2e" ;;
+ host/src/tui/*|host/src/screen/*|host/src/update/*|host/src/usage/*|host/src/remote/*|host/src/analytics*|\
+ host/src/service/*|host/src/cloud_cli.rs|host/src/compat.rs|host/src/secret_prompt.rs|\
+ packaging/updates/*|docs/reference/fixtures/*) add="" ;;
+ host/tests/common/*) echo all; return ;;
+ host/tests/*.py|host/tests/fixtures/*)
+ add=$(grep -rl --include='*.rs' "$(basename "$file")" "$snapshot/host/tests" |
+ sed -E 's#^.*/host/tests/([^/.]+).*#\1#' || true) ;;
+ host/tests/*) add=$(printf '%s' "$file" | sed -E 's#^host/tests/([^/.]+).*#\1#') ;;
+ *) echo all; return ;;
+ esac
+ targets="$targets $add"
+ done
+ filter="kind(lib) | kind(bin)"
+ for target in $targets; do filter="$filter | binary($target)"; done
+ printf '%s\n' "$filter"
+}
+
if touches '^(host/|packaging/updates/|docs/reference/fixtures/remote-relay-vectors\.json)'; then
+ if ! cargo nextest --version >/dev/null 2>&1; then
+ echo "The host checks run their tests with cargo-nextest, as CI does: cargo install cargo-nextest --locked"
+ exit 1
+ fi
staged_copy
- echo "Checking the host (cargo fmt, clippy, test)..."
+ tests=$(host_tests)
+ echo "Checking the host (cargo fmt, clippy, test: $tests)..."
+ set -- --profile ci
+ [ "$tests" = all ] || set -- "$@" -E "$tests"
+ # nextest runs every test at once, retries a flaky one and stops one that hangs (`host/.config/nextest.toml`).
(cd "$snapshot/host" && export CARGO_TARGET_DIR="$repo/host/target/precommit" &&
- cargo fmt --all --check && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace --no-run &&
- within 300 cargo test --workspace)
+ cargo fmt --all --check && cargo clippy --workspace --all-targets -- -D warnings &&
+ within 900 cargo nextest run --workspace "$@")
fi
if touches '^apps/desktop/'; then
diff --git a/docs/guides/development.md b/docs/guides/development.md
index dfec60be..a7882582 100644
--- a/docs/guides/development.md
+++ b/docs/guides/development.md
@@ -121,14 +121,20 @@ git config core.hooksPath .githooks
```
It runs CI's checks for each part a commit touches, so a failure shows up before the push:
-host and the memory crate (`cargo fmt --all --check`, clippy and `cargo test` for the workspace), desktop, cloud,
+host and the memory crate (`cargo fmt --all --check`, clippy, and the tests with `cargo nextest run --profile ci` as CI
+runs them: install it once with `cargo install cargo-nextest --locked`), desktop, cloud,
relay, discord and private-relay (`npm run typecheck`, `npm test`), the Android app (core and app unit tests, and a Kotlin compile of
the app and its instrumentation tests, with JDK 21), Linux screen helper formatting, a parse of the macOS
screen helper's Swift sources (on macOS), and the website's user manual (`npm run check:docs` in `web/`: pages
compile, links and anchors resolve). It checks the staged files only, in a copy under `.git/precommit-snapshot`,
so other agents' uncommitted edits in the same checkout neither break nor rescue a commit; the
-host builds into `host/target/precommit`, and its tests are stopped after 5 minutes so a hung
-test fails the commit instead of holding it. The npm checks reuse each package's `node_modules`
+host builds into `host/target/precommit`. Its unit tests always run; its end-to-end tests run for the
+areas the commit touches (`host_tests` in the hook: routines, network, the send CLI, memory, calls, or a changed test and
+the tests sharing a changed fixture), none for areas no end-to-end test covers (the terminal UI, screen, updates,
+usage, remote, analytics, service), and all of them for anything else (the hub, store, API, bots, agents and chats,
+or the tests' shared helpers). nextest runs them side by side, retries a flaky one, and stops one that hangs
+(`host/.config/nextest.toml`); the whole run is stopped after 15 minutes. Host CI runs only on pull requests, so a
+host change that skipped end-to-end tests here is fully tested when its PR into `main` opens. The npm checks reuse each package's `node_modules`
(run `npm ci` there first). Each worker package is checked only when its own folder (or the
shared relay vectors) changes. On a merge commit it checks only the files that differ from both
sides (resolved conflicts, or both sides' changes put together); what the merge brings in was checked