Skip to content

Commit

Permalink
Show severity in Github Workflow command message (#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriSko committed Oct 5, 2020
1 parent a45e225 commit cff352f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit cff352f

Please sign in to comment.