Skip to content

perf(dev): run only the pre-commit checks relevant to the staged changes #6095

In progress

Description

@purp

User Story

I maintain OpenShell and commit from a local checkout with the repository's pre-commit hook installed. I need the hook to run the checks that the staged change can affect, so that a documentation commit doesn't wait on Rust compilation.

Problem Statement

mise run pre-commit runs fmt and lint in full for every commit. A commit that changed one Markdown file under rfc/ ran rust:lint, which invokes Clippy across the workspace and more than a dozen additional manifests, plus Helm lint, proto lint, Python checks, and license checks. None of those could be affected by the change. Only the Markdown lint and format checks were relevant.

Impact / Why This Matters

The commit took several minutes, and one attempt failed on an unrelated compiler crash in rust:lint. Slow, irrelevant checks push contributors and agents toward skipping the hook, which removes the protection it provides. This is one part of the measurement and optimization work in #5571.

Proposed Design

The pre-commit hook would choose its checks from the staged paths. For example:

  • Markdown-only changes run Markdown lint and format.
  • Rust source, manifest, or lockfile changes run the Rust format, lockfile, and lint checks.
  • Helm chart changes run Helm lint and docs checks.
  • Proto changes run proto lint and the checks that depend on generated code.
  • Changes to shared inputs such as task definitions or toolchain configuration run everything.

CI would keep running the full set, so the hook's selection only affects local feedback time.

Acceptance Criteria

  • A commit that stages only Markdown runs no Rust, Helm, proto, or Python checks.
  • A commit that stages Rust source runs the Rust checks.
  • The mapping from paths to checks lives in one place and is documented for contributors.
  • A change the mapping does not recognize runs the full set.
  • There is a documented way to run the full set locally.

Alternatives Considered

  • Keep running everything and make it faster. Caching helps, but a full Clippy pass is still wasted work for a docs change, and it exposes unrelated commits to unrelated failures.
  • Move the slow checks out of the hook entirely and rely on CI. This loses fast local feedback for Rust changes, where it is most useful.

Activity

  1. self-assigned this
    on Nov 30, 2026
  2. added
    area:build
    topic:dx
    on Nov 30, 2026
  3. purp commented on Dec 4, 2026

    @purp
    ContributorAuthor

    🏗️ build-plan

    Implement staged-path selection as the first iteration of #5571. Keep the existing area checks, formatter behavior, and CI tasks; do not add runtime limits, telemetry, package-level Rust pruning, or move Clippy in this PR.

    • Route mise run pre-commit through a dependency-free Python selector that reads the Git index directly with NUL-delimited paths. Do not parse the lossy STAGED environment variable from older local hooks.
    • Keep the mapping in that script: Markdown, Rust, Python, Helm, and proto changes select their existing check groups; overlapping inputs select the union. Proto inputs also select Rust/Python consumers. Unknown paths and shared task/tool configuration select the full set. Renames must consider both paths; deletions must still select their area.
    • Retain the existing full task graph as mise run pre-commit:full. Report selected tasks and provide --dry-run for inspecting selection. Empty staged sets run no checks.
    • Add regression tests using real temporary Git indexes, including docs-only, mixed changes, configuration/unknown fallback, initial commits, renames, deletes, unusual filenames, ignored legacy STAGED, full override, and failure propagation. Exercise task wiring without invoking unrelated compilers.
    • Document selection, full checks, and the existing limitation that tasks check/format working-tree contents rather than an isolated staged snapshot. Run focused script tests, format/lint, and a real Markdown-only selection smoke test before opening a draft PR closing perf(dev): run only the pre-commit checks relevant to the staged changes #6095.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:buildtopic:dx

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions