ci(python): one Python (3.14) for the lock, a clone and the ci image
Build / build (pull_request) Successful in 14s
Molecule / molecule (pull_request) Canceled after 0s
Lint / lint (pull_request) Canceled after 56s

.python-version (3.14) is the source. dev-setup.sh and lock-requirements.sh
require exactly that minor; the ci image builds /opt/venv from its baked
python-build-standalone of that version (ARG PYTHON_VERSION) instead of the
distribution's python3, and derives the python<MINOR> links for
ansible-test from it; `check_image_versions.py pins` fails when
.python-version, the lock header or an `ARG PYTHON_VERSION` differs.
The lock already carries the 3.14 header (Renovate's -full container runs
pip-compile on its own python 3.14.8); renovate.yml now says that python's
minor version must equal .python-version. ci image 0.2.25 -> 0.2.26.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-11-16 07:42:45 +00:00
1 parent 3a777ac015
commit b0607a39e2
12 files changed
+285 -43

No files matched your search

+45 -2
View File
@@ -21,8 +21,14 @@ from pathlib import Path
SCRIPT = Path(__file__).resolve().parents[2] / "scripts" / "dev-setup.sh"
PYTHON_STUB = """#!/bin/sh
# Stub interpreter: every -c check passes; `-m venv DIR` lays out DIR/bin with the stubs.
if [ "$1" = "-c" ]; then exit 0; fi
# Stub interpreter: a -c check passes, unless STUB_PY_MINOR is set and the check does not compare against
# that minor version (the pinned-version check of dev-setup.sh); `-m venv DIR` lays out DIR/bin with the stubs.
if [ "$1" = "-c" ]; then
if [ -n "${STUB_PY_MINOR:-}" ]; then
case "$2" in *"== '$STUB_PY_MINOR'"*) exit 0 ;; *) exit 1 ;; esac
fi
exit 0
fi
if [ "$1" = "-m" ] && [ "$2" = "venv" ]; then
mkdir -p "$3/bin"
cp "$STUB_DIR/python" "$3/bin/python"
@@ -113,6 +119,7 @@ class DevSetupTest(unittest.TestCase):
repo = self.tmp / name
(repo / "scripts").mkdir(parents=True)
shutil.copy(SCRIPT, repo / "scripts" / "dev-setup.sh")
(repo / ".python-version").write_text("3.13\n")
(repo / "requirements-dev.txt").write_text("")
(repo / "requirements-dev.lock").write_text("")
(repo / "requirements.yml").write_text("---\ncollections: []\n")
@@ -144,6 +151,42 @@ class DevSetupTest(unittest.TestCase):
def hook(self, repo: Path, name: str = "pre-commit") -> Path:
return repo / ".git" / "hooks" / name
def test_a_python_other_than_the_pin_is_refused(self) -> None:
repo = self.make_repo()
wrong = self.stubs / "wrong-python"
wrong.write_text("#!/bin/sh\nexit 1\n")
wrong.chmod(0o755)
proc = self.run_setup(repo, KAMINO_PYTHON=str(wrong))
self.assertNotEqual(proc.returncode, 0)
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
self.assertFalse((repo / ".venv").exists())
def test_an_interpreter_of_another_minor_is_refused_and_the_pinned_one_accepted(
self,
) -> None:
repo = self.make_repo()
proc = self.run_setup(repo, STUB_PY_MINOR="3.12")
self.assertNotEqual(proc.returncode, 0)
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
self.assertFalse((repo / ".venv").exists())
proc = self.run_setup(repo, STUB_PY_MINOR="3.13")
self.assertEqual(proc.returncode, 0, proc.stderr)
self.assertTrue((repo / ".venv").is_dir())
def test_a_missing_pin_file_is_refused_with_a_message(self) -> None:
repo = self.make_repo()
(repo / ".python-version").unlink()
proc = self.run_setup(repo)
self.assertNotEqual(proc.returncode, 0)
self.assertIn(".python-version is missing", proc.stderr)
def test_a_malformed_pin_file_is_refused(self) -> None:
repo = self.make_repo()
(repo / ".python-version").write_text("3.13.2\n")
proc = self.run_setup(repo)
self.assertNotEqual(proc.returncode, 0)
self.assertIn(".python-version must hold one MAJOR.MINOR", proc.stderr)
def test_normal_run(self) -> None:
repo = self.make_repo()
result = self.run_setup(repo)