Skip to content

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

Merged
pawelchcki merged 6 commits into
mainfrom
commit_hook
May 15, 2026
Merged

chore: add pre-commit config for local Rust lint checks#1871
pawelchcki merged 6 commits into
mainfrom
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-2026-02-08 fmt --all and dd-rust-license-tool check (only on Cargo.toml/lock and license input 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 a million similar frameworks, but this is a nice example.

Additional Notes

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.)

rustfmt is pinned to nightly-2026-02-08 to match CI. Common Components will follow up with a rust-toolchain.toml to make this easier to keep in sync.

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.

Comment thread .pre-commit-config.yaml
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
- 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-commenter commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.63%. Comparing base (0a3304c) to head (19cd971).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1871   +/-   ##
=======================================
  Coverage   72.63%   72.63%           
=======================================
  Files         451      451           
  Lines       74687    74687           
=======================================
+ Hits        54249    54250    +1     
+ Misses      20438    20437    -1     
Components Coverage Δ
libdd-crashtracker 65.34% <ø> (+0.04%) ⬆️
libdd-crashtracker-ffi 37.68% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 85.97% <ø> (ø)
libdd-data-pipeline-ffi 71.04% <ø> (ø)
libdd-common 79.81% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.34% <ø> (ø)
libdd-telemetry-ffi 31.36% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.17% <ø> (ø)
libdd-profiling 81.57% <ø> (-0.03%) ⬇️
libdd-profiling-ffi 64.51% <ø> (ø)
libdd-sampling 97.25% <ø> (ø)
datadog-sidecar 29.09% <ø> (ø)
datdog-sidecar-ffi 9.67% <ø> (ø)
spawn-worker 48.86% <ø> (ø)
libdd-tinybytes 93.16% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.39% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 89.59% <ø> (ø)
libdd-tracer-flare 86.88% <ø> (ø)
libdd-log 74.83% <ø> (ø)
🚀 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

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 72.64% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 19cd971 | Docs | Datadog PR Page | 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.so 7.57 MB 7.57 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 81.84 MB 81.84 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.01 MB 10.01 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 98.03 MB 98.03 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 24.48 MB 24.48 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 79.87 KB 79.87 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 180.22 MB 180.21 MB -0% (-8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 913.96 MB 913.96 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 7.73 MB 7.73 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 79.87 KB 79.87 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 23.17 MB 23.17 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 45.36 MB 45.36 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.09 MB 21.09 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 81.11 KB 81.11 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 184.41 MB 184.40 MB -0% (-16.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 900.44 MB 900.44 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 5.99 MB 5.99 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 81.11 KB 81.11 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 24.81 MB 24.81 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 42.87 MB 42.87 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 72.93 MB 72.93 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.42 MB 8.42 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 90.70 MB 90.70 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.06 MB 10.06 MB 0% (0 B) 👌

@pawelchcki pawelchcki marked this pull request as ready for review May 14, 2026 09:03
@pawelchcki pawelchcki requested a review from a team as a code owner May 14, 2026 09:03
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23f46b1eba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .pre-commit-config.yaml Outdated
- id: cargo-fmt
name: cargo fmt
language: system
entry: cargo +nightly fmt --all --
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pin rustfmt to the CI nightly

When a developer's local nightly toolchain is newer or older than the CI-pinned nightly-2026-02-08 used in .github/workflows/lint.yml, this hook can rewrite files with a different rustfmt version than CI checks. That makes the local hook non-deterministic and can leave contributors with formatting that passes locally but is rejected by CI; use the same pinned toolchain here, e.g. +nightly-2026-02-08.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a good suggestion. Could you pin to nightly-2026-02-08 for now? I'll create a ticket for Common Components to follow up and setup a rust-toolchain.toml file for the repo to make managing this easier in the future.

@ekump
Copy link
Copy Markdown
Contributor

ekump commented May 14, 2026

No objections from me on introducing hooks.

Pin to nightly-2026-02-08 so the hook can't produce formatting that
diverges from .github/workflows/lint.yml. Also link the config from
CONTRIBUTING.md so contributors can find it.
@pawelchcki pawelchcki requested a review from a team as a code owner May 14, 2026 18:31
@pawelchcki pawelchcki requested a review from ekump May 14, 2026 18:34
@pawelchcki
Copy link
Copy Markdown
Contributor Author

thanks @ekump I added your suggestions

@pawelchcki
Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 14, 2026

View all feedbacks in Devflow UI.

2026-05-14 19:00:28 UTC ℹ️ Start processing command /merge


2026-05-14 19:00:35 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-05-14 19:09:07 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 49m (p90).


2026-05-14 21:09:47 UTCMergeQueue: The build pipeline has timeout

The merge request has been interrupted because the build 0 took longer than expected. The current limit for the base branch 'main' is 120 minutes.

@pawelchcki pawelchcki merged commit ec2fd4e into main May 15, 2026
114 of 115 checks passed
@pawelchcki pawelchcki deleted the commit_hook branch May 15, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants