Skip to content

Commit

Permalink
Allow warnings to be skipped (#2925)
Browse files Browse the repository at this point in the history
Fixes: #2868
Closes: #2917
  • Loading branch information
ssbarnea committed Jan 20, 2023
1 parent 6087f67 commit 04204dc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:GITHUB_STEP_SUMMARY
# Number of expected test passes, safety measure for accidental skip of
# tests. Update value if you add/remove tests.
PYTEST_REQPASS: 769
PYTEST_REQPASS: 770

steps:
- name: Activate WSL1
Expand Down
3 changes: 3 additions & 0 deletions src/ansiblelint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ def main(argv: list[str] | None = None) -> int: # noqa: C901
if options.strict and result.matches:
mark_as_success = False

# Remove skipped list items from the result
result.matches = [m for m in result.matches if m.tag not in app.options.skip_list]

app.render_matches(result.matches)

_perform_mockings_cleanup()
Expand Down
13 changes: 13 additions & 0 deletions test/test_with_skip_tagid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from ansiblelint.rules import RulesCollection
from ansiblelint.rules.yaml_rule import YamllintRule
from ansiblelint.runner import Runner
from ansiblelint.testing import run_ansible_lint

FILE = "examples/playbooks/with-skip-tag-id.yml"
collection = RulesCollection()
Expand Down Expand Up @@ -43,3 +44,15 @@ def test_positive_skip_tag() -> None:
skip_tag = "yaml[trailing-spaces]"
good_runner = Runner(FILE, rules=collection, skip_list=[skip_tag])
assert [] == good_runner.run()


def test_run_skip_warning_rule() -> None:
"""Test that we can skip warning[empty-playbook]."""
result = run_ansible_lint(
"-x",
"warning[empty-playbook]",
"examples/playbooks/empty_playbook.yml",
executable="ansible-lint",
)
assert result.returncode == 0
assert result.stdout == ""

0 comments on commit 04204dc

Please sign in to comment.