diff --git a/examples/playbooks/task-has-name-success.yml b/examples/playbooks/task-has-name-success.yml index 1cbaf78cdf..965a80ab46 100644 --- a/examples/playbooks/task-has-name-success.yml +++ b/examples/playbooks/task-has-name-success.yml @@ -3,8 +3,10 @@ hosts: all tasks: - name: This task has a name - ansible.builtin.command: echo "Hello World" + ansible.builtin.command: echo "Hello World" # noqa: no-free-form + changed_when: false - name: Debug task with name - ansible.builtin.debug: msg="Hello World" + ansible.builtin.debug: msg="Hello World" # noqa: no-free-form - name: Flush handler with name ansible.builtin.meta: flush_handlers + changed_when: false diff --git a/src/ansiblelint/app.py b/src/ansiblelint/app.py index 294d374047..f06d7248c5 100644 --- a/src/ansiblelint/app.py +++ b/src/ansiblelint/app.py @@ -193,7 +193,7 @@ def report_outcome(self, result: LintResult, mark_as_success: bool = False) -> i "because 'yaml' is in 'skip_list'." ) - if (result.matches or changed_files_count) and not self.options.quiet: + if not self.options.quiet: console_stderr.print(render_yaml(msg)) self.report_summary(summary, changed_files_count, files_count) @@ -231,12 +231,6 @@ def report_summary( # pylint: disable=too-many-branches,too-many-locals if changed_files_count: console_stderr.print(f"Modified {changed_files_count} files.") - msg = "Finished with " - msg += f"{summary.failures} failure(s), {summary.warnings} warning(s)" - if summary.fixed: - msg += f", and fixed {summary.fixed} issue(s)" - msg += f" on {files_count} files." - # determine which profile passed summary.passed_profile = "" passed_profile_count = 0 @@ -247,6 +241,7 @@ def report_summary( # pylint: disable=too-many-branches,too-many-locals summary.passed_profile = profile passed_profile_count += 1 + stars = "" if summary.tag_stats: table = Table( title="Rule Violation Summary", @@ -269,15 +264,25 @@ def report_summary( # pylint: disable=too-many-branches,too-many-locals # rate stars for the top 5 profiles (min would not get rating = 5 - (len(PROFILES.keys()) - passed_profile_count) if 0 < rating < 6: - stars = f"Rated as {rating}/5 stars." - else: - stars = "No rating." + stars = f", {rating}/5 star rating" console_stderr.print(table) console_stderr.print() - if summary.passed_profile: - msg += f" Code passed [white bold]{summary.passed_profile}[/] profile. {stars}" + if summary.failures: + msg = "[red][bold]Failed[/][/] after " + else: + msg = "[green]Passed[/] with " + + if summary.passed_profile: + msg += f"[bold]{summary.passed_profile}[/] profile" + if stars: + msg += stars + + msg += f": {summary.failures} failure(s), {summary.warnings} warning(s)" + if summary.fixed: + msg += f", and fixed [/]{summary.fixed} issue(s)" + msg += f" on {files_count} files." console_stderr.print(msg) diff --git a/src/ansiblelint/rules/only_builtins.py b/src/ansiblelint/rules/only_builtins.py index d79771a813..8af31619a2 100644 --- a/src/ansiblelint/rules/only_builtins.py +++ b/src/ansiblelint/rules/only_builtins.py @@ -58,7 +58,8 @@ def test_only_builtin_fail() -> None: "examples/playbooks/rule-only-builtins.yml", ) assert result.returncode == VIOLATIONS_FOUND_RC - assert "Finished with 1 failure(s)" in result.stderr + assert "Failed" in result.stderr + assert "1 failure(s)" in result.stderr assert "only-builtins" in result.stdout @pytest.mark.parametrize(