Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hopefully adds proper annotations to the regex linter #2352

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
python-version: "3.9"
- name: Run Check Regex
run: |
tools/bootstrap/python -m ci.check_regex --log-changes-only
tools/bootstrap/python -m ci.check_regex --log-changes-only --github-actions
- name: Annotate Regex Matches
if: always()
run: |
Expand Down
28 changes: 27 additions & 1 deletion tools/ci/check_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
modification, or removal. Good if you want to track down errors
caused by commit or PR changes.

--github-actions
An output option to format the output in a way that Github Actions
can parse and show as annotations in the PR.

Copyright 2021 Martin Lyrå

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -99,6 +103,12 @@
dest="log_changes_only",
default=False,
action="store_true")
options.add_argument(
"--github-actions",
dest="github_actions",
default=False,
action="store_true"
)

args = options.parse_args()

Expand Down Expand Up @@ -790,9 +800,25 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str:
show_items.append("Current (%4i): %s" % (len(matches), matches))
if len(adds):
show_items.append("+++++++ (%4i): %s" % (len(adds), adds))
#Github actions annotations
if args.github_actions and matching != RESULT_OK:
for line_no in adds:
output_write("::error file=%s,line=%i,title=Check Regex::%s added to here, remove or update check_regex.yml" % (
f,
line_no,
standard.message
), to_stdout=True, to_file=False)
inner_prefix = prefix
if len(removes):
show_items.append("------- (%4i): %s" % (len(removes), removes))
#Github actions annotations
if args.github_actions and matching != RESULT_OK:
for line_no in removes:
output_write("::error file=%s,line=%i,title=Check Regex::%s removed from here, update check_regex.yml" % (
f,
line_no,
standard.message
), to_stdout=True, to_file=False)
inner_prefix = prefix

lines.append("%2s %s" % ("\u2500\u252C", f))
Expand Down Expand Up @@ -898,4 +924,4 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str:
output_file.close()
output_file = None

exit(failure > 0 or fail_files > 0)
exit(failure > 0 or fail_files > 0)