Skip to content

Commit 226a640

Browse files
committed
ci: summarize stable validation logs
1 parent 58ad451 commit 226a640

1 file changed

Lines changed: 70 additions & 7 deletions

File tree

.github/workflows/techapi-pr-validation-comment.yml

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,75 @@ jobs:
310310
result="FAIL"
311311
fi
312312
313+
VALIDATION_STATUS="${{ steps.validate.outputs.status }}" python - <<'PY'
314+
from __future__ import annotations
315+
316+
import os
317+
from pathlib import Path
318+
319+
log_path = Path("validation.log")
320+
log = log_path.read_text(encoding="utf-8", errors="replace")
321+
lines = log.splitlines()
322+
failed = os.environ.get("VALIDATION_STATUS") != "success"
323+
324+
section_counts: dict[str, int] = {}
325+
current_section: str | None = None
326+
key_lines: list[str] = []
327+
hard_lines: list[str] = []
328+
329+
for line in lines:
330+
if line.startswith("## ") or line.startswith("loaded ") or "integrity gate:" in line:
331+
key_lines.append(line)
332+
if line.startswith("### "):
333+
current_section = line.removeprefix("### ").strip()
334+
section_counts[current_section] = 0
335+
continue
336+
if current_section and line.startswith(" "):
337+
section_counts[current_section] += 1
338+
if any(token in line for token in ("DUP ", "slug!=file", " > ")):
339+
hard_lines.append(line)
340+
341+
out: list[str] = []
342+
out.append("## Validation notes")
343+
out.append("")
344+
out.append("- Full advisory outlier listings are suppressed on successful runs because they are dataset-wide and mostly stable between PRs.")
345+
out.append("- Failure runs still include a detailed log excerpt for debugging.")
346+
if key_lines:
347+
out.append("")
348+
out.append("Key output:")
349+
out.append("")
350+
out.append("```text")
351+
out.extend(key_lines)
352+
out.append("```")
353+
if section_counts:
354+
out.append("")
355+
out.append("| Integrity section | Flagged lines |")
356+
out.append("| --- | ---: |")
357+
for name, count in section_counts.items():
358+
out.append(f"| {name} | {count} |")
359+
if hard_lines:
360+
out.append("")
361+
out.append("Potential blocking lines:")
362+
out.append("")
363+
out.append("```text")
364+
out.extend(hard_lines[:80])
365+
if len(hard_lines) > 80:
366+
out.append(f"... {len(hard_lines) - 80} more")
367+
out.append("```")
368+
if failed:
369+
out.append("")
370+
out.append("<details><summary>Detailed validation log excerpt</summary>")
371+
out.append("")
372+
out.append("```text")
373+
excerpt = log[-12000:] if len(log) > 12000 else log
374+
out.append(excerpt.rstrip())
375+
out.append("```")
376+
out.append("")
377+
out.append("</details>")
378+
379+
Path("validation-notes.md").write_text("\n".join(out) + "\n", encoding="utf-8")
380+
PY
381+
313382
{
314383
echo "<!-- techengine-pr-validation -->"
315384
echo "## TechEngine validation: ${result}"
@@ -327,13 +396,7 @@ jobs:
327396
echo
328397
cat quality-summary.md
329398
echo
330-
echo "<details><summary>Validation log</summary>"
331-
echo
332-
echo '```text'
333-
tail -c 6000 validation.log
334-
echo '```'
335-
echo
336-
echo "</details>"
399+
cat validation-notes.md
337400
} > comment.md
338401
339402
- name: Comment on TechAPI PR

0 commit comments

Comments
 (0)