Skip to content

chore: run cargo fmt, doc, and dylint checks in husky pre-push#12035

Merged
zkochan merged 1 commit into
mainfrom
dylint-hook
May 28, 2026
Merged

chore: run cargo fmt, doc, and dylint checks in husky pre-push#12035
zkochan merged 1 commit into
mainfrom
dylint-hook

Conversation

@zkochan

@zkochan zkochan commented May 28, 2026

Copy link
Copy Markdown
Member

Summary

  • The Rust pre-push checks were sitting in pacquet/.githooks/pre-push, which only ran if someone manually executed just install-hooks. That recipe set core.hooksPath = pacquet/.githooks, which also disables every husky-managed TypeScript hook (commit-msg, pre-commit, etc.) — so in practice the script never ran for anyone on a clean pnpm install setup.
  • Move the bash logic to pacquet/scripts/pre-push-rust.sh and call it from .husky/pre-push after compile-only + lint --quiet. Drop the install-hooks recipe (and its call from init) so nobody re-points core.hooksPath away from husky by mistake.
  • The script now also runs cargo doc --no-deps --workspace --all-features (with RUSTDOCFLAGS=-D warnings) and cargo dylint --all -- --all-targets --workspace (with RUSTFLAGS=-D warnings), matching CI. --workspace already covers both pacquet/crates/* and registry/crates/* because they share the root Cargo workspace.
  • cargo-dylint is detected at runtime and skipped with a yellow warning if not installed; cargo / taplo absence is handled the same way the original script did.

Migration note

Anyone whose machine ran just install-hooks previously has core.hooksPath pointing at the now-deleted pacquet/.githooks/ directory. The next pnpm install reruns husky's prepare script and resets the path to .husky/_ automatically — no manual fix needed.

Test plan

  • git push --dry-run runs cargo fmt --check, cargo doc, and cargo dylint and fails fast on any warning
  • Without cargo-dylint on PATH the dylint step prints a yellow skip warning and the push still proceeds
  • Without cargo on PATH all three Rust checks are skipped with a single warning
  • TypeScript hooks under .husky/ still fire (commit-msg runs commitlint, pre-commit blocks direct main commits in Claude Code, etc.)

Written by an agent (Claude Code, claude-opus-4-7).

Summary by CodeRabbit

  • Chores

    • Simplified project initialization by streamlining Git hook setup.
    • Enhanced pre-push validation to include additional Rust checks for documentation and code quality.
  • Documentation

    • Updated contribution and development guides to reflect the revised setup workflow.

Review Change Stack

The Rust workspace's pre-push checks were sitting in
`pacquet/.githooks/pre-push` and only fired if a developer ran
`just install-hooks`, which would also disable every husky-managed
TypeScript hook by replacing `core.hooksPath`. Move the bash logic to
`pacquet/scripts/pre-push-rust.sh`, invoke it from `.husky/pre-push`
alongside the existing TS compile and lint checks, and drop the
`install-hooks` recipe so nobody re-points `core.hooksPath` by mistake.

The script now also runs `cargo doc --no-deps --workspace --all-features`
(with `RUSTDOCFLAGS=-D warnings`) and `cargo dylint --all -- --all-targets
--workspace` (with `RUSTFLAGS=-D warnings`), matching CI. `--workspace`
covers both `pacquet/crates/*` and `registry/crates/*` since they share
the root Cargo workspace.
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a965e24f-c14f-4f46-8e2c-5cb13266bba9

📥 Commits

Reviewing files that changed from the base of the PR and between 7c9a6c2 and 48d7bd7.

📒 Files selected for processing (6)
  • .husky/pre-push
  • justfile
  • pacquet/.githooks/pre-push
  • pacquet/AGENTS.md
  • pacquet/CONTRIBUTING.md
  • pacquet/scripts/pre-push-rust.sh

📝 Walkthrough

Walkthrough

The PR migrates the repository's Git pre-push hook from a manually-installed .githooks/ directory to Husky's unified hook system. A new Bash script adds Rust documentation and linting checks alongside existing formatting validation, the justfile removes the old hook installation step, and documentation is updated to reflect the new flow.

Changes

Pre-push Hook Migration to Husky with Expanded Checks

Layer / File(s) Summary
New Rust pre-push check script
pacquet/scripts/pre-push-rust.sh
Introduces conditional Rust checks: cargo fmt, cargo doc with warning flags, and cargo dylint (when available), plus taplo TOML checks, with failure tracking and exit 1 abort on any failure.
Husky hook invocation
.husky/pre-push
Extends the pre-push hook to run bash pacquet/scripts/pre-push-rust.sh after TypeScript compile and lint steps, unifying Rust and TypeScript hygiene checks in one hook.
Remove git-config-based hooks
justfile
Removes the install-hooks recipe and its call from init, eliminating the git config core.hooksPath setup for .githooks/ directory.
Documentation updates
pacquet/CONTRIBUTING.md, pacquet/AGENTS.md
Updates setup and hygiene guidance to describe the Husky pre-push hook, the new cargo doc and cargo dylint checks, and conditional tool availability messaging.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • pnpm/pnpm#11969: Both PRs directly affect how cargo dylint is executed in the pacquet repo—this PR adds a pre-push script that runs cargo dylint, while that PR pins the cargo-dylint/dylint-link versions in CI to ensure that cargo dylint works.

Poem

🐰 The hooks hop from .githooks to Husky's care,
Rust checks now dance in the pre-push air—
cargo fmt, doc, dylint in the scene,
All together, keeping the repo clean!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dylint-hook

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zkochan zkochan marked this pull request as ready for review May 28, 2026 18:14
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Review Summary by Qodo

Integrate Rust checks into husky pre-push hook with doc and dylint

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Integrate Rust pre-push checks into husky workflow
• Add cargo doc and cargo dylint validation to pre-push hook
• Move pre-push logic from .githooks to pacquet/scripts/pre-push-rust.sh
• Remove install-hooks recipe and core.hooksPath configuration
• Update documentation to reflect new hook setup
Diagram
flowchart LR
  A["Old: .githooks/pre-push<br/>fmt + taplo only"] -->|Migrate| B["New: pacquet/scripts/pre-push-rust.sh<br/>fmt + doc + dylint + taplo"]
  C[".husky/pre-push<br/>TypeScript checks"] -->|Call| B
  D["justfile<br/>Remove install-hooks"] -->|Simplify| E["husky prepare<br/>Auto-configures hooks"]
  B -->|Runtime detection| F["cargo-dylint<br/>optional, skip if missing"]

Loading

Grey Divider

File Changes

1. pacquet/scripts/pre-push-rust.sh ✨ Enhancement +51/-0

New Rust pre-push validation script with doc and dylint

• New script implementing Rust pre-push checks (fmt, doc, dylint, taplo)
• Runs cargo fmt with --check flag to detect unformatted files
• Executes cargo doc with RUSTDOCFLAGS=-D warnings for rustdoc validation
• Runs cargo dylint with RUSTFLAGS=-D warnings for linting
• Detects cargo and cargo-dylint at runtime, skips gracefully if missing
• Provides colored output (yellow for checks, red for failures)

pacquet/scripts/pre-push-rust.sh


2. .husky/pre-push ✨ Enhancement +1/-1

Add Rust script invocation to husky pre-push hook

• Appends call to pacquet/scripts/pre-push-rust.sh after TypeScript checks
• Maintains existing pnpm compile-only and lint --quiet commands
• Integrates Rust checks into unified husky pre-push workflow

.husky/pre-push


3. justfile ⚙️ Configuration changes +0/-5

Remove install-hooks recipe and simplify init

• Removes install-hooks recipe that configured core.hooksPath
• Removes install-hooks call from init recipe
• Simplifies init to only install cargo tools via cargo-binstall
• Relies on husky prepare script for hook configuration

justfile


View more (3)
4. pacquet/.githooks/pre-push Miscellaneous +0/-35

Delete obsolete .githooks/pre-push file

• Deletes old pre-push hook file (35 lines removed)
• Functionality migrated to pacquet/scripts/pre-push-rust.sh
• No longer needed with husky-managed hooks

pacquet/.githooks/pre-push


5. pacquet/AGENTS.md 📝 Documentation +5/-3

Update agent documentation for new hook setup

• Updates hook documentation to reference new husky pre-push setup
• Documents that pre-push runs fmt, taplo, cargo doc, and cargo dylint
• Notes that cargo-dylint is detected at runtime and skipped if missing
• Removes reference to manual just install-hooks command

pacquet/AGENTS.md


6. pacquet/CONTRIBUTING.md 📝 Documentation +1/-1

Update contributing guide for husky pre-push integration

• Updates setup instructions to reflect husky-based hook configuration
• Clarifies that pnpm install wires up husky automatically
• Documents that pre-push hook runs format, doc, and dylint checks
• Removes reference to manual .githooks directory configuration

pacquet/CONTRIBUTING.md


Grey Divider

Qodo Logo

@zkochan zkochan merged commit e375a58 into main May 28, 2026
18 of 19 checks passed
@zkochan zkochan deleted the dylint-hook branch May 28, 2026 18:16
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.

1 participant