Skip to content

ci: gate Hearth pull requests on fmt, clippy and the test suite - #40

Open
PermutationResearch wants to merge 7 commits into
slice-2/control-planefrom
fix/hearth-ci
Open

PermutationResearch wants to merge 7 commits into
slice-2/control-planefrom
fix/hearth-ci

Conversation

@PermutationResearch

@PermutationResearch PermutationResearch commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

What

Hearth's first CI. Two jobs:

  • fmt — cargo fmt --all --check on every push and pull request.
  • test — pull requests: clippy and cargo test for only the packages the diff touches (resolved from cargo metadata; any file outside a package widens the scope to --workspace). Pushes to slice-2/control-plane: the full workspace suite.

Postgres 16 service for HEARTH_TEST_DATABASE_URL, openssh-server for the sshd -i fixture, one cargo cache, and a new push to the same PR cancels the running one.

Why the split: the first runs measured the truth — clippy --workspace took 2 m, and cargo test --workspace was still running after 43 minutes. 139 test binaries and 1,554 tests, each DB test creating, migrating and dropping its own database, on a cold build.

Two fixes from those runs are in this PR:

  1. HEARTH_TEST_DATABASE_URL is now a libpq keyword string, not a URI. crates/hearth-control/tests/common/mod.rs appends dbname=<name> to the value; with a URI the name became postgres dbname=hearth_t_…, and 1,176 tests panicked with database … does not exist.
  2. The cargo cache is saved with actions/cache/save under if: always(), so a failed run still warms the next one. It previously never saved, because every run failed.

Verified here

Check Result
cargo fmt --all --check clean
cargo clippy -p hearth-control -p hearth-cli --all-targets -- -D warnings exit 0 (PR #42)
scope script, crate-only diff -p hearth-control
scope script, nested crate -p hearth-agent-core
scope script, root or docs file --workspace
workflow YAML parses; jobs fmt, test

Stacks with #42, which clears the seven clippy errors this workflow first reported.

Formatting runs on every push because it costs seconds. Everything that
compiles runs on pull requests only, on one runner and one cargo cache, so
a PR head is built once instead of three times.

The test job supplies the Postgres that crates/hearth-control/tests/common
needs (HEARTH_TEST_DATABASE_URL, CREATEDB) and installs openssh-server for
the sshd fixture. Property tests run inside the workspace targets with
proptest's default case count, so they add no job.

No new dependencies: actions/checkout, actions/cache and a service
container only.
A run whose clippy step failed saved check metadata only (172 MB) under
the Cargo.lock key. The next run on that pull request hit that key
exactly, so cache-hit was true and the save step was skipped: it
rebuilt every crate and never replaced the entry, since caches are
immutable.

Build the test binaries with the arguments the test steps use, then
save before the tests run and without always(), so failing tests still
leave a warm cache while a lint failure, build failure or cancelled run
saves nothing. Bump the key to v2 to retire the partial entries.

A pull request still cannot restore another pull request's cache; that
comes from the default branch once a push there has saved one.
`cargo clippy --workspace --all-targets -- -D warnings` failed before the
test step ran, on code that predates the workflow.

- chatgpt_plan_store.rs: import db::GenericClient, so the four advisory-lock
  `query_one` calls dispatch to the trait method that prepares once and keeps
  the statement. clippy.toml disallows tokio-postgres' inherent method.
- threads/comparison.rs: fold the nested `if` into a let-chain.
- chatgpt_plan.rs: move `mod tests` below the items it tests.
- hearth-cli/tests/common/mod.rs: one `#![allow(dead_code)]` for fixtures the
  binaries share but do not all use, and drop the two now-duplicate outer
  allows. That is how hearth-control/tests/common already does it.
fix(lints): clear the seven clippy errors CI reports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants