Skip to content

Commit

Permalink
Hopefully adds proper annotations to the regex linter (#2352)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
See title

## Why It's Good For The Game
More clear what's going wrong when linters fails

## Changelog

:cl:
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
MarkSuckerberg authored Sep 14, 2023
1 parent b9391ac commit 7b10e32
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
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)

0 comments on commit 7b10e32

Please sign in to comment.