# To run pre-commit hooks, first install pre-commit: # - `pip install pre-commit==${PRE_COMMIT_VERSION}` # # Then, run the following command to install the git hook scripts: # - `pre-commit install` # You can run all configured hooks against all files with: # - `pre-commit run --all-files` # To manually run a specific hook, use: # - `pre-commit run --all-files` # To run the hooks against only the staged files, use: # - `pre-commit run` repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0 hooks: - id: check-added-large-files args: [--maxkb=400, --enforce-all] - id: check-executables-have-shebangs - id: trailing-whitespace - id: end-of-file-fixer - id: check-merge-conflict args: [--assume-in-merge] - repo: local hooks: - id: clang-tidy name: "clang-tidy (enable with: TIDY=1)" entry: ./bin/pre-commit/clang_tidy_check.py language: python types_or: [c++, c] # .ipp fragments are included by their owning header rather than compiled # as standalone translation units, so they have no compile_commands.json # entry to lint (verify_headers checks them transitively). exclude: '^include/xrpl/protocol_autogen|\.ipp$' # run-clang-tidy --fix may edit headers included by files it is not run on, # so pre-commit must not split the files across parallel hook invocations. # The script determines the staged files itself and lets run-clang-tidy # handle parallelism internally. pass_filenames: false - id: fix-include-style name: fix include style entry: ./bin/pre-commit/fix_include_style.py language: python types_or: [c++, c] exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_entries)/ - id: fix-pragma-once name: fix missing '#pragma once' declarations in header files language: python entry: ./bin/pre-commit/fix_pragma_once.py files: \.(h|hpp)$ - id: check-doxygen-style name: check Doxygen comment style entry: ./bin/pre-commit/check_doxygen_style.py language: python types_or: [c++, c] - id: fix-gtest-names name: "fix gtest names: CamelCase suite, snake_case test case" entry: ./bin/pre-commit/fix_gtest_names.py language: python types_or: [c++, c] - repo: https://github.com/pre-commit/mirrors-clang-format rev: e2b496dc2bd8340c2524cb9a2d2a943cde1bb6df # frozen: v23.1.1 hooks: - id: clang-format args: [--style=file] types_or: [c++, c, proto] exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_entries)/ - repo: local hooks: - id: cargo-fmt name: cargo fmt entry: cargo fmt --manifest-path crates/Cargo.toml --all language: system types: [rust] pass_filenames: false # rustfmt formats the whole workspace - id: check-coverage-attrs name: check Rust coverage attributes entry: ./bin/pre-commit/check_rust_coverage_attrs.py language: python files: ^crates/.*\.rs$ - repo: https://github.com/BlankSpruce/gersemi-pre-commit rev: f1c4833f8cf23c6d952673abc73525411a5719e8 # frozen: 0.29.1 hooks: - id: gersemi - repo: https://github.com/rbubley/mirrors-prettier rev: ef4a397f916211b4a39ccf9d3d9cbb6562157251 # frozen: v3.9.9 hooks: - id: prettier args: [--end-of-line=auto] # Scoped to package/: the rest of the repo's Python has pre-existing findings, # so widening these is its own change. - repo: https://github.com/astral-sh/ruff-pre-commit rev: a56c0b927e6465d37cae3e97d35d4d18ab2b96cd # frozen: v0.16.9 hooks: - id: ruff-check args: [--fix] files: ^package/.*\.py$ - repo: https://github.com/psf/black-pre-commit-mirror rev: 4160603246a6b365d4a2af661c6d71b0a0f50478 # frozen: 26.5.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy rev: 7ff8d35ae36a7d2b968f2f90b4c723e292e594ee # frozen: v2.3.1 hooks: - id: mypy args: [--strict] files: ^package/.*\.py$ - repo: https://github.com/scop/pre-commit-shfmt rev: 479be5958357ba5ab65ce47172117348516860e9 # frozen: v3.14.1-1 hooks: - id: shfmt args: [--write, --indent=4, --case-indent=true] - repo: local hooks: - id: format-inline-bash-workflows name: "format `run:` blocks in workflows/actions" entry: ./.github/scripts/format-inline-bash.py language: python files: ^\.github/(workflows|actions)/.*\.ya?ml$ - id: format-inline-bash-markdown name: "format ```bash blocks in markdown" entry: ./.github/scripts/format-inline-bash.py language: python files: \.md$ - repo: https://github.com/streetsidesoftware/cspell-cli rev: f5c5d72342f35643988a9ffa0705c05bd3ff8383 # frozen: v10.3.0 hooks: - id: cspell name: check changed files spelling exclude: | (?x)^( \.cspell\.config\.yaml| include/xrpl/protocol_autogen/(transactions|ledger_entries)/.* )$ - id: cspell name: check commit message spelling args: - --no-must-find-files - --no-progress - --no-summary stages: [commit-msg] - repo: local hooks: - id: nix-fmt name: Format Nix files entry: | bash -c ' if command -v nix &> /dev/null || [ "$GITHUB_ACTIONS" = "true" ]; then nix --extra-experimental-features "nix-command flakes" fmt "$@" else echo "Skipping nix-fmt: nix not installed and not in GitHub Actions" exit 0 fi ' -- language: system types: - nix pass_filenames: true exclude: | (?x)^( external/.*| .github/scripts/levelization/results/.*\.txt| src/tests/libxrpl/protocol_autogen/(transactions|ledger_entries)/.* )$