Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/scripts/prepare-gnome-extension-bumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import argparse
import ast
import os
import subprocess
import sys
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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.",
"",
Expand Down
5 changes: 4 additions & 1 deletion docs/skills/ci-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 21 additions & 2 deletions tests/test_gnome_extension_bumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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__":
Expand Down
Loading