feat(image): bake the ansible-test sanity virtualenvs into the ci image #9

Merged
Defame1297 merged 2 commits from feat/ci-image-sanity-venvs into main 2026-10-25 12:14:08 +00:00
Owner

Why

After #8 Build takes ~37s, most of it ansible-test sanity --requirements creating one virtualenv per sanity test (~/.ansible/test/venv/<label>/<python>/<hash>) and pip-installing into each. ansible-test caches them by the hash of the test's requirements and reuses them, and has --prime-venvs to create them without running tests.

Change

  • images/ci/Dockerfile, build stage: symlink the uv-managed python3.11/python3.13 onto PATH, create a stub collection (ansible_collections/mortis/kamino with a minimal galaxy.yml), run ansible-test sanity --prime-venvs --requirements, print the sizes. Final stage: COPY --from=build /root/.ansible/test /root/.ansible/test as its own layer.
  • image.yml: the ci image version 0.1.0 → 0.2.0, so the new content gets a new tag (a rebuild never moves a published tag).

Risks (no container runtime here, so only the first build on main tells)

  • The venvs for the baked 3.11/3.13 are created from the uv-managed interpreters (bootstrap via get-pip, as on 3.12); if --prime-venvs fails for one the build fails with the ansible-test output.
  • Layer size: the pylint venv is the largest; the build prints sizes. A 413 on the push means splitting the COPY per label directory.
  • The hash includes the requirement versions, i.e. the ansible-core pin; a pin bump rebuilds the venvs at run time (the pin-drift fallback already covers that case) until the image is rebuilt.

After merge

image.yml publishes ci:0.2.0; a follow-up PR points Lint/Build at its digest and compares the Build time (37s now).

🤖 Generated with Claude Code

## Why After #8 Build takes ~37s, most of it `ansible-test sanity --requirements` creating one virtualenv per sanity test (`~/.ansible/test/venv/<label>/<python>/<hash>`) and pip-installing into each. ansible-test caches them by the hash of the test's requirements and reuses them, and has `--prime-venvs` to create them without running tests. ## Change - `images/ci/Dockerfile`, build stage: symlink the uv-managed `python3.11`/`python3.13` onto PATH, create a stub collection (`ansible_collections/mortis/kamino` with a minimal `galaxy.yml`), run `ansible-test sanity --prime-venvs --requirements`, print the sizes. Final stage: `COPY --from=build /root/.ansible/test /root/.ansible/test` as its own layer. - `image.yml`: the ci image version `0.1.0` → `0.2.0`, so the new content gets a new tag (a rebuild never moves a published tag). ## Risks (no container runtime here, so only the first build on `main` tells) - The venvs for the baked 3.11/3.13 are created from the uv-managed interpreters (bootstrap via get-pip, as on 3.12); if `--prime-venvs` fails for one the build fails with the ansible-test output. - Layer size: the pylint venv is the largest; the build prints sizes. A 413 on the push means splitting the COPY per label directory. - The hash includes the requirement versions, i.e. the ansible-core pin; a pin bump rebuilds the venvs at run time (the pin-drift fallback already covers that case) until the image is rebuilt. ## After merge `image.yml` publishes `ci:0.2.0`; a follow-up PR points Lint/Build at its digest and compares the Build time (37s now). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 2 commits 2026-10-25 12:10:20 +00:00
`ansible-test sanity --requirements` builds one virtualenv per test under
~/.ansible/test/venv (keyed by the requirements hash) on every run: about
25s of the Build job. Prime them at image build time with --prime-venvs
against a stub collection, for the controller Python and the baked 3.11 and
3.13, and copy ~/.ansible/test into the final image as its own layer.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
feat(image): release the ci image as 0.2.0
Lint / lint (pull_request) Successful in 4s
Build / build (pull_request) Successful in 24s
908abd1a16
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 merged commit 10dec8b9a6 into main 2026-10-25 12:14:08 +00:00
Defame1297 deleted branch feat/ci-image-sanity-venvs 2026-10-25 12:14:08 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#9