Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include filepaths starting from $HOME in lintables #3621

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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: 808
PYTEST_REQPASS: 809
steps:
- name: Activate WSL1
if: "contains(matrix.shell, 'wsl')"
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def expand_dirs_in_lintables(lintables: set[Lintable]) -> None:
for item in copy.copy(lintables):
if item.path.is_dir():
for filename in all_files:
if filename.startswith(str(item.path)):
if filename.startswith((str(item.path), str(item.path.absolute()))):
lintables.add(Lintable(filename))


Expand Down
13 changes: 13 additions & 0 deletions test/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,16 @@ def test_runner_tmp_file(
result = runner.run()
assert len(result) == 1
assert result[0].tag == "syntax-check[empty-playbook]"


def test_with_full_path(default_rules_collection: RulesCollection) -> None:
"""Ensure that lintables include file path starting from home directory."""
filename = Path("examples/playbooks/deep").absolute()
runner = Runner(
filename,
rules=default_rules_collection,
verbosity=0,
)
result = runner.run()
assert len(result) == 1
assert result[0].tag == "name[casing]"