Use fetched sources for currency checks
All checks were successful
Build and publish policy-nexus image / build-and-push (push) Successful in 43s

This commit is contained in:
tegwick 2026-08-18 13:37:21 +02:00
parent e7b26ff158
commit e737b74688
2 changed files with 19 additions and 12 deletions

View file

@ -110,6 +110,20 @@ def _redirect(target: str, title: str) -> str:
)
def repository_paths(manifest_path: Path, manifest: dict[str, Any]) -> dict[str, Path]:
"""Resolve local or fetched source checkouts for a publication manifest."""
source_root = os.environ.get("POLICY_NEXUS_SOURCE_ROOT")
paths: dict[str, Path] = {}
for name, config in manifest["repositories"].items():
fetched = (Path(source_root) / name).resolve() if source_root else None
paths[name] = (
fetched
if fetched is not None and fetched.is_dir()
else (manifest_path.parent / config["path"]).resolve()
)
return paths
def _index_page(site: dict[str, Any], records: list[dict[str, str]]) -> str:
rows = []
for record in records:
@ -149,15 +163,7 @@ def build(
manifest_path = manifest_path.resolve()
manifest = load_manifest(manifest_path)
as_of = as_of or dt.date.today()
source_root = os.environ.get("POLICY_NEXUS_SOURCE_ROOT")
repository_paths = {}
for name, config in manifest["repositories"].items():
fetched = (Path(source_root) / name).resolve() if source_root else None
repository_paths[name] = (
fetched
if fetched is not None and fetched.is_dir()
else (manifest_path.parent / config["path"]).resolve()
)
resolved_repositories = repository_paths(manifest_path, manifest)
output_parent = output.resolve().parent
output_parent.mkdir(parents=True, exist_ok=True)
temporary = Path(tempfile.mkdtemp(prefix=f".{output.name}-", dir=output_parent))
@ -167,7 +173,7 @@ def build(
records: list[dict[str, str]] = []
try:
for document in manifest["documents"]:
repo = repository_paths[document["source_repo"]]
repo = resolved_repositories[document["source_repo"]]
source = (repo / document["source_path"]).resolve()
if not source.is_file() or repo not in source.parents:
raise FileNotFoundError(f"canonical source unavailable: {source}")

View file

@ -5,7 +5,7 @@ import argparse
import datetime as dt
from pathlib import Path
from build_site import _add_interval, load_manifest
from build_site import _add_interval, load_manifest, repository_paths
from render import split_frontmatter
@ -16,9 +16,10 @@ def main() -> int:
args = parser.parse_args()
manifest_path = args.manifest.resolve()
manifest = load_manifest(manifest_path)
repositories = repository_paths(manifest_path, manifest)
stale = 0
for document in manifest["documents"]:
repo = manifest_path.parent / manifest["repositories"][document["source_repo"]]["path"]
repo = repositories[document["source_repo"]]
source = (repo / document["source_path"]).resolve()
meta, _markdown = split_frontmatter(source.read_text(encoding="utf-8"))
reviewed = meta.get("last_reviewed") or meta.get("updated")