mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: read the lakka release from lakka.yml
The target scraper asked for the latest Lakka release while lakka.yml named its version by hand, kept in step by a test alone. The scraper now reads that field, and check_freshness reports a newer Lakka release.
This commit is contained in:
1 parent
852415a0e4
commit
35b5458a2d
9 files changed
+113
-7
No files matched your search
+4
-2
@@ -1,7 +1,9 @@
|
||||
inherits: retroarch
|
||||
platform: Lakka
|
||||
homepage: "https://www.lakka.tv"
|
||||
# Lakka-LibreELEC's release tag, the revision platforms/targets/lakka.yml
|
||||
# reads its cores at. A version is never inherited from retroarch.yml.
|
||||
# Lakka-LibreELEC's release tag, the revision the target scraper reads
|
||||
# platforms/targets/lakka.yml at. Moving to a new release is an edit of this
|
||||
# field, then a rescrape of the targets. A version is never inherited from
|
||||
# retroarch.yml.
|
||||
version: v6.1
|
||||
# Lakka uses the same BIOS requirements as RetroArch
|
||||
@@ -55,7 +55,7 @@ from freshness.platforms import check_emulatorjs, check_platforms
|
||||
from freshness.profiles import check_profiles, check_source_paths
|
||||
from freshness.report import exit_code, render, unknown_areas_message
|
||||
from freshness.romfolders import check_romfolders
|
||||
from freshness.targets import check_targets
|
||||
from freshness.targets import check_lakka_release, check_targets
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ def main() -> int:
|
||||
)
|
||||
if "targets" in areas:
|
||||
findings.extend(check_targets(platforms_dir, workdir, profiles, args.jobs, args.offline))
|
||||
findings.append(check_lakka_release(platforms_dir, args.cache_dir, args.offline))
|
||||
if "romfolders" in areas:
|
||||
findings.extend(check_romfolders(platforms_dir, args.cache_dir, args.offline))
|
||||
if "coreinfo" in areas:
|
||||
|
||||
@@ -8,6 +8,7 @@ from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from core import upstream
|
||||
from model.profiles import upstream_profile_index
|
||||
from model.sources import source_yaml_file
|
||||
from model.targets import apply_target_overrides, platform_overrides, read_target_overrides
|
||||
@@ -17,6 +18,8 @@ from freshness.findings import (
|
||||
from freshness.platformdiff import diff_targets
|
||||
from freshness.rescrape import scrape_into_copy
|
||||
from freshness.scrapers import target_scrapers
|
||||
from scraper.targets import BaseTargetScraper
|
||||
from scraper.targets.lakka_targets_scraper import PLATFORM_NAME as LAKKA, REPO as LAKKA_REPO
|
||||
|
||||
|
||||
def profile_name_index(profiles: dict[str, dict]) -> dict[str, set[str]]:
|
||||
@@ -133,6 +136,33 @@ def check_targets(
|
||||
return findings
|
||||
|
||||
|
||||
def check_lakka_release(platforms_dir: Path, cache_dir: str, offline: bool) -> Finding:
|
||||
"""The Lakka release platforms/lakka.yml pins against the newest one.
|
||||
|
||||
The target scraper reads the release lakka.yml names, so a rescrape
|
||||
never moves it: only this row says Lakka published a newer one.
|
||||
"""
|
||||
subject = f"{LAKKA} release"
|
||||
try:
|
||||
local = BaseTargetScraper.pinned_version(LAKKA, str(platforms_dir))
|
||||
except (OSError, RuntimeError) as exc:
|
||||
return Finding("targets", subject, ERROR, detail=str(exc))
|
||||
if offline:
|
||||
return Finding("targets", subject, SKIPPED, local=local, detail="offline")
|
||||
repo = upstream.parse_repo(f"https://github.com/{LAKKA_REPO}")
|
||||
try:
|
||||
release = upstream.latest_release(repo, cache_dir) if repo else None
|
||||
except upstream.UpstreamError as exc:
|
||||
return Finding("targets", subject, UNKNOWN, local=local, detail=str(exc))
|
||||
if release is None:
|
||||
return Finding("targets", subject, UNKNOWN, local=local, detail="no release listed")
|
||||
if release.tag == local:
|
||||
return Finding("targets", subject, OK, local=local, remote=release.tag,
|
||||
detail="newest release")
|
||||
return Finding("targets", subject, STALE, local=local, remote=release.tag,
|
||||
detail=f"edit version: in platforms/{LAKKA}.yml, then rescrape the targets")
|
||||
|
||||
|
||||
def _declared_cores(platform: str, platforms_dir: Path) -> list[str]:
|
||||
"""The cores and standalone emulators a platform's own file names."""
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
@@ -12,6 +12,7 @@ from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
|
||||
from model.safeparse import require_yaml
|
||||
from model.sources import source_yaml_file
|
||||
from model.sourcerevision import platform_revision
|
||||
|
||||
# Every target scraper reads the network through the platform scrapers'
|
||||
@@ -47,6 +48,22 @@ class BaseTargetScraper(ABC):
|
||||
)
|
||||
return platform_revision(directory / f"{platform}.yml")
|
||||
|
||||
@staticmethod
|
||||
def pinned_version(platform: str, platforms_dir: str | None = None) -> str:
|
||||
"""The release tag platforms/<platform>.yml names in its own `version:`.
|
||||
|
||||
A platform that inherits its BIOS list (Lakka) has no source of its
|
||||
own to pin: its file names the release by hand, and moving to a new
|
||||
release is an edit of that field.
|
||||
"""
|
||||
directory = Path(platforms_dir) if platforms_dir else (
|
||||
Path(__file__).resolve().parents[3] / "platforms"
|
||||
)
|
||||
version = str((source_yaml_file(directory / f"{platform}.yml") or {}).get("version") or "")
|
||||
if not version:
|
||||
raise RuntimeError(f"platforms/{platform}.yml names no version")
|
||||
return version
|
||||
|
||||
def write_output(self, data: dict, output_path: str) -> None:
|
||||
"""Write target data to YAML file."""
|
||||
from core.artifacts import write_text_atomic
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Scraper for Lakka per-device core availability.
|
||||
|
||||
Sources (libretro/Lakka-LibreELEC, at the latest Lakka release tag):
|
||||
Sources (libretro/Lakka-LibreELEC, at the release platforms/lakka.yml names):
|
||||
- packages/lakka/libretro_cores/package.mk -- LIBRETRO_CORES, then the
|
||||
EXCLUDE_LIBRETRO_CORES each PROJECT/DEVICE and OPENGLES_SUPPORT add
|
||||
- projects/<PROJECT>/options and projects/<PROJECT>/devices/<DEVICE>/options
|
||||
@@ -16,9 +16,8 @@ import re
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
from . import BaseTargetScraper, target_cli
|
||||
from ..base_scraper import fetch_github_latest_version, fetch_text, github_tree
|
||||
from ..base_scraper import fetch_text, github_tree
|
||||
|
||||
PLATFORM_NAME = "lakka"
|
||||
|
||||
@@ -220,7 +219,7 @@ class Scraper(BaseTargetScraper):
|
||||
return found
|
||||
|
||||
def fetch_targets(self) -> dict:
|
||||
self.tag = fetch_github_latest_version(REPO)
|
||||
self.tag = self.pinned_version(PLATFORM_NAME)
|
||||
cores_mk = self._raw(CORES_MK)
|
||||
targets: dict[str, dict] = {}
|
||||
for project, device in self._devices():
|
||||
|
||||
@@ -5215,6 +5215,10 @@ class TargetListsReadThePinnedRelease(unittest.TestCase):
|
||||
)
|
||||
self.assertNotIn("fetch_stable_tag()", source)
|
||||
self.assertNotIn("fetch_github_latest_version(", source)
|
||||
# Lakka inherits its BIOS list and pins the release in its own version:.
|
||||
source = (ROOT / "scripts" / "scraper" / "targets" / "lakka_targets_scraper.py").read_text()
|
||||
self.assertIn("self.pinned_version(PLATFORM_NAME)", source)
|
||||
self.assertNotIn("fetch_github_latest_version(", source)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ from freshness.scrapers import rescrape_command, target_scrapers
|
||||
from freshness.targets import (
|
||||
_declared_cores,
|
||||
_unresolved_findings,
|
||||
check_lakka_release,
|
||||
check_targets,
|
||||
profile_name_index,
|
||||
unresolved_target_cores,
|
||||
@@ -764,6 +765,21 @@ class RepositoryWiringTests(unittest.TestCase):
|
||||
self.assertNotIn("lakka", names)
|
||||
self.assertIn("retropie", names)
|
||||
|
||||
def test_a_newer_lakka_release_is_reported_not_followed(self):
|
||||
"""The target scraper reads the release lakka.yml names, so only
|
||||
this row says Lakka published a newer one."""
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
Path(tmp, "lakka.yml").write_text("inherits: retroarch\nversion: v6.1\n")
|
||||
for tag, status in (("v6.1", OK), ("v6.2", STALE)):
|
||||
release = upstream.Release(tag, "2026-11-01", False)
|
||||
with self.subTest(tag=tag), \
|
||||
mock.patch.object(upstream, "latest_release", return_value=release):
|
||||
row = check_lakka_release(Path(tmp), "", False)
|
||||
self.assertEqual((row.status, row.local, row.remote), (status, "v6.1", tag))
|
||||
self.assertEqual(check_lakka_release(Path(tmp), "", True).status, SKIPPED)
|
||||
Path(tmp, "lakka.yml").write_text("inherits: retroarch\n")
|
||||
self.assertEqual(check_lakka_release(Path(tmp), "", True).status, ERROR)
|
||||
|
||||
def test_render_counts_every_status_once(self):
|
||||
findings = [
|
||||
Finding("ci", "a", OK),
|
||||
|
||||
@@ -9,7 +9,10 @@ from __future__ import annotations
|
||||
|
||||
import tests
|
||||
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
from scripts.scraper.targets import lakka_targets_scraper as lakka
|
||||
|
||||
@@ -95,6 +98,35 @@ class OptionsEvaluation(unittest.TestCase):
|
||||
lakka.evaluate(text, {})
|
||||
|
||||
|
||||
def _files(url: str) -> str:
|
||||
return CORES_MK if url.endswith(lakka.CORES_MK) else ""
|
||||
|
||||
|
||||
class Release(unittest.TestCase):
|
||||
def test_the_release_is_the_one_lakka_yml_names(self):
|
||||
"""platforms/lakka.yml decides the release: a scraper that asked
|
||||
for the latest one moved the cores away from the version it shows."""
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
Path(tmp, "lakka.yml").write_text("inherits: retroarch\nversion: v6.1\n")
|
||||
self.assertEqual(lakka.Scraper.pinned_version("lakka", tmp), "v6.1")
|
||||
Path(tmp, "lakka.yml").write_text("inherits: retroarch\n")
|
||||
with self.assertRaises(RuntimeError):
|
||||
lakka.Scraper.pinned_version("lakka", tmp)
|
||||
|
||||
def test_the_scrape_reads_at_that_release(self):
|
||||
scraper = lakka.Scraper()
|
||||
tree = [
|
||||
{"path": "projects/Generic/options"},
|
||||
{"path": "projects/Generic/devices/Generic/options"},
|
||||
]
|
||||
with mock.patch.object(lakka.Scraper, "pinned_version", return_value="v6.1"), \
|
||||
mock.patch.object(lakka, "fetch_text", side_effect=_files) as fetch, \
|
||||
mock.patch.object(lakka, "github_tree", return_value=tree):
|
||||
data = scraper.fetch_targets()
|
||||
self.assertTrue(all("/v6.1/" in call.args[0] for call in fetch.call_args_list))
|
||||
self.assertIn("/blob/v6.1/", data["source"])
|
||||
|
||||
|
||||
class Architecture(unittest.TestCase):
|
||||
def test_aarch64_where_listed_else_arm(self):
|
||||
self.assertEqual(lakka.device_arch("RPi", "case $TARGET_ARCH in\n aarch64)\n"), "aarch64")
|
||||
|
||||
@@ -742,6 +742,11 @@ newest release, or with its branch head when the project publishes none. A
|
||||
stale pin is moved by hand, then `python -m scripts.scraper.romfolders --setup
|
||||
NAME` reads the folders again.
|
||||
|
||||
The `targets` area also compares the Lakka release `platforms/lakka.yml`
|
||||
names in `version:` with Lakka's newest release. The target scraper reads
|
||||
its core lists at that release and never moves it, so a newer release is
|
||||
`STALE` until the field is edited by hand and the targets are scraped again.
|
||||
|
||||
The `profiles` area always checks `website/src/data/source-paths.json`
|
||||
against the profiles, offline: a recorded tree that no profile pins any more
|
||||
is `STALE` until `sitesources.py --fetch` runs again. It also reads each
|
||||
|
||||
Reference in new issue
Block a user