Development¶
How to build Hearth from source, run a farm made of your own builds, and run the tests. For how to send changes, see CONTRIBUTING.md.
The repository¶
| Path | What |
|---|---|
crates/hearth-gateway |
The public endpoint: auth, queue, protocol proxies, live view, JSON API, UI serving |
crates/hearth-operator |
Pool sizing; publishes pools, teams, key hashes and agent tokens |
crates/hearth-node |
Runs in each browser pod: virtual screen, browser server, recording; talks to the farm only through the gateway |
crates/hearth-agent |
Runs next to devices: Android emulators and iOS simulators, Appium, recording, reset; see its README.md |
crates/hearth-core |
Shared model, Redis state (Lua scripts), WebSocket proxy, W3C helpers, storage |
crates/hearth-cli |
hearth up, down, status, key, agent-token, app upload |
images/android |
Entrypoint of the in-cluster Android emulator image |
ui |
The web UI (React, TypeScript, Vite); see ui/README.md |
charts/hearth |
The Helm chart; crds/ is generated from the operator's types |
e2e |
End-to-end tests against a running farm, and the device test runner |
examples |
Small client examples per language |
docs, site |
These docs and the MkDocs site config |
install.sh |
The one-line installer; docs/install.sh is the copy the site serves at /install.sh |
skills, .claude-plugin |
Agent skills and the Claude Code plugin marketplace; see Coding agents |
AGENTS.md |
Guidance for coding agents working on this repository |
What you need¶
- Rust (stable, edition 2024) with
rustfmtandclippy - Docker, kind, Helm 3, kubectl
- Node.js 22 for the UI and the end-to-end tests
- Python 3 for the docs site
make help lists shortcuts for the commands below (make build, make test, make lint,
make images, make up, make e2e, make docs). A dev container
(.devcontainer/devcontainer.json) has every tool installed, and pre-commit install runs the
format and lint checks on each commit.
Build the images¶
One Dockerfile builds every image; pick one with --target:
docker build --target gateway -t hearth-gateway:dev .
docker build --target operator -t hearth-operator:dev .
docker build --target browser -t hearth-browser:1.65 .
docker build --target browser-webdriver -t hearth-browser-webdriver:dev .
docker build --target android -t hearth-android:35 . # linux/amd64 only
| Target | Image | Contents |
|---|---|---|
gateway |
hearth-gateway |
The gateway and the built web UI, on distroless |
operator |
hearth-operator |
The operator, on distroless |
browser |
hearth-browser:<major.minor> |
Playwright's image for PLAYWRIGHT_VERSION (build arg, default 1.65.1), Xvfb, ffmpeg, xdotool and hearth-node |
browser-webdriver |
hearth-browser-webdriver |
Debian's Chromium and chromedriver, Firefox ESR and geckodriver, Xvfb, ffmpeg and hearth-node |
android |
hearth-android:35 |
Ubuntu, the Android SDK with an API 35 x86_64 system image and AVD, Appium with UiAutomator2, hearth-agent; needs /dev/kvm |
For a browser image of another Playwright version:
The device agent is a plain binary: cargo build --release -p hearth-agent.
Run a farm from your builds¶
--local-images loads your local images into kind and points the chart at them. Each image is
retagged with its content id (dev-<id>), so after a rebuild the pod templates change and the
operator replaces idle pods running the old build. Options:
--tag devis the tag of the gateway, operator and WebDriver images to load.--playwright 1.65is the tag of the browser image to load.--set key=valuepasses chart values, for example--set storage.bundled.size=2Gi, and-f values.yaml(repeatable) passes values files.
Rebuild and run the same command again to upgrade the farm in place.
Tests¶
Rust¶
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
Tests of the Redis scripts need a Redis; they run when HEARTH_TEST_REDIS is set:
docker run -d --rm -p 6379:6379 valkey/valkey:8.1-alpine
HEARTH_TEST_REDIS=redis://127.0.0.1:6379 cargo test --workspace
CRDs¶
The CRDs in charts/hearth/crds/ are generated from crates/hearth-operator/src/crd.rs. After
changing the types, regenerate them; CI fails if they differ:
UI¶
cd ui
npm ci
npm run dev # http://localhost:5173 with a mock gateway
npm run lint && npm run typecheck && npm test
npm run build && npm run size
npm run e2e # Playwright against the build and the mock API
HEARTH_API=http://localhost:8080 npm run dev uses a real farm instead of the mock. See
ui/README.md.
End to end¶
Against a farm from hearth up (the script reads the default team's key with kubectl and
creates a team limited to one session for the limit tests):
Against any farm:
The chaos tests delete pods and restart deployments with kubectl; they are skipped without
kubectl access or with HEARTH_SKIP_CHAOS=1. HEARTH_BURST sets the size of the burst test.
Devices¶
On a Mac with Xcode, an Android SDK with an AVD named hearth-pixel, and Appium with the
uiautomator2 and xcuitest drivers, against a farm from hearth up local:
It builds the test apps (fixtures/build-apps.sh), adds three device pools and the host mac-1
to the farm (values-devices.yaml), builds and starts hearth-agent on this machine with
agent.local.toml (copied from agent.toml.example on first run), waits for three devices, and
runs tests/devices.test.mjs. Pods in kind reach the agent at host.docker.internal:4800.
What each test covers is listed in Testing.
Supply chain¶
cargo install cargo-deny --locked
cargo deny check # licenses, RustSec advisories, banned crates, sources (deny.toml)
The installer¶
shellcheck -s sh install.sh
scripts/test-install.sh install.sh sh # installs from a fake release in a temp folder
cp install.sh docs/install.sh # the site serves this copy; CI checks they match
Docs¶
python3 -m venv .venv && . .venv/bin/activate
pip install -r site/requirements.txt
mkdocs serve -f site/mkdocs.yml # http://127.0.0.1:8000
mkdocs build --strict -f site/mkdocs.yml
CI and releases¶
.github/workflows/ci.ymlruns on every pull request: Rust format, clippy and tests (with a Valkey service), the CRD check,cargo deny check, the UI checks and build,helm lint, the installer checks (shellcheck, the fake-release test on Linux and macOS), and the end-to-end suite on kind with images built from the pull request..github/workflows/release.ymlruns on av*tag: multi-arch images toghcr.io/<owner>/..., the chart tooci://ghcr.io/<owner>/charts, and on the GitHub releasehearth-<target>.tar.gz(holdinghearthandhearth-agent) forx86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu,aarch64-apple-darwinandx86_64-apple-darwin, plusinstall.shandSHA256SUMS. The installer depends on these names..github/workflows/docs.ymlbuilds this site withmkdocs build --stricton pull requests that touchdocs/orsite/, and publishes it to GitHub Pages frommain..github/workflows/codeql.yml(Rust, TypeScript, workflows) and.github/workflows/scorecard.yml(OpenSSF Scorecard) report to the repository's code scanning.- Every action is pinned to a commit SHA with its version in a comment; Dependabot keeps them, the crates, npm packages and base images up to date.