mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
The version cron updates docker image tags and repository refs, and tests/external/update covers docker, addons and repository. Neither sees a version inside an Ansible task variable, and dependabot reads pyproject.toml rather than roles/. A pin set once therefore froze and nothing thawed it: backup-docker-to-local has not moved since it was written, and the automtu pin one commit back would have gone the same way. utils/update/pip mirrors the docker module: collect the pins, ask PyPI, rewrite in place. Only exact == pins are collected, because a range or a VCS reference states an intent an updater must not overrule. The external check warns rather than fails, like its docker sibling, so a slow PyPI cannot redden a run and a release the repository has deliberately not taken is not a regression. The cron job is the docker job with one script swapped, so a changed pin arrives as its own PR under update/pip-pins. Executed: the collector finds both pins in the repository; a synthetic file rewrites from 1.0.0 to 1.1.1 with the indent, quoting and neighbouring line untouched; automtu==1.0.0 would be reported while a bare name and a git+ reference are passed over. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
"""Check exact pip pins in ``roles/**/*.yml`` against PyPI.
|
|
|
|
A pin freezes a version and nothing thaws it: the docker updater tracks image
|
|
tags, dependabot reads ``pyproject.toml``, and neither sees a version inside an
|
|
Ansible task variable. This reports the gap as GitHub Actions ``::warning::``
|
|
annotations.
|
|
|
|
Like the Docker check this is an opt-in external test that always passes, so
|
|
normal validation stays stable when PyPI is slow, and it never blocks on a
|
|
release the repository has deliberately not taken yet.
|
|
|
|
Suppress a package by placing ``# nocheck: pip-version`` on the line directly
|
|
above the ``package_name:`` key, or on the key itself.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from utils.annotations.message import warning
|
|
from utils.update.pip import collect_entries, find_outdated_updates
|
|
|
|
from . import PROJECT_ROOT
|
|
|
|
_REPO_ROOT = PROJECT_ROOT
|
|
|
|
|
|
class TestPipPins(unittest.TestCase):
|
|
"""Warn about pinned pip requirements that PyPI has moved past."""
|
|
|
|
def test_pinned_requirements_are_current(self) -> None:
|
|
entries = collect_entries(_REPO_ROOT)
|
|
self.assertTrue(entries, "No exact pip pins found under roles/")
|
|
|
|
updates = find_outdated_updates(_REPO_ROOT)
|
|
if not updates:
|
|
return
|
|
|
|
col_w = (32, 32, 18)
|
|
header = (
|
|
f"{'Role':<{col_w[0]}} {'Package':<{col_w[1]}} "
|
|
f"{'Current':<{col_w[2]}} Latest"
|
|
)
|
|
rows = "\n".join(
|
|
f"{u.entry.role:<{col_w[0]}} {u.entry.package:<{col_w[1]}} "
|
|
f"{u.entry.version:<{col_w[2]}} {u.latest}"
|
|
for u in updates
|
|
)
|
|
print(
|
|
f"\n⚠️ Outdated pip pins:\n{header}\n{'-' * 100}\n{rows}\n\n"
|
|
"💡 To suppress a warning add above the package_name: key:\n"
|
|
" # nocheck: pip-version"
|
|
)
|
|
for update in updates:
|
|
warning(
|
|
f"{update.entry.role}: {update.entry.package} is pinned at "
|
|
f"{update.entry.version}, latest on PyPI is {update.latest}",
|
|
title="Outdated pip pin",
|
|
file=str(update.entry.config_path.relative_to(_REPO_ROOT)),
|
|
)
|
|
|
|
|
|
if __name__ == "__main__": # pragma: no cover
|
|
unittest.main()
|