chore: add pre-commit config for local Rust lint checks#1871
Draft
pawelchcki wants to merge 3 commits intomainfrom
Draft
chore: add pre-commit config for local Rust lint checks#1871pawelchcki wants to merge 3 commits intomainfrom
pawelchcki wants to merge 3 commits intomainfrom
Conversation
Mirrors CI lint checks for local development: - pre-commit: cargo fmt (nightly) and dd-rust-license-tool check - pre-push: cargo clippy --workspace
There was a problem hiding this comment.
Pull request overview
Adds an opt-in pre-commit configuration to run key Rust linting checks locally (fmt, clippy, and 3rd-party license validation) to better align developer workflows with CI and reduce CI round-trips.
Changes:
- Introduce
.pre-commit-config.yamlwith local hooks forcargo fmt(nightly),cargo clippy(pre-push), anddd-rust-license-tool check(on Cargo file changes).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Clarify nightly pinning in header comment (CI pins nightly-2026-02-08) - Expand license check file filter to include license-tool.toml and LICENSE-3rdparty.csv - Add version comment for dd-rust-license-tool (CI pins 1.0.6)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1871 +/- ##
==========================================
- Coverage 71.70% 71.65% -0.05%
==========================================
Files 429 429
Lines 67916 67916
==========================================
- Hits 48697 48665 -32
- Misses 19219 19251 +32
🚀 New features to boost your workflow:
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: d93673b | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Contributor
|
I am a fan of this. Totally not opposed for this to go in, especially since this is opt in |
Contributor
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
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.
What does this PR do?
Adds a
.pre-commit-config.yamlthat mirrors CI lint checks for local development:cargo +nightly fmt --allanddd-rust-license-tool check(only on Cargo.toml/lock changes)cargo clippy --workspace --all-targets --all-features -- -D warningsMotivation
Since I started using coding agents, I find pre-commit hooks invaluable — they greatly reduce back-and-forths and CI costs. The more checks that run locally before code leaves my machine, the fewer wasted CI cycles and review round-trips.
I'm not specifically promoting pre-commit (the Python tool), but it's a nice framework that's trivial to install, especially with
uv:There are probably million and one similar frameworks, but its a nice example.
This PR is only a demo and a discussion starter. If the libdatadog team likes the idea, I personally recommend it.
Additional Notes
This is completely opt-in. If you haven't configured the git hooks locally, none of these checks will fire. Install with:
(
GIT_CONFIG_GLOBAL=/dev/nullworks around the DD globalcore.hooksPathsetting.)How to test the change?
.rsfile and commit —cargo fmtruns automaticallycargo clippyruns before the push goes throughCargo.tomland commit —dd-rust-license-tool checkruns