Pre commit hook suite#109
Open
gloskull wants to merge 2 commits into
Open
Conversation
Add local pre-commit quality hook suite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Enforce repository-wide code quality gates locally before PRs by running deterministic checks for the Rust workspace and the usage dashboard.
Keep commit hooks fast and network-free by running only relevant checks and avoiding dependency installs inside the hook.
Make the hook easy to run manually and document its behavior for contributors.
Description
Add .pre-commit-config.yaml to register a repository-local hook utility-contracts-quality-suite scoped to contracts/, usage-dashboard/, the hook script, and the pre-commit config, and configured to receive changed filenames.
Add scripts/pre-commit-quality.sh, a POSIX shell runner that accepts --all or filenames, detects changed paths, and selectively runs cargo fmt --manifest-path "contracts/Cargo.toml" --all -- --check, cargo clippy --manifest-path "contracts/Cargo.toml" --all-targets --all-features -- -D warnings, cargo test --manifest-path "contracts/Cargo.toml" --all-features, and npm --prefix usage-dashboard run lint when applicable.
Add docs/PRE_COMMIT_QUALITY.md documenting architecture, quality gates, installation, manual execution, and operational notes.
Testing
Ran a syntax check with bash -n scripts/pre-commit-quality.sh, which succeeded.
Executed the script with representative filenames with scripts/pre-commit-quality.sh docs/PRE_COMMIT_QUALITY.md .pre-commit-config.yaml scripts/pre-commit-quality.sh, which completed successfully and correctly skipped unrelated checks.
Verified the hook file and script are present and executable by running the script in the repository root and observing expected behavior (selective skipping and success messages).
Closes #81