Repository navigation
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
115 lines (115 loc) · 6.59 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
115 lines (115 loc) · 6.59 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
default_language_version:
python: python3
# `pre-commit install` also installs the pre-push hook java-impact-map needs; every other
# hook keeps running at commit only.
default_install_hook_types: [pre-commit, pre-push]
default_stages: [pre-commit]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-json
# TODO: investigate and fix or remove the excluded files. The first
# three carry real JSON issues (duplicate keys, malformed/empty
# content) that pre-commit-hooks v2.3.0 didn't catch; v5.0.0 does.
# The last is an intentionally malformed test fixture.
exclude: |
(?x)^(
.*vscode.*|
openmetadata-spec/src/main/resources/rdf/contexts/dataAsset\.jsonld|
ingestion/examples/sample_data/pipelines/tasks\.json|
openmetadata-service/src/main/resources/dataInsights/opensearch/indexSettingsTemplate\.json|
openmetadata-ui/src/main/resources/ui/playwright/test-data/odcs-examples/invalid-malformed\.json
)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.12
hooks:
- id: ruff-check
files: ^(ingestion|openmetadata-airflow-apis)/
args: ["--fix", "--config", "ingestion/pyproject.toml"]
- id: ruff-format
files: ^(ingestion|openmetadata-airflow-apis)/
args: ["--config", "ingestion/pyproject.toml"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
- id: prettier
files: ^openmetadata-service/src/main/resources/json/schema/
- repo: local
hooks:
- id: google-style-java
name: Google Java Code Style for Java
description: Formats code in Google's Java codestyle with 120 line length.
entry: scripts/format-code.sh
language: script
files: \.java$
require_serial: true
- id: token-audit
name: Design token audit (no hardcoded CSS values)
description: Fails if committed UI CSS/LESS contains hardcoded colors or spacing instead of design tokens. See openmetadata-ui/src/main/resources/ui/specs/.
entry: node openmetadata-ui/src/main/resources/ui/scripts/token-audit.js
language: system
files: ^openmetadata-ui/src/main/resources/ui/src/.*\.(less|css)$
require_serial: true
- id: token-drift
name: Design token drift (generated files, token refs, spec links)
description: Fails if tokens.css / token-reference.md are stale (run yarn token-gen), a referenced token is undefined, or a component spec links to a missing file.
entry: node openmetadata-ui/src/main/resources/ui/scripts/design-tokens/check-drift.js
language: system
files: ^openmetadata-ui/src/main/resources/ui/(src/styles/tokens\.css|src/.*\.(less|css)|specs/.*\.md)$
pass_filenames: false
require_serial: true
- id: ui-prettier
name: Prettier (UI)
description: Fails if changed UI TS/TSX/JS/JSX/JSON is not prettier-formatted (matches CI ui-checkstyle). Fix with `yarn --cwd openmetadata-ui/src/main/resources/ui ui-checkstyle:changed`.
entry: scripts/check-ui-format.sh
language: script
files: ^(openmetadata-ui/src/main/resources/ui/(src|playwright)|openmetadata-ui-core-components/src/main/resources/ui/src)/.*\.(ts|tsx|js|jsx|json)$
exclude: /(generated|jsons)/
require_serial: true
- id: ui-license-header
name: Apache-2.0 license header (UI)
description: Fails if a changed UI source file is missing the Apache-2.0 header (matches CI ui-checkstyle). Fix with `yarn --cwd openmetadata-ui/src/main/resources/ui license-header-fix`.
entry: scripts/check-ui-license.sh
language: script
files: ^(openmetadata-ui/src/main/resources/ui/(src|playwright)|openmetadata-ui-core-components/src/main/resources/ui/src)/.*\.(ts|tsx|js|jsx)$
exclude: /generated/
require_serial: true
- id: tw-audit
name: Tailwind audit (no hardcoded values in TSX)
description: Fails if committed .tsx/.ts uses arbitrary Tailwind color/spacing/radius values that map to a design-system utility (e.g. tw:bg-[#2e90fa] -> tw:bg-brand-500).
entry: node openmetadata-ui/src/main/resources/ui/scripts/tw-audit.js
language: system
files: ^openmetadata-ui/src/main/resources/ui/src/.*\.(tsx|ts|jsx|js)$
require_serial: true
- id: tw-deprecation-guard
name: Antd + Less + raw-SVG deprecation guard (no new debt)
description: Fails if a change adds a new .less file, a new `import ... from 'antd'`, a new assets/svg .svg file, or a new import from assets/svg. Existing usage is fine; use UntitledUI + Tailwind + @openmetadata/ui-core-components/icons for new work.
entry: node openmetadata-ui/src/main/resources/ui/scripts/tw-deprecation-guard.js
language: system
files: ^openmetadata-ui/src/main/resources/ui/src/.*\.(tsx|ts|jsx|js|less|svg)$
pass_filenames: false
require_serial: true
- id: core-components-i18n
name: core-components i18n checks (gates 1+2+3)
description: Fails if core-components `t()` keys, locale files, or the language-set are out of sync. Run `yarn check-i18n-all` in openmetadata-ui-core-components/src/main/resources/ui.
entry: bash -c 'cd openmetadata-ui-core-components/src/main/resources/ui && yarn check-i18n-all'
language: system
files: ^openmetadata-ui-core-components/src/main/resources/ui/src/.*\.(ts|tsx|json)$
pass_filenames: false
- id: decision-records
name: Decision records (docs/decisions/ format, ADR citations)
description: Fails if a record under docs/decisions/ breaks the format, or an ADR citation or docs/decisions/ path in any tracked file resolves to no record. See docs/decisions/README.md.
entry: python3 scripts/harness/check_decision_records.py
language: system
pass_filenames: false
require_serial: true
- id: java-impact-map
name: Java impact map owns the code and ITs this branch adds
description: Fails the push while the branch leaves Java code or ITs without an area in .github/java-tests/impact-map.json, empties a pattern or breaks a map rule. The message names the glob to add and the likely area.
# The commit being pushed, not the working tree: an unstaged map fix must not pass.
entry: bash -c 'python3 .github/scripts/plan_local_java_tests.py --check-branch --head "${PRE_COMMIT_TO_REF:-HEAD}"'
language: system
pass_filenames: false
always_run: true
stages: [pre-push]