feat(update): bump addon pins through their declared source

The version-source updater only read meta/services.yml. An addon pinned in
meta/addons/<id>.yml stayed where it was: the ONLYOFFICE connector for
Nextcloud sat on v10.1.2, which does not install on Nextcloud 35, until
someone bumped it by hand.

The updater now reads addon files too. An addon declares its source in the
`update:` block it already has, beside monitored, catalog and upstream_id.
A monitored addon of the github-releases catalog needs nothing more: its
upstream_id names the repository whose tags are its versions. The
update-version-sources job opens the PRs, one per role.

Every pinned addon is wired:

- nextcloud onlyoffice carries its own version pin now. Its archive URL
  stays a literal that carries the pin, because
  test_pinned_addon_archives_available reads it as written
- wordpress mcp-adapter, moodle auth_oidc and jellyfin sso-authentication
  follow the tags of their repository, moodle within its v4.5 series
- the three xwiki extensions read their Maven metadata
- pretix-oidc reads the PyPI simple index. The JSON API answers 404 behind
  the package cache the test stack routes pypi.org through
- joomla's plugin is built here and jellyfin's ldap-authentication is bound
  to the md5 of its archive; both are opted out with that reason

A bump rewrites the pin and the config.archive line together, and an
archive that does not carry the pin fails test_version_keys, so the two
cannot drift apart again. test_version_pins_are_watched covers addon pins
as well: a new one without a source or a reasoned opt-out fails the lint.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-05 02:50:48 +02:00
1 parent 81ab6e4ffc
commit 739c78bad1
17 files changed
+408 -41

No files matched your search

+129 -1
View File
@@ -5,7 +5,7 @@ import unittest
import unittest.mock as mock
from pathlib import Path
from utils.roles.mapping import ROLE_FILE_META_SERVICES
from utils.roles.mapping import ROLE_DIR_META_ADDONS, ROLE_FILE_META_SERVICES
from utils.update import source as module
SERVICES = """\
@@ -33,6 +33,57 @@ frozen:
"""
ADDONS = {
"released": """\
---
enabled: true
version: "v1.2.0"
update:
monitored: true
catalog: github-releases
upstream_id: example/released
config:
archive: "https://example.test/released/download/v1.2.0/app.tar.gz"
""",
"declared": """\
---
enabled: true
version: "3.4"
update:
type: http_regex
url: https://example.test/metadata.xml
pattern: '<version>([0-9.]+)</version>'
""",
"unmonitored": """\
---
enabled: true
version: "1.0.0"
update:
monitored: false
catalog: github-releases
upstream_id: example/unmonitored
""",
"catalogued": """\
---
enabled: true
version: "1.0.0"
update:
monitored: true
catalog: wordpress-org
""",
"frozen": """\
---
enabled: true
# nocheck: unwatched-version Reason: bound to a checksum
version: "2.0.0"
update:
monitored: true
catalog: github-releases
upstream_id: example/frozen
""",
}
def _repo(services: str = SERVICES) -> Path:
tmp = Path(tempfile.mkdtemp())
config = tmp / "roles" / "web-app-example" / ROLE_FILE_META_SERVICES
@@ -41,6 +92,15 @@ def _repo(services: str = SERVICES) -> Path:
return tmp
def _addon_repo(addons: dict[str, str] | None = None) -> Path:
tmp = Path(tempfile.mkdtemp())
directory = tmp / "roles" / "web-app-example" / ROLE_DIR_META_ADDONS
directory.mkdir(parents=True)
for addon_id, content in (ADDONS if addons is None else addons).items():
(directory / f"{addon_id}.yml").write_text(content, encoding="utf-8")
return tmp
class TestCollectEntries(unittest.TestCase):
def test_each_declared_pin_is_collected_and_a_suppressed_one_is_not(self) -> None:
entries = module.collect_entries(_repo())
@@ -92,5 +152,73 @@ class TestOutdated(unittest.TestCase):
self.assertEqual(module.outdated([self._entry(root)], root), [])
class TestAddons(unittest.TestCase):
def test_only_a_declared_or_github_released_addon_pin_is_collected(self) -> None:
entries = module.collect_entries(_addon_repo())
self.assertEqual(
[
(e.entity, e.key, e.current, e.source["type"], e.line, e.addon)
for e in entries
],
[
("declared", "version", "3.4", "http_regex", 3, True),
("released", "version", "v1.2.0", "git_tags", 3, True),
],
)
self.assertEqual(
entries[1].source["repository"], "https://github.com/example/released.git"
)
def test_an_addon_pin_moves_together_with_the_archive_that_carries_it(self) -> None:
root = _addon_repo({"released": ADDONS["released"]})
with mock.patch.object(module, "candidates", return_value=["v1.3.0"]):
updates = module.find_outdated_updates(root)
module.apply_updates(updates)
addon = (
root / "roles" / "web-app-example" / ROLE_DIR_META_ADDONS / "released.yml"
)
written = addon.read_text() # nocheck: cache-read just rewritten here
self.assertIn('version: "v1.3.0"', written)
self.assertIn("released/download/v1.3.0/app.tar.gz", written)
self.assertIn("upstream_id: example/released", written)
def test_an_archive_that_does_not_carry_the_pin_is_reported(self) -> None:
drifted = ADDONS["released"].replace('version: "v1.2.0"', 'version: "v1.1.0"')
root = _addon_repo({"drifted": drifted})
self.assertEqual(
module.invalid_declarations(root),
[
(
"web-app-example/addons/drifted.version: config.archive does "
"not carry the pinned version, so a bump would move only one "
"of the two"
),
],
)
def test_an_addon_block_that_cannot_resolve_is_reported(self) -> None:
root = _addon_repo(
{"broken": "---\nenabled: true\nupdate:\n type: carrier_pigeon\n"}
)
self.assertEqual(
module.invalid_declarations(root),
[
(
"web-app-example/addons/broken: update.key 'version' names no "
"key of the addon"
),
(
"web-app-example/addons/broken.version: unknown update.type "
"'carrier_pigeon', expected one of git_tags, registry_tags, npm, "
"http_regex, script"
),
],
)
if __name__ == "__main__":
unittest.main()