Skip to content

Commit

Permalink
\!fixup Start preparing annotations by the script itself
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Jan 16, 2024
1 parent a833766 commit 81958b3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ repos:
- id: pylint
additional_dependencies:
- regex
- PyGithub
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
hooks:
Expand All @@ -130,4 +131,4 @@ repos:
- --show-error-codes
- --show-error-context
- --disable-error-code=name-defined
additional_dependencies: [tkcalendar>=1.5.0, types-pytz, regex]
additional_dependencies: [tkcalendar>=1.5.0, types-pytz, regex, PyGithub]
32 changes: 32 additions & 0 deletions logToCs.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,38 @@ def convert_text_to_checkstyle(text, root_path=None):
return ET.tostring(root, encoding="utf_8").decode("utf_8")


def github_annotate(items):

Check failure on line 90 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: W0613: Unused argument 'items' (unused-argument)
"""
Record github annotations for the items.
throws ImportError if the github module is not available.
"""
if not hasattr(github_annotate, "initialized"):
# Initialise github annotation submission
github_annotate.initialized = True
from github import Github

Check failure on line 99 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: C0415: Import outside toplevel (github.Github) (import-outside-toplevel)

# Create Github instance
g = Github(access_token)

Check failure on line 102 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: F821 undefined name 'access_token'

Check failure on line 102 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: E0602: Undefined variable 'access_token' (undefined-variable)

# Get the repository
repo = g.get_repo(f'{owner}/{repo_name}')

Check failure on line 105 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: F821 undefined name 'owner'

Check failure on line 105 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: F821 undefined name 'repo_name'

Check failure on line 105 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: E0602: Undefined variable 'owner' (undefined-variable)

Check failure on line 105 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: E0602: Undefined variable 'repo_name' (undefined-variable)

# Create a check run
github_annotate.check_run = repo.get_commit(commit_sha).create_check_run(
'YourCheckName',

Check failure on line 109 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: F821 undefined name 'commit_sha'

Check failure on line 109 in logToCs.py

View workflow job for this annotation

GitHub Actions / pre-commit

logToCs.py: E0602: Undefined variable 'commit_sha' (undefined-variable)
'in_progress',
)

github_annotate.check_run.create_annotation(
path='path/to/file',
start_line=10,
end_line=10,
annotation_level='warning', # or 'failure', 'notice'
message='This is a warning message',
)


ANY_REGEX = r".*?"
FILE_REGEX = r"\s*(?P<file_name>\S.*?)\s*?"
FILEGROUP_REGEX = r"\s*(?P<file_group>\S.*?)\s*?"
Expand Down

0 comments on commit 81958b3

Please sign in to comment.