From b8fb75e6cdcb9759d308abb5b8d54b2c35c87e35 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 1 Jul 2025 18:22:49 +0930 Subject: [PATCH] feat(parser): add table for each tool used for annotations ref: #3 #1 --- includes/usr/bin/annotations.py | 41 ++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/includes/usr/bin/annotations.py b/includes/usr/bin/annotations.py index bafc31a..4afbf3e 100755 --- a/includes/usr/bin/annotations.py +++ b/includes/usr/bin/annotations.py @@ -231,23 +231,52 @@ for tool, tool_results in results.items(): api_body['comments'] += [ pylint_matcher( entry ) ] -review_body = '## :no_entry_sign: Annotations found\n\n' \ - f'@{os.getenv("GITHUB_ACTOR")}, found some issues.\n\n' \ - '| Type | Count | \n|:---|:---:| \n' + if tool not in type_count: + + type_count[tool] = 1 + + else: + + type_count[tool] += 1 + + +review_body = { + 'header': str( + '## :no_entry_sign: Annotations found \n' \ + f'@{os.getenv("GITHUB_ACTOR")}, \n\n' + 'I found some issues that need addressing. \n\n' + ) +} for msg_type, cnt in type_count.items(): - review_body += f'| {msg_type} | {cnt} | \n' + if msg_type not in review_body: + + review_body[msg_type] = str('| Type | Count | \n|:---|:---:| \n') + + review_body[msg_type] += f'| {msg_type} | {cnt} | \n' -api_body['body'] = review_body + '\n' +api_body['body'] = review_body['header'] + +for msg_type, value in review_body.items(): + + if msg_type != 'header': + + api_body['body'] += str( + f'### {msg_type} issues found ' + '\n' + f'{value}\n' + '\n' + ) + data = { "pull_request": pull_request, "api_body": api_body } -print(json.dumps(data)) +print(json.dumps(data, indent=4)) # URL = os.getenv("GITHUB_API_URL") + '/repos/' + os.getenv("GITHUB_REPOSITORY") + '/pulls/' + os.getenv("GITHUB_REF_NAME") + '/reviews?token=' + str(os.getenv("AGITHUB_TOKEN"))