Merge remote-tracking branch 'origin/main' into fix/env/distro-derived-keys/794

This commit is contained in:
kevinveenbirkenbach committed 2026-10-15 01:07:53 +02:00
commit b637742f96
46 files changed
+793 -134

No files matched your search

Whitespace-only changes.
@@ -0,0 +1,62 @@
"""``scripts/lint/mermaid.sh`` renders with the browser install-lint provisioned.
``make lint`` runs its targets in parallel, so the script must not reach for a
package manager, and a browser that cannot start must fail the lint once with
its reason instead of once per Markdown file.
"""
from __future__ import annotations
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
from utils.cache.files import PROJECT_ROOT
SCRIPT = Path(PROJECT_ROOT) / "scripts" / "lint" / "mermaid.sh"
LIBRARY_ERROR = (
"chrome-headless-shell: error while loading shared libraries: libnspr4.so"
)
RECORDING_STUB = '#!/bin/sh\necho "$(basename "$0")" >> "$STUB_CALLS"\n'
class TestMermaidLint(unittest.TestCase):
def test_a_browser_that_cannot_start_fails_before_any_file_renders(self):
with tempfile.TemporaryDirectory() as tmp:
bin_dir = Path(tmp)
calls = bin_dir / "calls"
calls.touch()
for name in ("npx", "apt-get"):
(bin_dir / name).write_text(RECORDING_STUB)
(bin_dir / "mmdc").write_text(
f"{RECORDING_STUB}echo '{LIBRARY_ERROR}' >&2\nexit 1\n"
)
for stub in bin_dir.iterdir():
stub.chmod(0o755)
env = {
k: v
for k, v in os.environ.items()
if not k.startswith("INFINITO_") and k != "BASH_ENV"
}
env["PATH"] = f"{bin_dir}{os.pathsep}{env['PATH']}"
env["STUB_CALLS"] = str(calls)
proc = subprocess.run(
["bash", str(SCRIPT)],
env=env,
capture_output=True,
text=True,
check=False,
)
recorded = calls.read_text().split() # nocheck: cache-read stub call log
self.assertEqual(proc.returncode, 1, proc.stderr)
self.assertIn("cannot render a minimal diagram", proc.stderr)
self.assertIn(LIBRARY_ERROR, proc.stderr)
self.assertNotIn("❌", proc.stdout)
self.assertEqual(recorded, ["mmdc"])
if __name__ == "__main__":
unittest.main()
Whitespace-only changes.
@@ -0,0 +1,66 @@
from __future__ import annotations
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
from utils.cache.files import PROJECT_ROOT
SCRIPT = (
PROJECT_ROOT / "scripts" / "meta" / "resolve" / "missing" / "highest_release_tag.sh"
)
TAGS = ("v9.0.0", "v9.0.1", "v9.0.2", "v14.1.0", "v15.0.0")
STUBS = {
"git": '#!/usr/bin/env bash\nprintf "%s\\n" ${STUB_TAGS}\n',
"docker": (
"#!/usr/bin/env bash\n"
'case " ${STUB_MISSING} " in *" ${3##*:} "*) exit 1 ;; esac\n'
),
}
def pick(*missing: str) -> subprocess.CompletedProcess:
"""Run the picker against stubbed ``git`` tags and ``docker`` manifests.
Args:
missing: tags whose images the registry does not hold.
"""
with tempfile.TemporaryDirectory() as tmp:
for name, body in STUBS.items():
stub = Path(tmp) / name
stub.write_text(body)
stub.chmod(0o755)
env = {
**{k: v for k, v in os.environ.items() if k != "BASH_ENV"},
"PATH": f"{tmp}{os.pathsep}{os.environ['PATH']}",
"STUB_TAGS": " ".join(TAGS),
"STUB_MISSING": " ".join(missing),
"OWNER": "acme",
"REGISTRY": "ghcr.io",
"REPO_PREFIX": "core",
"INFINITO_DISTROS": "debian arch",
}
return subprocess.run(
["bash", str(SCRIPT)],
env=env,
capture_output=True,
text=True,
check=True,
)
class TestHighestReleaseTag(unittest.TestCase):
def test_tags_below_the_oldest_buildable_one_are_not_picked(self) -> None:
self.assertEqual("", pick("v9.0.1", "v9.0.0").stdout)
def test_the_oldest_buildable_tag_is_picked(self) -> None:
self.assertEqual("v9.0.2\n", pick("v9.0.2", "v9.0.1").stdout)
def test_the_highest_missing_tag_is_picked(self) -> None:
self.assertEqual("v14.1.0\n", pick("v14.1.0", "v9.0.1").stdout)
if __name__ == "__main__":
unittest.main()