mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -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:
|
||||
|
||||
@@ -22,6 +22,7 @@ from profiling import quota, selection
|
||||
from profiling.bump import DEFAULT_CACHE
|
||||
from profiling.flagchecks import refuse_flag_combinations
|
||||
from profiling.realignpass import run_realign
|
||||
from profiling.reports import STRICT_KINDS
|
||||
from profiling.run import emit_reports, read_selected
|
||||
from profiling.sourcepaths import refresh_source_paths
|
||||
from profiling.versioncheck import run_versions
|
||||
@@ -217,9 +218,7 @@ def main() -> None:
|
||||
refresh_source_paths(args, written)
|
||||
if not complete:
|
||||
raise SystemExit(130)
|
||||
if failed or (args.strict and any(
|
||||
report.needs_review() or report.uncheckable() for report in reports
|
||||
)):
|
||||
if failed or (args.strict and any(report.fails(STRICT_KINDS) for report in reports)):
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
|
||||
@@ -38,6 +38,26 @@ class CitedSource:
|
||||
return self.pin != self.head and not self.own_revision
|
||||
|
||||
|
||||
# The reasons profile_sync --strict fails on: a ref or pin to look at again,
|
||||
# and a profile that cannot be checked as written.
|
||||
STRICT_KINDS = frozenset({"review", "uncheckable"})
|
||||
|
||||
# Levels of an attention reason: the profile is behind its upstream, it
|
||||
# could not be read in full, or a remark that asks nothing.
|
||||
STALE_LEVEL = "stale"
|
||||
UNKNOWN_LEVEL = "unknown"
|
||||
NOTE_LEVEL = "note"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Attention:
|
||||
"""One reason to look at a profile again, with its level."""
|
||||
|
||||
kind: str
|
||||
level: str
|
||||
detail: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ProfileReport:
|
||||
name: str
|
||||
@@ -140,6 +160,74 @@ class ProfileReport:
|
||||
+ sum(1 for ref in self.build_refs if ref["status"] != "BUILD_OK")
|
||||
)
|
||||
|
||||
def attention(self) -> list[Attention]:
|
||||
"""Every reason the pass gives to look at this profile again.
|
||||
|
||||
The one verdict its consumers read: check_freshness maps the levels
|
||||
to its statuses, and --strict picks the kinds that fail a run. A
|
||||
profile skipped for want of a source_ref still has its revisions
|
||||
read, so an orphaned pin or a version warning stands beside the skip.
|
||||
"""
|
||||
reasons = self._skip_attention() if self.skipped else []
|
||||
review = self.needs_review()
|
||||
if review:
|
||||
reasons.append(Attention("review", STALE_LEVEL, f"{review} refs to review"))
|
||||
added = sorted({
|
||||
str(item.get("name")) for item in self.new_files or () if item.get("since_pin")
|
||||
})
|
||||
if added:
|
||||
reasons.append(Attention(
|
||||
"new_files", STALE_LEVEL, f"new file names since the pin: {', '.join(added)}"
|
||||
))
|
||||
if self.new_hashes:
|
||||
reasons.append(Attention(
|
||||
"new_hashes", STALE_LEVEL,
|
||||
f"{len(self.new_hashes)} undeclared hashes added since the pin",
|
||||
))
|
||||
if self.version_warning:
|
||||
reasons.append(Attention("version", STALE_LEVEL, self.version_warning))
|
||||
if self.version_unread:
|
||||
reasons.append(Attention("version_unread", UNKNOWN_LEVEL, self.version_unread))
|
||||
if self.detection_skipped:
|
||||
reasons.append(Attention(
|
||||
"detection_skipped", UNKNOWN_LEVEL,
|
||||
f"new file and hash detection unread: {self.detection_skipped}",
|
||||
))
|
||||
return reasons
|
||||
|
||||
def _skip_attention(self) -> list[Attention]:
|
||||
"""A skipped profile: a skip that is a defect, then its release page."""
|
||||
reasons = []
|
||||
if self.uncheckable():
|
||||
reasons.append(Attention("uncheckable", UNKNOWN_LEVEL, self.skipped or ""))
|
||||
if self.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.
|
||||
if self.page_version == (self.declared_version or ""):
|
||||
return reasons
|
||||
if self.page_version == self.no_genuine_copy:
|
||||
# Searched for and found only rebuilt: the profile covers the
|
||||
# newest build that can be read, until the page moves on.
|
||||
reasons.append(Attention(
|
||||
"no_genuine_copy", NOTE_LEVEL, "no genuine copy of the announced release"
|
||||
))
|
||||
return reasons
|
||||
reasons.append(
|
||||
Attention("page_version", STALE_LEVEL, "a newer release is announced")
|
||||
)
|
||||
elif self.page_version_unread:
|
||||
# The page is the only feed: unread, a new release cannot be told
|
||||
# from none.
|
||||
reasons.append(Attention(
|
||||
"page_version_unread", UNKNOWN_LEVEL,
|
||||
f"version page unread: {self.page_version_unread}",
|
||||
))
|
||||
return reasons
|
||||
|
||||
def fails(self, kinds: frozenset[str]) -> bool:
|
||||
"""Whether a reason of one of ``kinds`` stands on this profile."""
|
||||
return any(reason.kind in kinds for reason in self.attention())
|
||||
|
||||
|
||||
def triage_state(report: ProfileReport) -> str:
|
||||
"""One triage line: what to review, the pin to set again named first.
|
||||
@@ -322,6 +410,7 @@ def report_to_dict(report: ProfileReport) -> dict:
|
||||
payload = asdict(report)
|
||||
del payload["cited_sources"]
|
||||
payload["needs_review"] = report.needs_review()
|
||||
payload["attention"] = [asdict(reason) for reason in report.attention()]
|
||||
return payload
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user