From 1308e0a57b7de5619b1251b1693978e27824aff8 Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Tue, 18 Jul 2023 11:55:53 +0530 Subject: [PATCH 1/2] Include filepaths starting from home directory in lintables --- src/ansiblelint/file_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansiblelint/file_utils.py b/src/ansiblelint/file_utils.py index 15c92d2983..d5681eb32e 100644 --- a/src/ansiblelint/file_utils.py +++ b/src/ansiblelint/file_utils.py @@ -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)) From 170016de629904e4646187d42fe9950f9273216d Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Tue, 18 Jul 2023 22:10:00 +0530 Subject: [PATCH 2/2] Add test --- .github/workflows/tox.yml | 2 +- test/test_runner.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index b290f39615..7500fd8a0d 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -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')" diff --git a/test/test_runner.py b/test/test_runner.py index e4662f2585..2c0df47b90 100644 --- a/test/test_runner.py +++ b/test/test_runner.py @@ -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]"