Skip to content

Commit e6c7a71

Browse files
vanzan01jbampton
andauthored
Add yamllint pre-commit hook for YAML file standardization (#11017)
* Add yamllint pre-commit hook for YAML file standardization Add yamllint hook to .pre-commit-config.yaml to standardize YAML files across the project. Created .yamllint.yml configuration with relaxed rules to accommodate existing files. Fixed colon spacing in .asf.yaml to pass yamllint checks. Closes #10974 Signed-off-by: vanzan01 <[email protected]> * Add extra eol to .yamllint.yml Address review comment from DaanHoogland Signed-off-by: vanzan01 <[email protected]> * Move .yamllint.yml to .github/linters/ and improve file pattern - Move .yamllint.yml to .github/linters/ directory for better organization - Update pre-commit config to point to new location - Change file pattern to \.ya?ml$ as suggested Address review feedback from jbampton Signed-off-by: vanzan01 <[email protected]> * Update .pre-commit-config.yaml Co-authored-by: John Bampton <[email protected]> * Make yamllint more forgiving and exclude only k8s templates - Remove extensive file exclusions, keep only k8s templates - Increase line length limit to 400 chars (GitHub Actions friendly) - Allow flexible colon spacing (max-spaces-after: -1) - Disable document-start requirement This provides linting value while handling infrastructure patterns. Signed-off-by: vanzan01 <[email protected]> * Update .pre-commit-config.yaml Co-authored-by: John Bampton <[email protected]> --------- Signed-off-by: vanzan01 <[email protected]> Co-authored-by: John Bampton <[email protected]>
1 parent a466750 commit e6c7a71

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

.asf.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ github:
6363
protected_branches: ~
6464

6565
notifications:
66-
67-
66+
67+
6868
pullrequests: [email protected]
69-
discussions: [email protected]
69+
discussions: [email protected]

.github/linters/.yamllint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
---
18+
extends: relaxed
19+
20+
rules:
21+
line-length:
22+
max: 400 # Very forgiving for GitHub Actions and infrastructure files
23+
indentation: disable # Disable indentation checking for existing files
24+
comments: disable # Disable comment formatting checks
25+
brackets: disable # Disable bracket spacing checks
26+
colons:
27+
max-spaces-after: -1 # Allow any number of spaces after colon
28+
max-spaces-before: 0
29+
document-start: disable # Many files don't have ---
30+
truthy:
31+
allowed-values: ['true', 'false', 'on', 'off', 'yes', 'no']

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,13 @@ repos:
9494
args: [--config=.github/linters/.markdown-lint.yml]
9595
types: [markdown]
9696
files: \.(md|mdown|markdown)$
97+
- repo: https://github.com/adrienverge/yamllint
98+
rev: v1.37.1
99+
hooks:
100+
- id: yamllint
101+
name: run yamllint
102+
description: check YAML files with yamllint
103+
args: [--config-file=.github/linters/.yamllint.yml]
104+
types: [yaml]
105+
files: \.ya?ml$
106+
exclude: ^.*k8s-.*\.ya?ml$

0 commit comments

Comments
 (0)