Skip to content

Commit

Permalink
schema: add ability to recognize ansible-lint config files (#2127)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed May 12, 2022
1 parent 06c78ff commit 33db532
Show file tree
Hide file tree
Showing 5 changed files with 24 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 @@ -155,7 +155,7 @@ jobs:
WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:TOX_PARALLEL_NO_SPINNER
# Number of expected test passes, safety measure for accidental skip of
# tests. Update value if you add/remove tests.
PYTEST_REQPASS: 637
PYTEST_REQPASS: 640

steps:
- name: Activate WSL1
Expand Down
1 change: 1 addition & 0 deletions examples/.config/ansible-lint.yml
2 changes: 2 additions & 0 deletions examples/broken/.ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# invalid ansible-lint config file
foo: bar # invalid based on schema
2 changes: 2 additions & 0 deletions src/ansiblelint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
{"yaml": ".github/**/*.{yaml,yml}"}, # github workflows
{"text": "**/templates/**/*.*"}, # templates are likely not validable
{"execution-environment": "**/execution-environment.yml"},
{"ansible-lint-config": "**/.ansible-lint"},
{"ansible-lint-config": "**/.config/ansible-lint.yml"},
{"inventory": "**/inventory/**.yml"},
{"requirements": "**/meta/requirements.yml"}, # v1 only
# https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html
Expand Down
18 changes: 18 additions & 0 deletions src/ansiblelint/rules/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ def matchyaml(self, file: Lintable) -> List[MatchError]:
"inventory",
["Additional properties are not allowed ('foo' was unexpected)"],
),
(
".ansible-lint",
"ansible-lint-config",
[],
),
(
"examples/.config/ansible-lint.yml",
"ansible-lint-config",
[],
),
(
"examples/broken/.ansible-lint",
"ansible-lint-config",
["Additional properties are not allowed ('foo' was unexpected)"],
),
),
ids=(
# "playbook-fail",
Expand All @@ -154,6 +169,9 @@ def matchyaml(self, file: Lintable) -> List[MatchError]:
"meta-runtime-broken",
"inventory",
"inventory-broken",
"lint-config",
"lint-config2",
"lint-config-broken",
),
)
# # unsupported yet:
Expand Down

0 comments on commit 33db532

Please sign in to comment.