Skip to content

Commit

Permalink
Ensure that syntax-check also runs on roles (#3272)
Browse files Browse the repository at this point in the history
Co-authored-by: Ajinkya Udgirkar <ajinkyaudgirkar@gmail.com>
  • Loading branch information
ssbarnea and audgirka committed Apr 12, 2023
1 parent 021ccbc commit 502ea61
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions .config/requirements-test.txt
Expand Up @@ -5,6 +5,7 @@ flake8 # IDE support
flake8-future-annotations # IDE support
jmespath
mypy # IDE support
netaddr # needed by ipwrap filter
psutil # soft-dep of pytest-xdist
pylint # IDE support
pytest >= 7.2.2
Expand Down
1 change: 1 addition & 0 deletions .config/requirements.txt
Expand Up @@ -63,6 +63,7 @@ mkdocstrings==0.21.2
mkdocstrings-python==0.9.0
mypy==1.2.0
mypy-extensions==1.0.0
netaddr==0.8.0
packaging==23.0
pathspec==0.11.1
pillow==9.5.0
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/meta_no_tags.py
Expand Up @@ -106,7 +106,7 @@ def test_valid_tag_rule(rule_runner: RunFromText) -> None:
@pytest.mark.parametrize(
"rule_runner", (MetaTagValidRule,), indirect=["rule_runner"]
)
def test_no_galaxy_info(rule_runner: Any) -> None:
def test_meta_not_tags(rule_runner: Any) -> None:
"""Test rule matches."""
results = rule_runner.run(
"examples/roles/meta_no_tags_galaxy_info/meta/main.yml"
Expand Down
7 changes: 6 additions & 1 deletion src/ansiblelint/rules/syntax_check.py
Expand Up @@ -230,9 +230,14 @@ def test_extra_vars_passed_to_command(config_options: Any) -> None:

def test_syntax_check_role() -> None:
"""Validate syntax check of a broken role."""
# pylint: disable=import-outside-toplevel
from ansiblelint.rules import RulesCollection
from ansiblelint.runner import Runner

lintable = Lintable("examples/playbooks/roles/invalid_due_syntax", kind="role")
# pylint: disable=protected-access
result = AnsibleSyntaxCheckRule._get_ansible_syntax_check_matches(lintable)
rules = RulesCollection()
result = Runner(lintable, rules=rules).run()
assert len(result) == 1, result
assert result[0].linenumber == 2
assert result[0].filename == "examples/roles/invalid_due_syntax/tasks/main.yml"
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/runner.py
Expand Up @@ -139,7 +139,7 @@ def worker(lintable: Lintable) -> list[MatchError]:

# playbooks: List[Lintable] = []
for lintable in self.lintables:
if lintable.kind != "playbook" or lintable.stop_processing:
if lintable.kind not in ("playbook", "role") or lintable.stop_processing:
continue
files.append(lintable)

Expand Down

0 comments on commit 502ea61

Please sign in to comment.