forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint.py
43 lines (33 loc) · 1.09 KB
/
lint.py
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
from forge import LocalShell
import re
from typing import Tuple
from pathlib import Path
import click
@click.group()
def main() -> None:
pass
@main.command()
@click.argument("paths", nargs=-1)
def helm(paths: Tuple[str]) -> None:
shell = LocalShell(True)
error = False
for path in paths:
result = shell.run(["helm", "lint", path])
for line in result.output.decode().splitlines():
if line.startswith("[ERROR]"):
match = re.match(
r".ERROR. (?P<section>[^:]+?): (?P<error_type>.*) at [(](?P<filename>.*):(?P<line>\d+)[)]: (?P<message>.*)",
line,
)
if match:
fullpath = Path(path).parent / match.group("filename")
print(
"::error file={fullpath},line={line},col=1::{message}".format(
fullpath=fullpath, **match.groupdict()
)
)
error = True
if error:
raise SystemExit(1)
if __name__ == "__main__":
main()