mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
Folds the parallel Docker-image and git-ref version-update plumbing
into a single subsystem so the auto-update workflow, the external
freshness tests, and the unit tests all share one module layout.
utils/
update/
base.py # semver primitives shared by both backends
docker.py # OCI registry lookups + version: line rewriter
repository.py # git ls-remote walker + ref: line rewriter
cli/contributing/update/
docker/ # python -m cli.contributing.update.docker
repository/ # python -m cli.contributing.update.repository
scripts/github/update/
image_versions.sh
repository_refs.sh
Tests mirror the same shape under tests/{unit,external}/update/{docker,repository}/.
Also widens the Docker bump scope to all roles (previously gated on
`web-*`) so non-web roles like sys-svc-container get bumped too;
pins Bookwyrm's python image at 3.11-bookworm via
`# nocheck: docker-version` with a TODO until upstream supports
Python >= 3.12.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from utils.cache.files import read_text
|
|
from utils.update.docker import update_config_versions
|
|
|
|
|
|
class TestUpdateDocker(unittest.TestCase):
|
|
def test_update_config_versions_updates_only_target_services(self) -> None:
|
|
# The file root of meta/services.yml IS the services map (no
|
|
# `compose.services` envelope), so service keys are at indent 0.
|
|
original = """moodle:
|
|
version: "4.5" # Keep comment
|
|
image: bitnamilegacy/moodle
|
|
nginx:
|
|
version: alpine
|
|
image: nginx
|
|
"""
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
config_path = Path(tmpdir) / "main.yml"
|
|
config_path.write_text(original, encoding="utf-8")
|
|
|
|
changed = update_config_versions(config_path, {"moodle": "5.0"})
|
|
|
|
self.assertTrue(changed)
|
|
updated = read_text(str(config_path))
|
|
self.assertIn('version: "5.0" # Keep comment', updated)
|
|
self.assertIn("version: alpine", updated)
|
|
self.assertNotIn('version: "4.5" # Keep comment', updated)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|