Repository navigation
Description
Is your feature request related to a problem? Please describe.
The pre-push hook has no memory, so it re-runs cargo clippy --workspace --all-targets, the e2e harness clippy and cargo test --workspace --all-targets --exclude e2e-cucumber on a tree it has already checked. A push of a one-file change took about 14 minutes end to end on a fresh worktree on a busy machine, and the same tree gets checked again in several ordinary flows:
- A push is retried after the connection drops during the hook or the remote rejects it, and the whole hook runs again on an identical tree.
- A contributor runs the pre-push stage by hand before pushing, then pushes, and it runs a second time.
- A commit is amended for its message only, or the same tree is pushed to a second remote.
Describe the solution you'd like
Record a pass and skip the cargo hooks when the key matches. After all three cargo hooks pass, write a stamp keyed by the tree hash of HEAD (git rev-parse HEAD^{tree}), a hash of the three hook definitions, and the toolchain identity (rustc -vV and the OS). Keep it under the git common directory so every worktree of a clone shares it. On the next push, if a stamp with the same key exists, skip those three hooks and say so in the output, for example "skipped: this tree passed at ; remove to force a re-run". Details:
verify-commitskeeps running every time, because it checks commit metadata (signatures and sign-off), which is not a function of the tree.- Any change to the tree changes the key, so a rebase onto a newer
main, an amend that changes content, or a new commit all re-run the full hooks. - Only a fully green run writes a stamp, so a failed or interrupted hook can never open the skip.
- The checks are a function of the tree, the hook definitions and the toolchain, so a skip covers what the re-run would have covered, apart from tests that are themselves flaky.
Describe alternatives you've considered
- Do nothing: every retry pays the full cost.
- Skip the hook with an environment variable or
--no-verify. That skips the checks for a tree that never passed them, andAGENTS.mdasks contributors not to bypass hooks, so it solves a different problem less safely. - Rely on cargo's incremental cache. It makes the second run faster but still re-runs the whole test suite, since
cargo testdoes not cache test results. - Narrow the hooks to the affected crates, (dev: narrow the pre-push cargo hooks to the crates a push affects #895): it reduces the cost of every run, while this removes repeated runs on the same content, and the two combine.
Additional context
Open questions for maintainers:
AGENTS.mdsection 8 asks for the quality gate to be run; a stamp keeps the guarantee that this exact tree passed but not that it was run during this push, so the wording would need a line to say so.- Inputs outside the tree can change a result:
RUSTFLAGS, feature environment variables and installed tools. The key would need to cover the ones that matter, or the skip message should name what it did not cover. - Where stamps live and when they expire (for example keep the last N, or drop after some days) so the directory does not grow.
- Behaviour on Windows and WSL, where the hook may run under a different shell and path style.
Related: #895, the proposal to narrow the cargo hooks to the crates a push affects.
Activity