Rename github action, better argparse for linter

This commit is contained in:
disinvite 2023-12-11 22:40:38 -05:00
parent 775256a142
commit 38b44e1246
2 changed files with 12 additions and 12 deletions

View File

@ -1,9 +1,9 @@
name: Check order name: Decomp marker linting
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
checkorder: decomplint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@ -33,7 +33,7 @@ def display_errors(alerts, filename):
print(f"{colorama.Fore.WHITE} {alert.line}") print(f"{colorama.Fore.WHITE} {alert.line}")
def parse_args() -> dict: def parse_args() -> argparse.Namespace:
p = argparse.ArgumentParser( p = argparse.ArgumentParser(
description="Syntax checking and linting for decomp annotation markers." description="Syntax checking and linting for decomp annotation markers."
) )
@ -57,8 +57,8 @@ def parse_args() -> dict:
help="Fail if syntax warnings are found and enforce is enabled.", help="Fail if syntax warnings are found and enforce is enabled.",
) )
args = p.parse_args() (args, _) = p.parse_known_args()
return vars(args) return args
def process_files(files, module=None): def process_files(files, module=None):
@ -85,19 +85,19 @@ def process_files(files, module=None):
def main(): def main():
args = parse_args() args = parse_args()
if os.path.isdir(args["target"]): if os.path.isdir(args.target):
files_to_check = list(walk_source_dir(args["target"])) files_to_check = list(walk_source_dir(args.target))
elif os.path.isfile(args["target"]) and is_file_cpp(args["target"]): elif os.path.isfile(args.target) and is_file_cpp(args.target):
files_to_check = [args["target"]] files_to_check = [args.target]
else: else:
sys.exit("Invalid target") sys.exit("Invalid target")
(warning_count, error_count) = process_files(files_to_check, module=args["module"]) (warning_count, error_count) = process_files(files_to_check, module=args.module)
print(colorama.Style.RESET_ALL, end="") print(colorama.Style.RESET_ALL, end="")
would_fail = error_count > 0 or (warning_count > 0 and args["warnfail"]) would_fail = error_count > 0 or (warning_count > 0 and args.warnfail)
if args["enforce"] and would_fail: if args.enforce and would_fail:
sys.exit(1) sys.exit(1)