(report: Path, status: str, summary_key: str, output: Path | None)
| 87 | |
| 88 | |
| 89 | def summarize_asciidoc(report: Path, status: str, summary_key: str, output: Path | None) -> None: |
| 90 | text = "" |
| 91 | if report.is_file(): |
| 92 | text = report.read_text(encoding="utf-8", errors="ignore") |
| 93 | |
| 94 | pattern = re.compile( |
| 95 | r"^\s*(?:[^:\n]+:\d+:\d+:\s+|asciidoctor:\s+)(ERROR|WARN(?:ING)?|INFO)\b", |
| 96 | re.MULTILINE, |
| 97 | ) |
| 98 | matches = pattern.findall(text) |
| 99 | |
| 100 | counts = {"error": 0, "warning": 0, "info": 0} |
| 101 | for severity in matches: |
| 102 | normalized = severity.upper() |
| 103 | if normalized == "ERROR": |
| 104 | counts["error"] += 1 |
| 105 | elif normalized in {"WARN", "WARNING"}: |
| 106 | counts["warning"] += 1 |
| 107 | elif normalized == "INFO": |
| 108 | counts["info"] += 1 |
| 109 | |
| 110 | total = sum(counts.values()) |
| 111 | |
| 112 | if total: |
| 113 | parts = [f"{counts['error']} errors"] if counts["error"] else [] |
| 114 | if counts["warning"]: |
| 115 | parts.append(f"{counts['warning']} warnings") |
| 116 | if counts["info"]: |
| 117 | parts.append(f"{counts['info']} info") |
| 118 | detail = f" ({', '.join(parts)})" if parts else "" |
| 119 | summary = f"{total} issue(s) flagged{detail}" |
| 120 | if _has_nonzero_status(status): |
| 121 | summary += f" (exit code {_normalize_status(status)})" |
| 122 | elif _has_nonzero_status(status): |
| 123 | summary = f"Linter failed (exit code {_normalize_status(status)})" |
| 124 | else: |
| 125 | summary = "No issues found" |
| 126 | |
| 127 | write_outputs([(summary_key, summary)], output) |
| 128 | |
| 129 | |
| 130 | def summarize_vale( |
no test coverage detected