-
Notifications
You must be signed in to change notification settings - Fork 871
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
132 lines (115 loc) · 5.11 KB
/
.pre-commit-config.yaml
File metadata and controls
132 lines (115 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# 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: v6.0.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"
- id: end-of-file-fixer
exclude_types: ["image", "jupyter"]
exclude: ".*\\.excalidraw"
- id: trailing-whitespace
exclude_types: ["image", "jupyter"]
- repo: https://github.com/psf/black
rev: 25.11.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: v21.1.8
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.47.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/crate-ci/typos
rev: v1.44.0
hooks:
- id: typos
name: Check for typos
args: ["--config", "build_tools/linters/typos.toml", "--force-exclude"]
- repo: https://github.com/jlebar/pre-commit-hooks.git
rev: f2d115a052860b09b2888b4f104be614bf3b4779
hooks:
- id: do-not-submit
- repo: local
hooks:
- id: buildifier
name: Run buildifier
entry: buildifier
language: golang
# Pinned to v7.1.2, but of course we can't use a tag because semver
# and "go install" just don't work together???
# This makes absolutely no sense and the maintainers have no intention
# of improving it or at least explaining it as hundreds of developers
# search for basic support: https://github.com/golang/go/issues/35732.
# Docs are technically at https://go.dev/ref/mod#go-install ¯\_(ツ)_/¯
additional_dependencies:
[
"github.com/bazelbuild/buildtools/buildifier@1429e15ae755a6762d0edf9198062dc6ed04408d",
]
files: '^(.*/)?(BUILD\.bazel|BUILD|WORKSPACE|WORKSPACE\.bazel|WORKSPACE\.bzlmod|MODULE\.bazel)$|\.BUILD$|\.bzl$'
# Pin the language version so other system version are _not_ used.
# Older go versions used different syntax for "go install" (which is
# apparently different from "go get" and "go build"), so for this to
# work reliably at all we need to ensure at least some minimum. Syntax
# probably changed again in a future version, whatever.
language_version: "1.16"
# Convert BUILD.bazel files to CMakeLists.txt files in two passes to
# avoid potential race conditions.
# Note: this passes file names to the tool. The tool can also be run
# manually with no arguments specified to walk directories on its own.
# Keep the top level directories here in sync with .bazel_to_cmake.cfg.py.
- id: bazel_to_cmake_1
name: Run bazel_to_cmake.py on BUILD.bazel files
language: python
entry: ./build_tools/bazel_to_cmake/bazel_to_cmake.py
files: '^(compiler|runtime|samples|tests|tools)/(.*/)?(BUILD\.bazel)$'
- id: bazel_to_cmake_2
name: Run bazel_to_cmake.py on CMakeLists.txt files
language: python
entry: ./build_tools/bazel_to_cmake/bazel_to_cmake.py
files: "^(compiler|runtime|samples|tests|tools)/(.*/)?(CMakeLists.txt)$"
- id: check_path_lengths
name: Check for excessively long path lengths
language: fail
entry: Path lengths relative to the root should be < 75 characters (run ./build_tools/scripts/check_path_lengths.py for detailed output)
# The regex includes/excludes here should roughly match the behavior of
# the check_path_lengths.py script.
files: '^compiler/.{66,}/\w+\.'
exclude: "test/"
- id: build_file_names
name: Check Bazel file names
entry: Files should be named BUILD.bazel instead of BUILD
language: fail
files: "BUILD$"
- id: generate_capi_exports
name: Regenerate CAPI export files
entry: compiler/src/iree/compiler/API/generate_exports.py
language: python
files: '^compiler/bindings/c/iree/compiler/.*\.h$'
pass_filenames: false
# TODO(scotttodd): mypy type checking for Python (https://mypy-lang.org/)