Skip to content

Commit

Permalink
Ref #91 -- Group GitHub workflow output by filename
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Oct 25, 2024
1 parent 6eec24a commit e71ded6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion relint/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,24 @@ def split_diff_content_by_filename(output: str) -> {str: str}:

def print_github_actions_output(matches, args):
exit_code = 0
groups = collections.defaultdict(list)
for filename, test, match, line_number in matches:
exit_code = test.error if exit_code == 0 else exit_code
start_line_no = match.string[: match.start()].count("\n") + 1
end_line_no = match.string[: match.end()].count("\n") + 1
col = match.start() - match.string.rfind("\n", 0, match.start())
col_end = match.end() - match.string.rfind("\n", 0, match.end())

print(
groups[filename].append(
f"::{'error' if test.error else 'warning'} file={filename},"
f"line={start_line_no},endLine={end_line_no},col={col},colEnd={col_end},"
f"title={test.name}::{test.hint}".replace("\n", "%0A")
)
for filename, messages in groups.items():
print(f"::group::{filename}")
for annotation in messages:
print(annotation)
print("::endgroup::")
return exit_code


Expand Down

0 comments on commit e71ded6

Please sign in to comment.