fix: regenerate the truth before a native refresh

This commit is contained in:
Abdessamad Derraz committed 2026-10-18 14:34:42 +02:00
1 parent 090369cb20
commit 3c5570f8f0
5 files changed
+33 -10

No files matched your search

+5 -1
View File
@@ -399,7 +399,11 @@ def check_native(platforms_dir: Path, cache_dir: Path, truth_dir: Path) -> list[
exporter_class = exporters.get(name)
if not exporter_class:
continue
truth, scraped = export_native.load_inputs(name, truth_dir, str(platforms_dir))
try:
truth, scraped = export_native.load_inputs(name, truth_dir, str(platforms_dir))
except export_native.StaleTruth as exc:
findings.append(Finding("native", name, STALE, detail=str(exc)))
continue
systems, _ = build_native_model(truth or {}, scraped)
wanted = export_native.wanted_sources(exporter_class(), systems, scraped)
reason = native_cache_state(
+5 -2
View File
@@ -265,8 +265,11 @@ class StaleTruth(ValueError):
@functools.lru_cache(maxsize=None)
def _truth_sources(platforms_dir: str) -> tuple[dict, dict, dict | None]:
"""Registry, profiles and database, as generate_truth reads them."""
with open(Path(platforms_dir) / "_registry.yml") as handle:
registry = (yaml_load(handle) or {}).get("platforms", {})
registry_path = Path(platforms_dir) / "_registry.yml"
registry: dict = {}
if registry_path.exists():
with open(registry_path) as handle:
registry = (yaml_load(handle) or {}).get("platforms", {})
profiles = load_emulator_profiles("emulators")
db = load_database(TRUTH_DB) if Path(TRUTH_DB).exists() else None
return registry, profiles, db
+13 -2
View File
@@ -12,7 +12,8 @@ Mapping (stale -> command):
-o platforms/<name>.yml
then the native refresh below: the original
the export patches must be the one just scraped
native/<name> python scripts/export_native.py --platform <name>
native/<name> python scripts/generate_truth.py --platform <name>, then
python scripts/export_native.py --platform <name>
--refresh-cache
targets/<name> python -m scripts.scraper.targets.<module>
-o platforms/targets/<name>.yml
@@ -169,6 +170,10 @@ def plan_jobs(
log = LOG_DIR / f"{area}__{_slug(subject)}.log"
then: tuple[tuple[str, ...], ...] = ()
if area == "platforms":
# The truth reads the platform file: regenerated first, or the
# native refresh refuses it as older than the profiles.
then = (tuple(_truth_refresh(subject)), tuple(_native_refresh(subject)))
elif area == "native":
then = (tuple(_native_refresh(subject)),)
jobs.append(
Job(area=area, subject=subject, command=command, log_path=log, then=then)
@@ -177,6 +182,10 @@ def plan_jobs(
return jobs, surfaced, ignored
def _truth_refresh(platform: str) -> list[str]:
return [sys.executable, "scripts/generate_truth.py", "--platform", platform]
def _native_refresh(platform: str) -> list[str]:
return [
sys.executable,
@@ -192,7 +201,9 @@ def _command_for(
) -> list[str] | None:
"""Map a stale finding to its refresh command, or None if manual."""
if area == "native":
return _native_refresh(subject)
# export_native refuses a truth older than the profiles, so the
# truth comes first and the original follows (Job.then).
return _truth_refresh(subject)
if area == "platforms":
entry = registry.get(subject) or {}