fix(dev): run ansible-lint against the clone's pinned collections from any shell
The hook scripts written by dev-setup.sh exported ANSIBLE_HOME and ANSIBLE_COLLECTIONS_PATH, so only a hook run through git commit saw the pinned collections; a bare pre-commit run fell back to the control host's ~/.ansible, the drift #118 removes. The ansible-lint hook now runs scripts/ansible-lint.sh, which uses .ansible/collections of the clone when ANSIBLE_COLLECTIONS_PATH is unset, fails with the fix when they are missing, and leaves a preset path (CI's /opt/collections) alone. dev-setup.sh keeps installing the collections and no longer edits the hook scripts beyond the PATH block it always wrote. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
This commit is contained in:
1 parent
42ad8de88f
commit
bdb34cf98e
7 files changed
+123
-53
No files matched your search
@@ -146,12 +146,6 @@ class DevSetupTest(unittest.TestCase):
|
||||
for name in ("pre-commit", "commit-msg"):
|
||||
text = self.hook(repo, name).read_text()
|
||||
self.assertIn("# kamino-dev-setup: virtualenv first on PATH", text)
|
||||
self.assertIn("# kamino-dev-setup: collections from this clone", text)
|
||||
self.assertIn(f"export ANSIBLE_HOME={repo / '.ansible'}", text)
|
||||
self.assertIn(
|
||||
f"export ANSIBLE_COLLECTIONS_PATH={repo / '.ansible' / 'collections'}",
|
||||
text,
|
||||
)
|
||||
self.assertEqual(self.hooks_z(repo), b"")
|
||||
|
||||
def galaxy_calls(self) -> list[str]:
|
||||
@@ -174,29 +168,6 @@ class DevSetupTest(unittest.TestCase):
|
||||
self.assertIn("stub galaxy failure", result.stderr)
|
||||
self.assertNotIn("kamino-dev-setup", self.hook(repo).read_text())
|
||||
|
||||
def test_hook_of_the_previous_version_gains_only_the_collections_path(
|
||||
self,
|
||||
) -> None:
|
||||
repo = self.make_repo()
|
||||
self.assertEqual(self.run_setup(repo).returncode, 0)
|
||||
hook = self.hook(repo)
|
||||
# What the previous version of the script wrote: the PATH block, no collections block.
|
||||
lines = hook.read_text().splitlines()
|
||||
old = [
|
||||
line
|
||||
for line in lines
|
||||
if "collections from this clone" not in line
|
||||
and "ANSIBLE_COLLECTIONS_PATH" not in line
|
||||
and "ANSIBLE_HOME" not in line
|
||||
]
|
||||
hook.write_text("\n".join(old) + "\n")
|
||||
self.assertEqual(self.run_setup(repo).returncode, 0)
|
||||
text = hook.read_text()
|
||||
self.assertEqual(text.count("kamino-dev-setup: virtualenv first"), 1)
|
||||
self.assertEqual(text.count("kamino-dev-setup: collections from this clone"), 1)
|
||||
self.assertEqual(text.count("export ANSIBLE_COLLECTIONS_PATH="), 1)
|
||||
self.assertEqual(text.count("export ANSIBLE_HOME="), 1)
|
||||
|
||||
def test_rerun_is_idempotent(self) -> None:
|
||||
repo = self.make_repo()
|
||||
self.assertEqual(self.run_setup(repo).returncode, 0)
|
||||
@@ -205,9 +176,6 @@ class DevSetupTest(unittest.TestCase):
|
||||
self.assertEqual(second_run.returncode, 0, second_run.stderr)
|
||||
self.assertEqual(self.hook(repo).read_text(), first)
|
||||
self.assertEqual(first.count("kamino-dev-setup: virtualenv first"), 1)
|
||||
self.assertEqual(
|
||||
first.count("kamino-dev-setup: collections from this clone"), 1
|
||||
)
|
||||
|
||||
def test_own_absolute_hooks_path_is_lifted_and_restored(self) -> None:
|
||||
repo = self.make_repo()
|
||||
|
||||
Reference in new issue
Block a user