diff --git a/.gitea/workflows/image.yml b/.gitea/workflows/image.yml index c742b0f..2a4b87f 100644 --- a/.gitea/workflows/image.yml +++ b/.gitea/workflows/image.yml @@ -87,7 +87,7 @@ jobs: dockerfile: Dockerfile job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c - name: ci - version: 0.2.17 + version: 0.2.18 subpath: "" dockerfile: images/ci/Dockerfile job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4645f17..6961103 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -default_install_hook_types: [pre-commit, commit-msg] +default_install_hook_types: [pre-commit, commit-msg, pre-push] repos: - repo: https://github.com/compilerla/conventional-pre-commit @@ -83,6 +83,20 @@ repos: stages: ['pre-commit'] pass_filenames: false + # Pre-push only: the Build job's ansible-test sanity run, on HEAD (scripts/ansible-test-sanity.sh). + # The sanity tests carry their own pylint, pep8 and shellcheck settings, which the hooks above do + # not, and a cold run builds virtualenvs, so it is not a commit hook. CI's pre-commit run does not + # run this stage (the Build job runs sanity itself), and no hook environment is built for it. + - id: ansible-test-sanity + name: ansible-test sanity + description: ansible-test sanity on HEAD, as the Build job runs it + entry: scripts/ansible-test-sanity.sh + language: system + pass_filenames: false + always_run: true + require_serial: true + stages: ['pre-push'] + - id: ansible-lint name: ansible-lint description: ansible-lint production profile, offline diff --git a/CLAUDE.md b/CLAUDE.md index 298936a..5610eaa 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -27,6 +27,8 @@ or create tags: those are the operator's. actionlint, ansible-lint, gitleaks, changelog lint, Conventional Commits) only run in `git commit`; an API commit skips them and CI finds the problem after the push. The first hook run builds the Go hook environments and takes minutes: run commits in the background. + `git push` also runs `ansible-test sanity` on HEAD (`scripts/ansible-test-sanity.sh`, the Build + job's check, which ruff and the other hooks do not cover); its first run builds virtualenvs and takes minutes. - Feature branch and pull request; `main` and `v*` tags are protected. Never push to `main`. Releases are the operator's: annotated `vX.Y.Z` tags equal to `galaxy.yml`'s version. - Conventional Commits. A PR says what was verified and what was not. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 370d9fd..d5392f1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,9 @@ (`requirements.yml`, into `.ansible/collections`, so local lint resolves the versions CI does) and installs git hooks that find the tools (the `ansible-lint` hook, `scripts/ansible-lint.sh`, uses those collections, also from a bare `pre-commit run`). Then - `pre-commit run --all-files` before pushing. + `pre-commit run --all-files` before pushing. A `git push` runs `ansible-test sanity` on HEAD + (`scripts/ansible-test-sanity.sh`, the Build job's check; the first run builds virtualenvs and + takes minutes), so a finding only that test reports stops the push, not the Build check. - Never commit credentials, tokens or key material. - Releases are cut by the maintainer: bump `version` in `galaxy.yml`, add a `release_summary:` fragment, run `antsibull-changelog release` in a release PR diff --git a/scripts/dev-setup.sh b/scripts/dev-setup.sh index e06a2f2..91365dd 100755 --- a/scripts/dev-setup.sh +++ b/scripts/dev-setup.sh @@ -133,7 +133,7 @@ ANSIBLE_COLLECTIONS_PATH="$collections" .venv/bin/ansible-galaxy collection inst marker="# kamino-dev-setup: virtualenv first on PATH" # default_install_hook_types in .pre-commit-config.yaml names these; keep in step. -for hook in pre-commit commit-msg; do +for hook in pre-commit commit-msg pre-push; do file="$(git -C "$root" rev-parse --path-format=absolute --git-path "hooks/$hook")" if [ ! -f "$file" ]; then echo "error: $file was not installed by 'pre-commit install'; check default_install_hook_types in .pre-commit-config.yaml." >&2 diff --git a/tests/scripts/test_dev_setup.py b/tests/scripts/test_dev_setup.py index 17f40d5..483467a 100644 --- a/tests/scripts/test_dev_setup.py +++ b/tests/scripts/test_dev_setup.py @@ -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"")