Skip to content

chore: add pre-commit config for local Rust lint checks#1871

Draft
pawelchcki wants to merge 3 commits intomainfrom
commit_hook
Draft

chore: add pre-commit config for local Rust lint checks#1871
pawelchcki wants to merge 3 commits intomainfrom
commit_hook

Conversation

@pawelchcki
Copy link
Copy Markdown
Contributor

@pawelchcki pawelchcki commented Apr 13, 2026

What does this PR do?

Adds a .pre-commit-config.yaml that mirrors CI lint checks for local development:

  • pre-commit: cargo +nightly fmt --all and dd-rust-license-tool check (only on Cargo.toml/lock changes)
  • pre-push: cargo clippy --workspace --all-targets --all-features -- -D warnings

Motivation

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:

uv tool install pre-commit

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/null pre-commit install
GIT_CONFIG_GLOBAL=/dev/null pre-commit install --hook-type pre-push

(GIT_CONFIG_GLOBAL=/dev/null works around the DD global core.hooksPath setting.)

How to test the change?

  1. Install hooks as above
  2. Modify a .rs file and commit — cargo fmt runs automatically
  3. Push — cargo clippy runs before the push goes through
  4. Modify a Cargo.toml and commit — dd-rust-license-tool check runs

Mirrors CI lint checks for local development:
- pre-commit: cargo fmt (nightly) and dd-rust-license-tool check
- pre-push: cargo clippy --workspace
Copilot AI review requested due to automatic review settings April 13, 2026 17:05
@pawelchcki pawelchcki marked this pull request as draft April 13, 2026 17:05
@pawelchcki pawelchcki marked this pull request as draft April 13, 2026 17:05
@pawelchcki pawelchcki marked this pull request as draft April 13, 2026 17:05
@pawelchcki pawelchcki marked this pull request as draft April 13, 2026 17:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yaml with local hooks for cargo fmt (nightly), cargo clippy (pre-push), and dd-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-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.65%. Comparing base (d83038c) to head (d93673b).
⚠️ Report is 1 commits behind head on main.

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     
Components Coverage Δ
libdd-crashtracker 66.05% <ø> (+0.01%) ⬆️
libdd-crashtracker-ffi 34.47% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 86.14% <ø> (ø)
libdd-data-pipeline-ffi 72.50% <ø> (ø)
libdd-common 79.16% <ø> (ø)
libdd-common-ffi 73.87% <ø> (ø)
libdd-telemetry 65.98% <ø> (ø)
libdd-telemetry-ffi 16.75% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 71.00% <ø> (-2.11%) ⬇️
libdd-profiling 81.62% <ø> (ø)
libdd-profiling-ffi 64.94% <ø> (ø)
datadog-sidecar 30.53% <ø> (ø)
datdog-sidecar-ffi 8.77% <ø> (ø)
spawn-worker 54.69% <ø> (ø)
libdd-tinybytes 93.16% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.24% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 88.72% <ø> (ø)
datadog-tracer-flare 86.88% <ø> (ø)
libdd-log 74.69% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 bot commented Apr 13, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 71.65% (-0.05%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: d93673b | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@gyuheon0h
Copy link
Copy Markdown
Contributor

I am a fan of this. Totally not opposed for this to go in, especially since this is opt in

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts bot commented Apr 13, 2026

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 83.25 MB 83.25 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.63 MB 7.63 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 99.29 MB 99.29 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.10 MB 10.10 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.16 MB 25.16 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 78.21 KB 78.21 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 184.22 MB 184.21 MB -0% (-8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 916.99 MB 916.99 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 7.88 MB 7.88 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 78.21 KB 78.21 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 23.64 MB 23.64 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 46.13 MB 46.13 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.63 MB 21.63 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 79.42 KB 79.42 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 188.30 MB 188.30 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 902.01 MB 902.01 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.12 MB 6.12 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 79.42 KB 79.42 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 25.31 MB 25.31 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 43.60 MB 43.60 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 74.38 MB 74.38 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.51 MB 8.51 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 91.66 MB 91.66 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.18 MB 10.18 MB 0% (0 B) 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants