ci(hooks): run ansible-test sanity before a push
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 30s
Molecule / molecule (pull_request) Successful in 5m22s

Add a pre-push hook that runs scripts/ansible-test-sanity.sh, so the Build job's sanity check, which ruff and the other hooks do not cover (it failed on a name only its pylint disallows), stops a push instead of the pull request. It is pre-push and not pre-commit because a cold run builds virtualenvs and needs the network; CI's pre-commit run does not run that stage, and a local system hook builds no environment. pre-push joins default_install_hook_types, and dev-setup.sh and its test treat it like the other two hook types, so its hook script also gets the virtualenv on PATH.

Verified through git push --dry-run in a throwaway clone: a commit with a disallowed name inside a function is blocked (exit 1, the same pylint message as CI, failed to push), and the push passes once it is removed.

Image input: .pre-commit-config.yaml is baked into the ci image, so ci 0.2.17 -> 0.2.18 (scripts/bump_image_versions.py). The new hook adds no hook environment and no layer size; the merge builds 0.2.18 and a pin PR follows.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-11-14 15:52:35 +00:00
1 parent 574c0d00f9
commit 18a7e26e4f
6 files changed
+24 -6

No files matched your search

+2 -2
View File
@@ -52,7 +52,7 @@ if git config --get-all core.hooksPath >/dev/null 2>&1; then
echo "Cannot install: core.hooksPath is set" >&2
exit 1
fi
for h in pre-commit commit-msg; do
for h in pre-commit commit-msg pre-push; do
f="$(git rev-parse --path-format=absolute --git-path "hooks/$h")"
mkdir -p "$(dirname "$f")"
printf '#!/usr/bin/env bash\\necho "hook-ran"\\necho "$PATH"\\n' > "$f"
@@ -143,7 +143,7 @@ class DevSetupTest(unittest.TestCase):
repo = self.make_repo()
result = self.run_setup(repo)
self.assertEqual(result.returncode, 0, result.stderr)
for name in ("pre-commit", "commit-msg"):
for name in ("pre-commit", "commit-msg", "pre-push"):
text = self.hook(repo, name).read_text()
self.assertIn("# kamino-dev-setup: virtualenv first on PATH", text)
self.assertEqual(self.hooks_z(repo), b"")