mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-28 12:28:51 -06:00
fix: one attention verdict on the profile report
check_freshness rebuilt the profile_sync verdict from single JSON keys and dropped version_warning, version_unread and detection_skipped: a core_version behind its pin and a refused detection both read OK. ProfileReport.attention() now gives every reason with its level, report_to_dict serializes it, freshness maps the levels, and --strict names the kinds it fails on.
This commit is contained in:
1 parent
e146a8f349
commit
5cce11e7d0
5 files changed
+238
-90
No files matched your search
@@ -80,15 +80,56 @@ def check_profiles(run: bool, offline: bool) -> list[Finding]:
|
||||
return summarize_profile_sync(report)
|
||||
|
||||
|
||||
_LEVELS = {"stale": STALE, "unknown": UNKNOWN}
|
||||
|
||||
|
||||
def _verdict(row: dict) -> tuple[str | None, list[str]]:
|
||||
"""The status profile_sync's attention reasons give a row, and their details.
|
||||
|
||||
The reasons are decided once, on the report: a stale one makes the row
|
||||
stale, an unreadable one unknown, and a note says something without
|
||||
asking anything.
|
||||
"""
|
||||
reasons = [r for r in row.get("attention") or () if isinstance(r, dict)]
|
||||
levels = {_LEVELS.get(str(r.get("level"))) for r in reasons}
|
||||
status = STALE if STALE in levels else UNKNOWN if UNKNOWN in levels else None
|
||||
asking = [str(r.get("detail") or "") for r in reasons if str(r.get("level")) in _LEVELS]
|
||||
notes = [str(r.get("detail") or "") for r in reasons if str(r.get("level")) not in _LEVELS]
|
||||
return status, asking or notes
|
||||
|
||||
|
||||
def _skipped_finding(name: str, row: dict) -> Finding:
|
||||
"""A profile profile_sync could not compare: its release page, or the skip.
|
||||
|
||||
A skip profile_sync counts as a defect (no repository answers, no
|
||||
resolvable pin) is unknown. One that is the profile's nature (an upstream
|
||||
declared gone, a host no forge API serves, no source_ref) is never
|
||||
checkable and does not hold the exit code.
|
||||
"""
|
||||
status, details = _verdict(row)
|
||||
reason = str(row["skipped"])
|
||||
declared = str(row.get("declared_version") or "")
|
||||
if row.get("page_version"):
|
||||
return Finding("profiles", name, status or OK, local=declared,
|
||||
remote=str(row["page_version"]), detail=", ".join(details))
|
||||
if row.get("page_version_unread"):
|
||||
return Finding("profiles", name, status or UNKNOWN, local=declared,
|
||||
detail=", ".join(details))
|
||||
if status is None:
|
||||
return Finding("profiles", name, SKIPPED, detail=reason)
|
||||
if reason not in details:
|
||||
details.insert(0, reason)
|
||||
return Finding("profiles", name, status, detail=", ".join(details))
|
||||
|
||||
|
||||
def summarize_profile_sync(report: object) -> list[Finding]:
|
||||
"""One row per profile with something to look at, from profile_sync's JSON.
|
||||
|
||||
The JSON carries the ref verdicts and the pin against the tip. A profile
|
||||
whose refs need review is stale, one the forge could not serve is unknown,
|
||||
and one whose upstream moved while every ref still anchors is reported as
|
||||
such without being counted as stale. A cited file that gained a file name
|
||||
since the pin, or a hash the profile does not declare, is stale too: the
|
||||
upstream may load a file the profile does not document.
|
||||
Each row carries the report's attention reasons: refs to review, a
|
||||
version behind its code, a file name or hash the cited code gained since
|
||||
the pin, a check the forge refused. A stale reason makes the profile
|
||||
stale, an unreadable one unknown, and one whose upstream moved while
|
||||
nothing asks for attention is counted as such without being stale.
|
||||
"""
|
||||
if not isinstance(report, list):
|
||||
return [Finding("profiles", "profile_sync", ERROR, detail="report is not a list")]
|
||||
@@ -98,61 +139,20 @@ def summarize_profile_sync(report: object) -> list[Finding]:
|
||||
if not isinstance(row, dict):
|
||||
continue
|
||||
name = str(row.get("name") or "?")
|
||||
if row.get("skipped") and row.get("page_version"):
|
||||
# Off any forge, the release page is the feed: a version there
|
||||
# beyond the declared one is a release the profile does not cover.
|
||||
declared, announced = str(row.get("declared_version") or ""), str(row["page_version"])
|
||||
if announced == declared:
|
||||
status, detail = OK, ""
|
||||
elif announced == str(row.get("no_genuine_copy") or ""):
|
||||
# Searched for and found only rebuilt: the profile covers the
|
||||
# newest build that can be read, until the page moves on.
|
||||
status, detail = OK, "no genuine copy of the announced release"
|
||||
else:
|
||||
status, detail = STALE, "a newer release is announced"
|
||||
findings.append(Finding("profiles", name, status, local=declared,
|
||||
remote=announced, detail=detail))
|
||||
continue
|
||||
if row.get("skipped") and row.get("page_version_unread"):
|
||||
# The release page is the only feed this profile has: unread, a
|
||||
# new release cannot be told from none, so the row is unknown.
|
||||
findings.append(Finding("profiles", name, UNKNOWN,
|
||||
local=str(row.get("declared_version") or ""),
|
||||
detail=f"version page unread: {row['page_version_unread']}"))
|
||||
continue
|
||||
if row.get("skipped"):
|
||||
# A skip profile_sync counts as a defect (no repository answers,
|
||||
# no resolvable pin) is unknown. One that is the profile's nature
|
||||
# (an upstream declared gone, a host no forge API serves, no
|
||||
# source_ref) is never checkable and does not hold the exit code.
|
||||
from profiling.reports import ProfileReport
|
||||
|
||||
reason = str(row["skipped"])
|
||||
status = UNKNOWN if reason.startswith(ProfileReport.UNCHECKABLE) else SKIPPED
|
||||
findings.append(Finding("profiles", name, status, detail=reason))
|
||||
findings.append(_skipped_finding(name, row))
|
||||
continue
|
||||
review = row.get("needs_review") or 0
|
||||
pin, head = str(row.get("pin") or ""), str(row.get("head") or "")
|
||||
added = sorted({
|
||||
str(item.get("name"))
|
||||
for item in row.get("new_files") or ()
|
||||
if isinstance(item, dict) and item.get("since_pin")
|
||||
})
|
||||
hashes = len(row.get("new_hashes") or ())
|
||||
reasons = [f"{review} refs to review"] if review else []
|
||||
if added:
|
||||
reasons.append(f"new file names since the pin: {', '.join(added)}")
|
||||
if hashes:
|
||||
reasons.append(f"{hashes} undeclared hashes added since the pin")
|
||||
if reasons:
|
||||
status, details = _verdict(row)
|
||||
if status is not None:
|
||||
findings.append(
|
||||
Finding(
|
||||
"profiles",
|
||||
name,
|
||||
STALE,
|
||||
status,
|
||||
local=pin[:8],
|
||||
remote=head[:8],
|
||||
detail=", ".join(reasons),
|
||||
detail=", ".join(details),
|
||||
)
|
||||
)
|
||||
elif pin and head and pin != head:
|
||||
|
||||
Reference in new issue
Block a user