mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 14:28:54 -06:00
fix: check the tag core_version names, per build
version_basis now answers which tag core_version names for each build mode and repository: the basis tag for a tag basis, core_version otherwise. check_version, the run report and the triage read that answer instead of the raw core_version string, so a describe-form version (armsx2 2.9.2-77-gfc4ab0b) and a mode-keyed one (jgenesis, rpcs3, xemu) can raise the newer and passed release warnings again. A pin at the distance core_version states is not warned about, and a version page is held against the build it announces.
This commit is contained in:
1 parent
14dc75c6fb
commit
2559dfba79
7 files changed
+233
-61
No files matched your search
+47
-26
@@ -26,11 +26,13 @@ from profiling.reports import (
|
||||
from profiling.resolver import build_report
|
||||
from profiling.sourcepaths import record_write
|
||||
from profiling.triage import PROGRESS_SECONDS, Progress, print_interrupted, print_triage
|
||||
from profiling.version_basis import version_repo
|
||||
from profiling.version_basis import VersionTag, version_tags
|
||||
from profiling.versions import (
|
||||
newer_release,
|
||||
latest_passed_release,
|
||||
VersionReport,
|
||||
check_version,
|
||||
latest_passed_release,
|
||||
newer_release,
|
||||
page_declared,
|
||||
page_version,
|
||||
version_warning,
|
||||
)
|
||||
@@ -277,32 +279,21 @@ def _version_pin(report: ProfileReport, repo: upstream.Repo, field: str) -> str
|
||||
return None
|
||||
|
||||
|
||||
def _attach_version(
|
||||
args: argparse.Namespace, profile: dict, report: ProfileReport
|
||||
) -> None:
|
||||
"""Record core_version against the forge's latest tag and release.
|
||||
|
||||
Kept on the report rather than printed, so --json carries it as the text
|
||||
report does. A forge that refuses is named on the profile's own line
|
||||
(version_unread).
|
||||
"""
|
||||
repo, field = version_repo(profile) if report.head else (None, "")
|
||||
def _version_of(
|
||||
args: argparse.Namespace, profile: dict, report: ProfileReport, named: VersionTag,
|
||||
) -> tuple[VersionReport | None, str | None]:
|
||||
"""One build's core_version against its repository: the report and the
|
||||
warning. A refused tag ancestry is named on version_unread."""
|
||||
repo = named.repo
|
||||
if repo is None:
|
||||
return
|
||||
pin = _version_pin(report, repo, field)
|
||||
return None, None
|
||||
pin = _version_pin(report, repo, named.field)
|
||||
# A held upstream (yaps2 synced to PCSX2 342db515) is not one a newer
|
||||
# release of that project asks to profile again, as a held pin is not.
|
||||
frozen_by = "upstream_frozen" if field == "upstream" else "pin_frozen"
|
||||
try:
|
||||
report.version = check_version(profile, repo, args.cache_dir, args.offline)
|
||||
except upstream.RateLimitError:
|
||||
raise
|
||||
except upstream.UpstreamError as exc:
|
||||
report.version_unread = f"version check skipped: {exc}"
|
||||
return
|
||||
frozen_by = "upstream_frozen" if named.field == "upstream" else "pin_frozen"
|
||||
version = check_version(named, args.cache_dir, args.offline)
|
||||
relation = None
|
||||
passed = None
|
||||
version = report.version
|
||||
try:
|
||||
if version and version.tag_commit and pin and version.tag_commit != pin:
|
||||
relation = upstream.ancestry(
|
||||
@@ -317,11 +308,41 @@ def _attach_version(
|
||||
except upstream.UpstreamError as exc:
|
||||
report.version_unread = f"tag ancestry unread: {exc}"
|
||||
newer = None
|
||||
report.version_warning = version_warning(version, pin, relation, passed) or (
|
||||
warning = version_warning(version, pin, relation, passed) or (
|
||||
f"{'release' if version.latest_release else 'tag'} {newer} is newer than core_version {version.declared} and the pin: "
|
||||
f"profile it, or hold the pin with {frozen_by} and the reason"
|
||||
if newer and version else None
|
||||
)
|
||||
return version, warning
|
||||
|
||||
|
||||
def _attach_version(
|
||||
args: argparse.Namespace, profile: dict, report: ProfileReport
|
||||
) -> None:
|
||||
"""Record core_version against the forge's latest tag and release.
|
||||
|
||||
Kept on the report rather than printed, so --json carries it as the text
|
||||
report does. A forge that refuses is named on the profile's own line
|
||||
(version_unread). Each build's tag is read in its own repository, and a
|
||||
warning names its build when the builds name different tags.
|
||||
"""
|
||||
if not report.head:
|
||||
return
|
||||
named_tags = [named for named in version_tags(profile) if named.repo is not None]
|
||||
warnings: list[str] = []
|
||||
for named in named_tags:
|
||||
try:
|
||||
version, warning = _version_of(args, profile, report, named)
|
||||
except upstream.RateLimitError:
|
||||
raise
|
||||
except upstream.UpstreamError as exc:
|
||||
report.version_unread = f"version check skipped: {exc}"
|
||||
return
|
||||
if report.version is None:
|
||||
report.version = version
|
||||
if warning:
|
||||
warnings.append(f"{named.mode}: {warning}" if len(named_tags) > 1 else warning)
|
||||
report.version_warning = "; ".join(warnings) or None
|
||||
|
||||
|
||||
def read_one_profile(
|
||||
@@ -444,10 +465,10 @@ def _build_full_report(
|
||||
if not report.skipped and profile_path.is_file():
|
||||
report.stale_prose = _read_stale_prose(name, profile_path, args, failed)
|
||||
if args.check_version and profile.get("version_source"):
|
||||
report.declared_version = str(profile.get("core_version") or "") or None
|
||||
report.page_version, report.page_version_unread = page_version(
|
||||
profile, args.cache_dir, args.offline
|
||||
)
|
||||
report.declared_version = page_declared(profile, report.page_version)
|
||||
report.no_genuine_copy = str(
|
||||
profile["version_source"].get("no_genuine_copy") or "") or None
|
||||
if args.check_version:
|
||||
|
||||
+14
-10
@@ -5,10 +5,11 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import sys
|
||||
import time
|
||||
from collections.abc import Sequence
|
||||
|
||||
from core import upstream
|
||||
from profiling.reports import ProfileReport, triage_state
|
||||
from profiling.version_basis import version_repo
|
||||
from profiling.version_basis import version_repo, version_tags
|
||||
from profiling.versions import VersionReport, check_version
|
||||
|
||||
|
||||
@@ -23,7 +24,7 @@ PIN_WEIGHT = 50
|
||||
|
||||
|
||||
def drift_score(
|
||||
report: ProfileReport, version: VersionReport | None, commits: int
|
||||
report: ProfileReport, versions: Sequence[VersionReport], commits: int
|
||||
) -> int:
|
||||
"""Rank profiles by how far they have drifted from their pin."""
|
||||
counts = report.counts or {}
|
||||
@@ -34,9 +35,10 @@ def drift_score(
|
||||
DRIFT_WEIGHTS["SHIFTED" if line.startswith("would recale") else "AMBIGUOUS"]
|
||||
for line in report.stale_prose or ()
|
||||
)
|
||||
if (
|
||||
version is not None and not version.tag_matches_declared
|
||||
and version.latest_release and version.latest_release != version.declared
|
||||
if any(
|
||||
not version.tag_matches_declared
|
||||
and version.latest_release and version.latest_release != version.named
|
||||
for version in versions
|
||||
):
|
||||
score += 10
|
||||
# A pin off its branch or a repository answering under another name is
|
||||
@@ -110,17 +112,19 @@ def _score(
|
||||
"""Append one profile's drift score to ``ranked``. True when its commit
|
||||
count was read on a sample of the paths it cites."""
|
||||
profile = selected[report.name]
|
||||
version = None
|
||||
versions: list[VersionReport] = []
|
||||
commits = 0
|
||||
refused = ""
|
||||
sampled = False
|
||||
repo = version_repo(profile)[0]
|
||||
if report.head and repo is not None:
|
||||
if report.head and version_repo(profile)[0] is not None:
|
||||
# Each cited path counted in the repository the resolver settled it
|
||||
# in, between that repository's own pin and HEAD.
|
||||
sources = report.cited_sources
|
||||
try:
|
||||
version = check_version(profile, repo, args.cache_dir, args.offline)
|
||||
for named in version_tags(profile):
|
||||
version = check_version(named, args.cache_dir, args.offline)
|
||||
if version is not None:
|
||||
versions.append(version)
|
||||
for source in sources[:TRIAGE_PATH_SAMPLE]:
|
||||
commits += upstream.commits_touching(
|
||||
source.repo, source.path, source.pin, args.cache_dir, args.offline,
|
||||
@@ -132,5 +136,5 @@ def _score(
|
||||
refused = "commit history unreachable"
|
||||
print(f"{report.name}: {exc}", file=sys.stderr)
|
||||
sampled = len(sources) > TRIAGE_PATH_SAMPLE and not refused
|
||||
ranked.append((drift_score(report, version, commits), report, refused))
|
||||
ranked.append((drift_score(report, versions, commits), report, refused))
|
||||
return sampled
|
||||
@@ -111,6 +111,48 @@ def version_repo(
|
||||
return upstream.parse_repo(_by_mode(profile, field, mode) or ""), field
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class VersionTag:
|
||||
"""The tag core_version names for one build mode, and where it lives."""
|
||||
|
||||
mode: str
|
||||
declared: str
|
||||
tag: str
|
||||
distance: int
|
||||
repo: upstream.Repo | None
|
||||
field: str
|
||||
|
||||
|
||||
def version_tags(profile: dict) -> list[VersionTag]:
|
||||
"""Which tag core_version names, for each build mode and repository.
|
||||
|
||||
A tag basis holds the tag apart from core_version, which writes git
|
||||
describe's long form past it (armsx2 2.9.2-77-gfc4ab0b names tag 2.9.2).
|
||||
Any other basis names the tag by core_version itself. Builds naming the
|
||||
same tag in the same repository are one answer.
|
||||
"""
|
||||
found = bases(profile)
|
||||
value = profile.get("core_version")
|
||||
modes = list(found) or ([str(mode) for mode in value] if isinstance(value, dict) else [""])
|
||||
answers: list[VersionTag] = []
|
||||
seen: set[tuple] = set()
|
||||
for mode in modes:
|
||||
stated = declared(profile, mode)
|
||||
if not stated:
|
||||
continue
|
||||
basis = found.get(mode)
|
||||
tag, distance = stated, 0
|
||||
if basis and basis.get("kind") == "tag" and basis.get("tag"):
|
||||
tag, distance = str(basis["tag"]), int(basis.get("distance") or 0)
|
||||
repo, field = version_repo(profile, mode, basis)
|
||||
key = (repo.host, repo.slug) if repo else None, field, stated, tag
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
answers.append(VersionTag(mode, stated, tag, distance, repo, field))
|
||||
return answers
|
||||
|
||||
|
||||
def is_placeholder(value: object) -> bool:
|
||||
"""A VCS or branch word standing for a version, alone or annotated
|
||||
("SVN (2015 snapshot)"). The schema refuses the same strings."""
|
||||
|
||||
@@ -6,6 +6,7 @@ import re
|
||||
from dataclasses import dataclass
|
||||
|
||||
from core import upstream
|
||||
from profiling.version_basis import VersionTag, declared
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -16,26 +17,37 @@ class VersionReport:
|
||||
release_date: str | None
|
||||
tag_matches_declared: bool
|
||||
tag_commit: str | None
|
||||
# The tag core_version names and the commits the pin sits past it: a tag
|
||||
# basis writes 2.9.2-77-gfc4ab0b for tag 2.9.2 at distance 77.
|
||||
tag: str = ""
|
||||
distance: int = 0
|
||||
|
||||
@property
|
||||
def named(self) -> str:
|
||||
"""The tag name core_version stands for."""
|
||||
return self.tag or self.declared
|
||||
|
||||
|
||||
def check_version(
|
||||
profile: dict, repo: upstream.Repo, cache_dir: str, offline: bool
|
||||
named: VersionTag, cache_dir: str, offline: bool
|
||||
) -> VersionReport | None:
|
||||
"""Declared core_version against the latest upstream tag and release."""
|
||||
declared = str(profile.get("core_version") or "")
|
||||
if not declared:
|
||||
repo = named.repo
|
||||
if repo is None or not named.declared:
|
||||
return None
|
||||
release = upstream.latest_release(repo, cache_dir, offline)
|
||||
# Asked by name: the first page of tags misses a release that a project
|
||||
# publishing nightlies has pushed past a hundred newer tags.
|
||||
commit = upstream.tag_commit(repo, declared, cache_dir, offline)
|
||||
commit = upstream.tag_commit(repo, named.tag, cache_dir, offline)
|
||||
return VersionReport(
|
||||
declared,
|
||||
named.declared,
|
||||
upstream.newest_tag(repo, cache_dir, offline),
|
||||
release.tag if release else None,
|
||||
release.date if release else None,
|
||||
commit is not None,
|
||||
commit,
|
||||
named.tag,
|
||||
named.distance,
|
||||
)
|
||||
|
||||
|
||||
@@ -66,6 +78,21 @@ def page_version(
|
||||
return (match.group(1), None) if match else (None, "pattern not found")
|
||||
|
||||
|
||||
def page_declared(profile: dict, announced: str | None) -> str | None:
|
||||
"""The core_version a version_source page is held against.
|
||||
|
||||
A core_version keyed by build mode states one version per build, and the
|
||||
page announces one of them (eduke32's synthesis page, its standalone).
|
||||
The build the page names is the one compared, else the first declared.
|
||||
"""
|
||||
value = profile.get("core_version")
|
||||
modes = [str(mode) for mode in value] if isinstance(value, dict) else [""]
|
||||
stated = [version for mode in modes if (version := declared(profile, mode))]
|
||||
if announced in stated:
|
||||
return announced
|
||||
return stated[0] if stated else None
|
||||
|
||||
|
||||
def version_warning(
|
||||
report: VersionReport | None,
|
||||
pin: str | None,
|
||||
@@ -91,6 +118,9 @@ def version_warning(
|
||||
)
|
||||
if not report.tag_commit or report.tag_commit == pin:
|
||||
return None
|
||||
if report.distance and relation == (report.distance, 0):
|
||||
# The distance core_version states: the build it says it is.
|
||||
return None
|
||||
where = ""
|
||||
if relation is not None:
|
||||
ahead, behind = relation
|
||||
@@ -171,7 +201,7 @@ def newer_release(
|
||||
published = published_version(version)
|
||||
if not version or not pin or not version.tag_commit or not published:
|
||||
return None
|
||||
if published == version.declared:
|
||||
if published == version.named:
|
||||
return None
|
||||
commit = upstream.tag_commit(repo, published, cache_dir, offline)
|
||||
if not commit or commit == pin:
|
||||
@@ -202,9 +232,9 @@ def latest_passed_release(
|
||||
published = published_version(version)
|
||||
if not version or not pin or not published:
|
||||
return None
|
||||
if published == version.declared:
|
||||
if published == version.named:
|
||||
return None
|
||||
if not version.tag_commit and not _later_number(published, version.declared):
|
||||
if not version.tag_commit and not _later_number(published, version.named):
|
||||
# No tag to order them: only a release numbered past the declared
|
||||
# version says it is older. "latest", "continuous" or 1.53 under a
|
||||
# declared 1.61 say nothing.
|
||||
|
||||
Reference in new issue
Block a user