Step 5 of #118, the last open item, plus a pre-push hook for ansible-test sanity that came out of this PR's own Build failure. Refs #118. This PR is an image input (it edits .pre-commit-config.yaml): it carries the ci bump 0.2.17 -> 0.2.18, and a pin-follow PR is needed after the merge builds the image.
1. Lint resolves the Collection's own roles; mock_roles is gone (3289c0d)
The molecule scenarios' converge plays call the roles by FQCN (mortis.kamino.<role>), which only resolves from an ansible_collections/<namespace>/<name> directory, and a checkout is not one. .ansible-lint therefore listed the five roles in mock_roles, and ansible-lint never checked those plays against the real roles.
scripts/ansible-lint.sh, which the ansible-lint hook runs in CI and locally, links the checkout as ansible_collections/<namespace>/<name> in a temporary root (namespace and name read from galaxy.yml), puts that root first on ANSIBLE_COLLECTIONS_PATH (after it comes CI's /opt/collections or the clone's .ansible/collections, as before) and removes it on exit. It no longer execs ansible-lint, so the cleanup trap runs; the exit code is unchanged. A bare ansible-lint outside the hook gets no link; .ansible-lint says so.
The first Build run of this PR failed in ansible-test sanity: tests/scripts/test_ansible_lint_wrapper.py:37:13: disallowed-name: Disallowed name "_". Ruff accepts the name; the pylint configuration of ansible-test, which also scans the Python under tests/, does not. Fixed by indexing the partition result.
scripts/ansible-test-sanity.sh copies HEAD (git archive: the committed files only) into a temporary ansible_collections/<namespace>/<name>, applies the Build job's ignore-file step (ignore-common.txt to ignore-<core MAJOR.MINOR>.txt) and runs ansible-test sanity --requirements, passing extra arguments through. Eleven tests cover it.
A pre-push hook (language: system, always_run, pass_filenames: false) runs it. pre-push is in default_install_hook_types, and dev-setup.sh treats it like the other two hook types, so its hook script also gets the virtualenv on PATH. It is pre-push and not pre-commit because a cold run builds virtualenvs and needs the network (minutes), then reuses them. CI's pre-commit run --all-files does not run that stage (the Build job runs sanity itself), and a system hook builds no environment, so the image gains no layer size.
CLAUDE.md and CONTRIBUTING.md say that git push runs it.
Image loop
.pre-commit-config.yaml is baked into the ci image, so scripts/bump_image_versions.py moved ci 0.2.17 -> 0.2.18 (check_image_versions.py bump origin/main passes). After the merge image.yml builds 0.2.18 on main (the build prints the compressed layer sizes) and a pin-follow PR moves lint.yml and build.yml. Until that PR, Lint on main runs on the 0.2.17 image, whose baked checksums differ from this repository's .pre-commit-config.yaml, so Lint takes the install path for that stretch.
Verified
Removing mock_roles alone, linted the way CI does, reproduced 5 syntax-check[specific] errors; with the link the run passes with no warnings, locally and with CI's preset path. The wrapper leaves no temporary directory after a pass or a failing lint.
The real ansible-test-sanity.sh ran end to end against the real ansible-test on the committed tree (34 test runs on this host, no findings; the host has no Python 3.14 or 3.15 interpreter for the compile test, CI runs 36). It also ran for real as the pre-push hook of this push: ansible-test sanity ... Passed.
Through git push --dry-run in a throwaway clone with the hook installed: a commit with _ as a name inside a function is blocked (exit 1, the same pylint message as CI, failed to push some refs), and the push passes once it is removed. A module-level _ is not flagged by that pylint, so the check is as strict as CI's and no stricter.
scripts/dev-setup.sh run for real installs the pre-push hook script with the PATH marker next to the other two.
174 script tests pass; every hook passed on every commit except the format commit's retries, which were ruff-format rewriting a new file before the commit went through.
Not verified
This PR's Lint and Build runs on the pushed head: Build failed on the first head only for the name above, which the sanity run now reproduces and clears locally.
The image build of 0.2.18 and the baked path with the three-hook-type config: both run only on main.
Things to know
With the real roles resolved, ansible-lint now checks the scenarios' converge plays against them; they pass today, but lint can fail on a play where mock_roles used to hide it.
The pre-push hook checks HEAD: a push of another branch than the checked-out one checks the wrong commit (the script says so).
Whether to comment on or close#112 and #118 afterwards is yours; this PR does not use a closing keyword.
Step 5 of #118, the last open item, plus a pre-push hook for `ansible-test sanity` that came out of this PR's own Build failure. Refs #118. **This PR is an image input** (it edits `.pre-commit-config.yaml`): it carries the `ci` bump 0.2.17 -> 0.2.18, and a pin-follow PR is needed after the merge builds the image.
## 1. Lint resolves the Collection's own roles; `mock_roles` is gone (3289c0d)
The molecule scenarios' converge plays call the roles by FQCN (`mortis.kamino.<role>`), which only resolves from an `ansible_collections/<namespace>/<name>` directory, and a checkout is not one. `.ansible-lint` therefore listed the five roles in `mock_roles`, and ansible-lint never checked those plays against the real roles.
`scripts/ansible-lint.sh`, which the `ansible-lint` hook runs in CI and locally, links the checkout as `ansible_collections/<namespace>/<name>` in a temporary root (namespace and name read from `galaxy.yml`), puts that root first on `ANSIBLE_COLLECTIONS_PATH` (after it comes CI's `/opt/collections` or the clone's `.ansible/collections`, as before) and removes it on exit. It no longer `exec`s ansible-lint, so the cleanup trap runs; the exit code is unchanged. A bare `ansible-lint` outside the hook gets no link; `.ansible-lint` says so.
## 2. A name the sanity pylint disallows (6b930a0)
The first Build run of this PR failed in `ansible-test sanity`: `tests/scripts/test_ansible_lint_wrapper.py:37:13: disallowed-name: Disallowed name "_"`. Ruff accepts the name; the pylint configuration of ansible-test, which also scans the Python under `tests/`, does not. Fixed by indexing the `partition` result.
## 3. `ansible-test sanity` before a push (574c0d0, 18a7e26)
- `scripts/ansible-test-sanity.sh` copies `HEAD` (`git archive`: the committed files only) into a temporary `ansible_collections/<namespace>/<name>`, applies the Build job's ignore-file step (`ignore-common.txt` to `ignore-<core MAJOR.MINOR>.txt`) and runs `ansible-test sanity --requirements`, passing extra arguments through. Eleven tests cover it.
- A `pre-push` hook (`language: system`, `always_run`, `pass_filenames: false`) runs it. `pre-push` is in `default_install_hook_types`, and `dev-setup.sh` treats it like the other two hook types, so its hook script also gets the virtualenv on `PATH`. It is pre-push and not pre-commit because a cold run builds virtualenvs and needs the network (minutes), then reuses them. CI's `pre-commit run --all-files` does not run that stage (the Build job runs sanity itself), and a system hook builds no environment, so the image gains no layer size.
- `CLAUDE.md` and `CONTRIBUTING.md` say that `git push` runs it.
## Image loop
`.pre-commit-config.yaml` is baked into the `ci` image, so `scripts/bump_image_versions.py` moved `ci` 0.2.17 -> 0.2.18 (`check_image_versions.py bump origin/main` passes). After the merge `image.yml` builds 0.2.18 on `main` (the build prints the compressed layer sizes) and a pin-follow PR moves `lint.yml` and `build.yml`. Until that PR, Lint on `main` runs on the 0.2.17 image, whose baked checksums differ from this repository's `.pre-commit-config.yaml`, so Lint takes the install path for that stretch.
## Verified
- Removing `mock_roles` alone, linted the way CI does, reproduced 5 `syntax-check[specific]` errors; with the link the run passes with no warnings, locally and with CI's preset path. The wrapper leaves no temporary directory after a pass or a failing lint.
- The real `ansible-test-sanity.sh` ran end to end against the real `ansible-test` on the committed tree (34 test runs on this host, no findings; the host has no Python 3.14 or 3.15 interpreter for the compile test, CI runs 36). It also ran for real as the pre-push hook of this push: `ansible-test sanity ... Passed`.
- Through `git push --dry-run` in a throwaway clone with the hook installed: a commit with `_` as a name inside a function is blocked (exit 1, the same pylint message as CI, `failed to push some refs`), and the push passes once it is removed. A module-level `_` is not flagged by that pylint, so the check is as strict as CI's and no stricter.
- `scripts/dev-setup.sh` run for real installs the `pre-push` hook script with the `PATH` marker next to the other two.
- 174 script tests pass; every hook passed on every commit except the format commit's retries, which were `ruff-format` rewriting a new file before the commit went through.
## Not verified
- This PR's Lint and Build runs on the pushed head: Build failed on the first head only for the name above, which the sanity run now reproduces and clears locally.
- The image build of 0.2.18 and the baked path with the three-hook-type config: both run only on `main`.
## Things to know
- With the real roles resolved, ansible-lint now checks the scenarios' converge plays against them; they pass today, but lint can fail on a play where `mock_roles` used to hide it.
- The pre-push hook checks `HEAD`: a push of another branch than the checked-out one checks the wrong commit (the script says so).
- Whether to comment on or close #112 and #118 afterwards is yours; this PR does not use a closing keyword.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Step 5 of #118. The scenarios' converge plays call the roles by FQCN (mortis.kamino.<role>), which only resolves from an ansible_collections/<namespace>/<name> directory, and a checkout is not one, so .ansible-lint listed the five roles in mock_roles and ansible-lint never checked those plays against the real roles.
scripts/ansible-lint.sh, which the ansible-lint hook runs in CI and locally, now links the checkout as ansible_collections/<namespace>/<name> in a temporary root (namespace and name read from galaxy.yml), puts that root first on ANSIBLE_COLLECTIONS_PATH and removes it on exit, so ansible-lint reads the checkout itself. Removing mock_roles reproduced five syntax-check[specific] role-not-found errors; with the link the run passes with no warnings, locally and with CI's preset path. A bare ansible-lint, outside the hook, does not get the link; .ansible-lint says so.
No image input changes: .pre-commit-config.yaml, requirements and images/** are untouched, so no version bump or second pull request. Closes the last open item of #118.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
The Build check failed in ansible-test sanity: pylint reported tests/scripts/test_ansible_lint_wrapper.py:37:13 disallowed-name for `_`, from unpacking the middle of str.partition. Ruff accepts the name, but the pylint configuration of ansible-test, which also scans the Python under tests/, does not. Index the partition result instead. Reproduced locally with ansible-test sanity --test pylint on a copy of the tree under ansible_collections/mortis/kamino: the committed file fails with the same message, this one passes.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
ansible-test only runs a collection from an ansible_collections/<namespace>/<name> directory, so scripts/ansible-test-sanity.sh copies HEAD (git archive: the committed files only) into a temporary one, applies the Build job's ignore-file step and runs ansible-test sanity --requirements, passing extra arguments through. The sanity tests carry their own pylint, pep8 and shellcheck settings and also scan the Python under tests/, which ruff and the other hooks do not (the Build check failed on a name only that pylint disallows). The hook that runs it before a push follows in the next commit.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
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
Claude
changed title from ci(lint): resolve the Collection's own roles and drop mock_roles to ci: resolve the Collection's own roles in lint and run ansible-test sanity before a push2026-11-14 15:53:44 +00:00
Defame1297
scheduled this pull request to auto merge when all checks succeed 2026-11-14 15:58:54 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Step 5 of #118, the last open item, plus a pre-push hook for
ansible-test sanitythat came out of this PR's own Build failure. Refs #118. This PR is an image input (it edits.pre-commit-config.yaml): it carries thecibump 0.2.17 -> 0.2.18, and a pin-follow PR is needed after the merge builds the image.1. Lint resolves the Collection's own roles;
mock_rolesis gone (3289c0d)The molecule scenarios' converge plays call the roles by FQCN (
mortis.kamino.<role>), which only resolves from anansible_collections/<namespace>/<name>directory, and a checkout is not one..ansible-linttherefore listed the five roles inmock_roles, and ansible-lint never checked those plays against the real roles.scripts/ansible-lint.sh, which theansible-linthook runs in CI and locally, links the checkout asansible_collections/<namespace>/<name>in a temporary root (namespace and name read fromgalaxy.yml), puts that root first onANSIBLE_COLLECTIONS_PATH(after it comes CI's/opt/collectionsor the clone's.ansible/collections, as before) and removes it on exit. It no longerexecs ansible-lint, so the cleanup trap runs; the exit code is unchanged. A bareansible-lintoutside the hook gets no link;.ansible-lintsays so.2. A name the sanity pylint disallows (
6b930a0)The first Build run of this PR failed in
ansible-test sanity:tests/scripts/test_ansible_lint_wrapper.py:37:13: disallowed-name: Disallowed name "_". Ruff accepts the name; the pylint configuration of ansible-test, which also scans the Python undertests/, does not. Fixed by indexing thepartitionresult.3.
ansible-test sanitybefore a push (574c0d0,18a7e26)scripts/ansible-test-sanity.shcopiesHEAD(git archive: the committed files only) into a temporaryansible_collections/<namespace>/<name>, applies the Build job's ignore-file step (ignore-common.txttoignore-<core MAJOR.MINOR>.txt) and runsansible-test sanity --requirements, passing extra arguments through. Eleven tests cover it.pre-pushhook (language: system,always_run,pass_filenames: false) runs it.pre-pushis indefault_install_hook_types, anddev-setup.shtreats it like the other two hook types, so its hook script also gets the virtualenv onPATH. It is pre-push and not pre-commit because a cold run builds virtualenvs and needs the network (minutes), then reuses them. CI'spre-commit run --all-filesdoes not run that stage (the Build job runs sanity itself), and a system hook builds no environment, so the image gains no layer size.CLAUDE.mdandCONTRIBUTING.mdsay thatgit pushruns it.Image loop
.pre-commit-config.yamlis baked into theciimage, soscripts/bump_image_versions.pymovedci0.2.17 -> 0.2.18 (check_image_versions.py bump origin/mainpasses). After the mergeimage.ymlbuilds 0.2.18 onmain(the build prints the compressed layer sizes) and a pin-follow PR moveslint.ymlandbuild.yml. Until that PR, Lint onmainruns on the 0.2.17 image, whose baked checksums differ from this repository's.pre-commit-config.yaml, so Lint takes the install path for that stretch.Verified
mock_rolesalone, linted the way CI does, reproduced 5syntax-check[specific]errors; with the link the run passes with no warnings, locally and with CI's preset path. The wrapper leaves no temporary directory after a pass or a failing lint.ansible-test-sanity.shran end to end against the realansible-teston the committed tree (34 test runs on this host, no findings; the host has no Python 3.14 or 3.15 interpreter for the compile test, CI runs 36). It also ran for real as the pre-push hook of this push:ansible-test sanity ... Passed.git push --dry-runin a throwaway clone with the hook installed: a commit with_as a name inside a function is blocked (exit 1, the same pylint message as CI,failed to push some refs), and the push passes once it is removed. A module-level_is not flagged by that pylint, so the check is as strict as CI's and no stricter.scripts/dev-setup.shrun for real installs thepre-pushhook script with thePATHmarker next to the other two.ruff-formatrewriting a new file before the commit went through.Not verified
main.Things to know
mock_rolesused to hide it.HEAD: a push of another branch than the checked-out one checks the wrong commit (the script says so).🤖 Generated with Claude Code
ci(lint): resolve the Collection's own roles and drop mock_rolesto ci: resolve the Collection's own roles in lint and run ansible-test sanity before a push