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

Show severity in Github Workflow command message #1055

Merged
merged 4 commits into from Oct 5, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/ansiblelint/formatters/__init__.py
Expand Up @@ -107,9 +107,9 @@ class AnnotationsFormatter(BaseFormatter):
in a form of GitHub Checks API annotations that appear rendered in pull-
request files view.

::debug file={name},line={line},col={col}::{message}
::warning file={name},line={line},col={col}::{message}
::error file={name},line={line},col={col}::{message}
::debug file={name},line={line},col={col},severity={severity}::{message}
::warning file={name},line={line},col={col},severity={severity}::{message}
::error file={name},line={line},col={col},severity={severity}::{message}

Supported levels: debug, warning, error
"""
Expand All @@ -123,9 +123,10 @@ def format(self, match: "MatchError", colored: bool = False) -> str:
file_path = self._format_path(match.filename or "")
line_num = match.linenumber
rule_id = match.rule.id
severity = match.rule.severity
violation_details = match.message
return (
f"::{level} file={file_path},line={line_num}"
f"::{level} file={file_path},line={line_num},severity={severity}"
f"::[E{rule_id}] {violation_details}"
)

Expand Down
2 changes: 1 addition & 1 deletion test/TestCliRolePaths.py
Expand Up @@ -128,7 +128,7 @@ def test_run_playbook_github(result, env):
result_gh = run_ansible_lint(role_path, cwd=cwd, env=env)

expected = (
'::error file=examples/example.yml,line=47::[E101] '
'::error file=examples/example.yml,line=47,severity=MEDIUM::[E101] '
'Deprecated always_run'
)
assert (expected in result_gh.stdout) is result