CI: ignore legacy CTA audit mismatches when allowed
This commit is contained in:
@@ -41,6 +41,45 @@ def print_summary(payload: dict) -> tuple[int, int]:
|
||||
return total_block, total_warn
|
||||
|
||||
|
||||
def _cta_issue_is_allowed_now(locale: str, issue: dict) -> bool:
|
||||
if issue.get("issue_type") != "cta_language_mismatch":
|
||||
return False
|
||||
if issue.get("severity") != "block":
|
||||
return False
|
||||
|
||||
try:
|
||||
from mandelblog_content_guard.validators.rules.cta import validate_cta
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
bad_value = issue.get("bad_value") or ""
|
||||
field_paths = issue.get("field_paths") or []
|
||||
if not field_paths:
|
||||
return False
|
||||
|
||||
for field_path in field_paths:
|
||||
if validate_cta(locale, field_path, bad_value):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def effective_block_count(payload: dict) -> tuple[int, int]:
|
||||
"""Return (effective_block, ignored_block) after applying allowlists."""
|
||||
ignored = 0
|
||||
block = 0
|
||||
issues = payload.get("issues") or {}
|
||||
for locale, data in locale_rows(payload):
|
||||
locale_issues = issues.get(locale) or []
|
||||
for issue in locale_issues:
|
||||
if issue.get("severity") != "block":
|
||||
continue
|
||||
if _cta_issue_is_allowed_now(locale, issue):
|
||||
ignored += int(issue.get("count") or 1)
|
||||
continue
|
||||
block += int(issue.get("count") or 1)
|
||||
return block, ignored
|
||||
|
||||
|
||||
def print_regressions(current: dict, previous: dict) -> None:
|
||||
prev_summary = {locale: data for locale, data in locale_rows(previous)}
|
||||
regressions = []
|
||||
@@ -80,6 +119,9 @@ def main() -> int:
|
||||
if error_status:
|
||||
return error_status
|
||||
total_block, total_warn = print_summary(current)
|
||||
effective_block, ignored_block = effective_block_count(current)
|
||||
if ignored_block:
|
||||
print(f"IGNORED: {ignored_block} block issue(s) now allowed by current rules")
|
||||
|
||||
if args.previous_json:
|
||||
prev_path = Path(args.previous_json)
|
||||
@@ -88,7 +130,7 @@ def main() -> int:
|
||||
else:
|
||||
print("REGRESSIONS: previous artifact not found")
|
||||
|
||||
if total_block > 0:
|
||||
if effective_block > 0:
|
||||
return 2
|
||||
if total_warn > 0:
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user