fix: lock workflow checkout provenance
Some checks failed
Build and publish policy-nexus image / build-and-push (push) Failing after 48s

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a058f3-8ba0-7692-a042-9a870fc3d663
This commit is contained in:
tegwick 2026-09-01 00:37:12 +02:00
parent a0e4964b46
commit 8ea8a4b41c
2 changed files with 23 additions and 24 deletions

View file

@ -88,17 +88,19 @@ class PublicationTest(unittest.TestCase):
def test_archive_build_uses_fetched_source_lock_revision(self) -> None: def test_archive_build_uses_fetched_source_lock_revision(self) -> None:
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory:
root = Path(directory) root = Path(directory)
repo = root / "the-custodian" source_root = root / "_sources"
source_root.mkdir()
repo = root / "policy-nexus"
source = repo / "canon/example.md" source = repo / "canon/example.md"
source.parent.mkdir(parents=True) source.parent.mkdir(parents=True)
source.write_text("example", encoding="utf-8") source.write_text("example", encoding="utf-8")
revision = "b" * 40 revision = "b" * 40
(root / "source-lock.json").write_text( (source_root / "source-lock.json").write_text(
json.dumps( json.dumps(
{ {
"schema_version": 1, "schema_version": 1,
"repositories": { "repositories": {
"the-custodian": {"revision": revision} "policy-nexus": {"revision": revision}
}, },
} }
), ),
@ -106,7 +108,9 @@ class PublicationTest(unittest.TestCase):
) )
with mock.patch.dict( with mock.patch.dict(
os.environ, {"POLICY_NEXUS_SOURCE_ROOT": str(root)}, clear=False os.environ,
{"POLICY_NEXUS_SOURCE_ROOT": str(source_root)},
clear=False,
): ):
self.assertEqual(revision, build_site._source_revision(repo, source)) self.assertEqual(revision, build_site._source_revision(repo, source))

View file

@ -48,11 +48,6 @@ def _source_revision(repo: Path, source: Path) -> str:
source_root = os.environ.get("POLICY_NEXUS_SOURCE_ROOT", "") source_root = os.environ.get("POLICY_NEXUS_SOURCE_ROOT", "")
if source_root: if source_root:
root = Path(source_root).resolve() root = Path(source_root).resolve()
try:
repo.relative_to(root)
except ValueError:
pass
else:
lock_path = root / "source-lock.json" lock_path = root / "source-lock.json"
try: try:
lock = json.loads(lock_path.read_text(encoding="utf-8")) lock = json.loads(lock_path.read_text(encoding="utf-8"))