diff --git a/.github/scripts/prepare-gnome-extension-bumps.py b/.github/scripts/prepare-gnome-extension-bumps.py index 7a66a7b86..159ad2a0c 100755 --- a/.github/scripts/prepare-gnome-extension-bumps.py +++ b/.github/scripts/prepare-gnome-extension-bumps.py @@ -4,6 +4,7 @@ from __future__ import annotations import argparse +import ast import os import subprocess import sys @@ -97,9 +98,41 @@ def update_submodule(root: Path, name: str, path: str) -> tuple[str, str]: return pinned, run_git(root, "-C", path, "rev-parse", "HEAD").stdout.strip() +def archive_paths(root: Path) -> set[str]: + """Submodules whose extension ships from a pinned, sha256-checked archive. + + Their gitlink is only reference source: scripts/build-gnome-extensions.sh + installs the archive, and provenance.json records both. Moving the gitlink + alone would name source that does not ship, so they are bumped only + together with their archive URL and digest, by hand. + """ + verifier = root / "scripts/verify-gnome-extensions.py" + if not verifier.is_file(): + return set() + names: dict[str, object] = {} + for node in ast.parse(verifier.read_text()).body: + if isinstance(node, ast.Assign) and len(node.targets) == 1: + target = node.targets[0] + if isinstance(target, ast.Name) and target.id in ( + "ARCHIVES", "SOURCE_EXTENSIONS", "EXTENSION_BASE" + ): + names[target.id] = ast.literal_eval(node.value) + archives, sources, base = ( + names.get("ARCHIVES"), names.get("SOURCE_EXTENSIONS"), names.get("EXTENSION_BASE") + ) + if not (isinstance(archives, dict) and isinstance(sources, dict) and isinstance(base, str)): + raise RuntimeError(f"cannot read ARCHIVES/SOURCE_EXTENSIONS/EXTENSION_BASE from {verifier}") + return {base + sources[uuid] for uuid in archives} + + def prepare(root: Path, report_path: Path) -> list[Bump]: bumps = [] + archived = archive_paths(root) for name, path in submodules(root): + if any(metadata.startswith(path + "/") for metadata in archived): + pinned = run_git(root, "rev-parse", f"HEAD:{path}").stdout.strip() + bumps.append(Bump(path, pinned, pinned, "—", "skipped (ships from a pinned archive)")) + continue pinned, upstream = update_submodule(root, name, path) if pinned == upstream: bumps.append(Bump(path, pinned, upstream, "—", "unchanged")) @@ -131,6 +164,7 @@ def prepare(root: Path, report_path: Path) -> list[Bump]: "# GNOME extension bumps", "", "Valid tracked-branch heads are proposed; missing or invalid metadata keeps the existing pin and does not block other extensions.", + "Extensions that ship from a pinned archive are never bumped here: their gitlink moves only with the archive URL and sha256.", "The proposal uses the repository-scoped App so normal pull-request contract and image-build CI run on its exact head.", "Hive review, required checks and the normal merge policy still apply. Source metadata alone does not prove GNOME 51 runtime compatibility.", "", diff --git a/docs/skills/ci-workflows.md b/docs/skills/ci-workflows.md index bb274ec3e..18816c910 100644 --- a/docs/skills/ci-workflows.md +++ b/docs/skills/ci-workflows.md @@ -76,7 +76,10 @@ post-build verification workflows, not the complete workflow inventory: - `.github/workflows/update-gnome-extensions.yml` -- weekly and manual submodule updates. `prepare-gnome-extension-bumps.py` validates each tracked-branch head; missing or invalid metadata keeps that source pinned, - warns in the run summary, and does not block other candidates. It uses the + warns in the run summary, and does not block other candidates. Extensions + in `ARCHIVES` ship from a pinned, sha256-checked zip, so their gitlink is + never bumped alone (#1290): move it by hand with the archive URL and digest. + It uses the metadata paths in `scripts/verify-gnome-extensions.py` (`SOURCE_EXTENSIONS`); update that map when adding an extension. Paths are passed as argv and `shell-version` values are allow-listed in the report. diff --git a/tests/test_gnome_extension_bumps.py b/tests/test_gnome_extension_bumps.py index f09886e14..5a87a68d9 100644 --- a/tests/test_gnome_extension_bumps.py +++ b/tests/test_gnome_extension_bumps.py @@ -50,7 +50,15 @@ def test_invalid_head_is_skipped_without_blocking_valid_head(self) -> None: self.git(root, "config", "user.email", "extension-test@example.invalid", env=env) remotes = {} - for name in ("valid", "retired"): + # "archived" ships from a pinned zip (ARCHIVES in the verifier), + # so its gitlink must not move on its own (#1290, Copyous). + (root / "scripts").mkdir() + (root / "scripts/verify-gnome-extensions.py").write_text( + 'SOURCE_EXTENSIONS = {"archived@example": "archived/resources/metadata.json"}\n' + 'EXTENSION_BASE = "extensions/"\n' + 'ARCHIVES = {"archived@example": "archived"}\n' + ) + for name in ("valid", "retired", "archived"): remote = base / f"{name}-upstream" self.create_upstream(remote, name, env) self.git( @@ -72,7 +80,7 @@ def test_invalid_head_is_skipped_without_blocking_valid_head(self) -> None: ) remotes[name] = remote - self.git(root, "add", ".gitmodules", "extensions", env=env) + self.git(root, "add", ".gitmodules", "extensions", "scripts", env=env) self.git(root, "commit", "-m", "pin extensions", env=env) old = { name: self.git(root, "rev-parse", f"HEAD:extensions/{name}", env=env) @@ -82,6 +90,9 @@ def test_invalid_head_is_skipped_without_blocking_valid_head(self) -> None: (remotes["valid"] / "fix.js").write_text("// compatible upstream fix\n") self.git(remotes["valid"], "add", "fix.js", env=env) self.git(remotes["valid"], "commit", "-m", "valid update", env=env) + (remotes["archived"] / "fix.js").write_text("// newer than the pinned zip\n") + self.git(remotes["archived"], "add", "fix.js", env=env) + self.git(remotes["archived"], "commit", "-m", "archived update", env=env) (remotes["retired"] / "metadata.json").unlink() (remotes["retired"] / "README.md").write_text("Source was removed upstream.\n") self.git(remotes["retired"], "add", "-A", env=env) @@ -127,6 +138,14 @@ def test_invalid_head_is_skipped_without_blocking_valid_head(self) -> None: contents, ) self.assertIn("keeping", result.stderr) + self.assertEqual( + self.git(root, "rev-parse", "HEAD:extensions/archived", env=env), + old["archived"], + ) + self.assertIn( + f"| `extensions/archived` | `{old['archived'][:12]}` | `{old['archived'][:12]}` | — | skipped (ships from a pinned archive) |", + contents, + ) if __name__ == "__main__":