diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1ad6fd8094..cec3cfc835 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,6 +4,7 @@ .claude/ @DataDog/apm-common-components-core .clang-format @DataDog/libdatadog +.pre-commit-config.yaml @DataDog/libdatadog-core .codecov.yml @DataDog/apm-common-components-core .cargo/* @DataDog/libdatadog-core .config/nextest.toml @DataDog/apm-common-components-core diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..b3295dc26d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,36 @@ +# Pre-commit configuration for libdatadog +# +# Install (GIT_CONFIG_GLOBAL=/dev/null works around DD core.hooksPath): +# GIT_CONFIG_GLOBAL=/dev/null pre-commit install +# GIT_CONFIG_GLOBAL=/dev/null pre-commit install --hook-type pre-push +# +# Mirrors CI checks from .github/workflows/lint.yml: +# pre-commit: cargo +nightly-2026-02-08 fmt --all +# pre-push: cargo clippy --workspace --all-targets --all-features -- -D warnings +# pre-commit: dd-rust-license-tool check (on dependency/license file changes) +repos: + - repo: local + hooks: + - id: cargo-fmt + name: cargo fmt + language: system + # Pinned to match CI (.github/workflows/lint.yml). Keep this in sync. + entry: cargo +nightly-2026-02-08 fmt --all -- + types: [rust] + pass_filenames: false + + - id: cargo-clippy + name: cargo clippy + language: system + entry: cargo clippy --workspace --all-targets --all-features -- -D warnings + types: [rust] + pass_filenames: false + stages: [pre-push] + + - id: license-3rdparty + name: dd-rust-license-tool check + language: system + # CI pins version 1.0.6 — install with: cargo install dd-rust-license-tool --version 1.0.6 + entry: dd-rust-license-tool check + files: (Cargo\.toml|Cargo\.lock|license-tool\.toml|LICENSE-3rdparty\.csv)$ + pass_filenames: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bfdd932fea..0abbae2feb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,6 +91,9 @@ If you'd like CI to automatically format your code and commit the changes to you label to your pull request. This will trigger a one-time formatting commit if any changes are needed. If you push additional commits after labeling, remove and re-add the label to re-run formatting. +Optionally, you can install [pre-commit](https://pre-commit.com/) hooks to run formatting and clippy checks locally +before they hit CI. See `.pre-commit-config.yaml` for setup instructions. + ## Commit Message Guidelines This project uses [Conventional Commits](https://www.conventionalcommits.org/) for commit messages and pull request titles.