scripts: compliance: add a check for MAINTAINERS.yml format
Add a compliance check that tries to load MAINTAINERS.yml with get_maintainer.Maintainers() if it's been modified by the CL, and fail compliance if it fails to be parsed. Example output: ``` ERROR : Test MaintainersFormat failed: Error parsing MAINTAINERS.yml: MAINTAINERS.yml: YAML error: while scanning a simple key in "MAINTAINERS.yml", line 976, column 1 could not find expected ':' in "MAINTAINERS.yml", line 977, column 3 ``` ``` ERROR : Test MaintainersFormat failed: Error parsing MAINTAINERS.yml: MAINTAINERS.yml: glob pattern 'drivers/regulator' in 'files' in area 'Drivers: Regulators' matches a directory, but has no trailing '/' ``` Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
374411dfaf
commit
f33d43795d
1 changed files with 24 additions and 0 deletions
|
@ -20,6 +20,9 @@ import shlex
|
||||||
from junitparser import TestCase, TestSuite, JUnitXml, Skipped, Error, Failure
|
from junitparser import TestCase, TestSuite, JUnitXml, Skipped, Error, Failure
|
||||||
import magic
|
import magic
|
||||||
|
|
||||||
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||||
|
from get_maintainer import Maintainers, MaintainersError
|
||||||
|
|
||||||
logger = None
|
logger = None
|
||||||
|
|
||||||
def git(*args, cwd=None):
|
def git(*args, cwd=None):
|
||||||
|
@ -967,6 +970,27 @@ class ImageSize(ComplianceTest):
|
||||||
f"less than {limit >> 10}kB")
|
f"less than {limit >> 10}kB")
|
||||||
|
|
||||||
|
|
||||||
|
class MaintainersFormat(ComplianceTest):
|
||||||
|
"""
|
||||||
|
Check that MAINTAINERS file parses correctly.
|
||||||
|
"""
|
||||||
|
name = "MaintainersFormat"
|
||||||
|
doc = "Check that MAINTAINERS file parses correctly."
|
||||||
|
path_hint = "<git-top>"
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
MAINTAINERS_FILES = ["MAINTAINERS.yml", "MAINTAINERS.yaml"]
|
||||||
|
|
||||||
|
for file in get_files(filter="d"):
|
||||||
|
if file not in MAINTAINERS_FILES:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
Maintainers(file)
|
||||||
|
except MaintainersError as ex:
|
||||||
|
self.failure(f"Error parsing {file}: {ex}")
|
||||||
|
|
||||||
|
|
||||||
def init_logs(cli_arg):
|
def init_logs(cli_arg):
|
||||||
# Initializes logging
|
# Initializes logging
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue