blob: 0406c803e887b6647dc6c0df7e83fd7d294a0dce [file] [log] [blame]
# Pre-commit (https://pre-commit.com) configuration for assorted lint checks.
#
# See https://pre-commit.com/hooks.html for more hooks.
exclude: "third_party/"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-merge-conflict
- id: check-yaml
# * Extensions can't be included in the mkdocs schema, so skip checking
# https://github.com/squidfunk/mkdocs-material/issues/6378
# * clang-format files use `---` to split for multiple languages,
# resulting in errors like `expected a single document in the stream`
exclude: "mkdocs.yml|.clang-format"
# TODO(scotttodd): enable once enough contributors are familiar with pre-commit
# - id: end-of-file-fixer
# exclude_types: ["image", "jupyter"]
# TODO(scotttodd): enable once enough contributors are familiar with pre-commit
# - id: trailing-whitespace
# exclude_types: ["image", "jupyter"]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
name: Run Black to format Python files
- repo: https://github.com/pre-commit/mirrors-clang-format
# Loosely track the most recent versions in
# * Runner images: https://github.com/actions/runner-images/
# * Editor extensions: https://github.com/microsoft/vscode-cpptools
rev: v18.1.3
hooks:
- id: clang-format
name: Run clang-format on C/C++/etc. files
exclude_types: ["jupyter"]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
hooks:
- id: markdownlint
name: Run markdownlint on .md files
args: ["--config", "docs/.markdownlint.yml"]
files: "docs/website/.*.md"
exclude: "mlir-dialects/!(index).md"
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: forbid-tabs
exclude: ".gitmodules|Makefile"
- repo: https://github.com/jlebar/pre-commit-hooks.git
rev: f2d115a052860b09b2888b4f104be614bf3b4779
hooks:
# TODO(scotttodd): Download as needed
# https://github.com/jlebar/pre-commit-hooks/issues/3
# TODO(scotttodd): enable when this works on Windows
# https://github.com/bazelbuild/buildtools/issues/914
# could try `git add . --renormalize`
# - id: bazel-buildifier
- id: do-not-submit
- repo: local
hooks:
- id: bazel_to_cmake
name: Run bazel_to_cmake.py
language: python
entry: ./build_tools/bazel_to_cmake/bazel_to_cmake.py
# TODO(scotttodd): run on BUILD.bazel/CMakeLists.txt files individually
always_run: true
pass_filenames: false
# TODO(scotttodd): replace with an official pre-commit hook?
# See https://github.com/pre-commit/pre-commit-hooks/issues/760
- id: check_path_lengths
name: Run check_path_lengths.py
language: python
entry: ./build_tools/scripts/check_path_lengths.py
always_run: true
pass_filenames: false
- id: build_file_names
name: Check Bazel file names
entry: Files should be named BUILD.bazel instead of BUILD
language: fail
files: "BUILD$"
# TODO(scotttodd): enable these checks when they work on Windows
# the generator scripts use \ on Windows instead of /
# - id: generate_cmake_e2e_test_artifacts_suite
# name: Run generate_cmake_e2e_test_artifacts_suite.py
# language: python
# entry: ./build_tools/testing/generate_cmake_e2e_test_artifacts_suite.py
# args: ["--output_dir", "./tests/e2e/test_artifacts"]
# # TODO(scotttodd): run only on relevant files
# always_run: true
# pass_filenames: false
# - id: generate_cmake_e2e_model_tests
# name: Run generate_cmake_e2e_model_tests.py
# language: python
# entry: ./build_tools/testing/generate_cmake_e2e_model_tests.py
# args: ["--output", "./tests/e2e/stablehlo_models/generated_e2e_model_tests.cmake"]
# # TODO(scotttodd): run only on relevant files
# always_run: true
# pass_filenames: false