feat(image): bake the ansible-test sanity virtualenvs into the ci image #9
No files matched your search
@@ -73,7 +73,7 @@ jobs:
|
||||
subpath: images/molecule-ubuntu2404
|
||||
dockerfile: Dockerfile
|
||||
- name: ci
|
||||
version: 0.1.0
|
||||
version: 0.2.0
|
||||
subpath: ""
|
||||
dockerfile: images/ci/Dockerfile
|
||||
container:
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
# - /opt/pre-commit: every hook environment of .pre-commit-config.yaml, installed by
|
||||
# `pre-commit install-hooks` (gitleaks and actionlint are built from source by
|
||||
# pre-commit, which downloads a Go toolchain: that is most of the time saved).
|
||||
# - /root/.ansible/test: the ansible-test sanity virtualenvs, primed against a stub
|
||||
# collection (`ansible-test sanity --prime-venvs`), so a run only reuses them.
|
||||
# - Python 3.11 and 3.13 as python3.11 / python3.13 on PATH, so that
|
||||
# `ansible-test sanity` runs its compile test for them instead of skipping it.
|
||||
# They come from python-build-standalone through uv, pinned by the uv version.
|
||||
@@ -93,6 +95,23 @@ RUN set -eu; \
|
||||
find /opt/pre-commit -maxdepth 1 -mindepth 1 -exec du -sh {} + | sort -h; \
|
||||
du -sh /opt/venv /opt/python /opt/pre-commit
|
||||
|
||||
# ansible-test builds one virtualenv per sanity test under ~/.ansible/test/venv, keyed
|
||||
# by the hash of the test's requirements (so by the ansible-core pin), and reuses it on
|
||||
# later runs. --prime-venvs creates them without running any test; it needs a
|
||||
# collection tree, so a stub one is used. The target interpreters must be on PATH
|
||||
# first, as in the final image.
|
||||
RUN set -eu; \
|
||||
for v in 3.11 3.13; do \
|
||||
ln -s "$(echo /opt/python/cpython-${v}.*/bin/python${v})" "/usr/local/bin/python${v}"; \
|
||||
done; \
|
||||
mkdir -p /tmp/ac/ansible_collections/mortis/kamino; \
|
||||
cd /tmp/ac/ansible_collections/mortis/kamino; \
|
||||
printf -- '---\nnamespace: mortis\nname: kamino\nversion: 0.0.0\nreadme: README.md\nauthors:\n - ci\n' > galaxy.yml; \
|
||||
: > README.md; \
|
||||
PATH=/opt/venv/bin:$PATH ansible-test sanity --prime-venvs --requirements --color no; \
|
||||
rm -rf /tmp/ac; \
|
||||
du -sh /root/.ansible/test/venv/* /root/.ansible/test
|
||||
|
||||
|
||||
FROM os AS final
|
||||
|
||||
@@ -108,6 +127,8 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
COPY --from=build /opt/venv /opt/venv
|
||||
COPY --from=build /opt/python /opt/python
|
||||
COPY --from=build /opt/pre-commit /opt/pre-commit
|
||||
# The primed ansible-test sanity virtualenvs and its pip bootstrap cache.
|
||||
COPY --from=build /root/.ansible/test /root/.ansible/test
|
||||
|
||||
# The target interpreters ansible-test looks for on PATH, and the pin record.
|
||||
COPY --from=build /src/requirements-dev.txt /src/.pre-commit-config.yaml /opt/ci-pins/
|
||||
|
||||
Reference in new issue
Block a user