ci(hooks): run ansible-test sanity before a push
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:
1 parent
574c0d00f9
commit
18a7e26e4f
6 files changed
+24
-6
No files matched your search
@@ -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"")
|
||||
|
||||
Reference in new issue
Block a user