Skip to content

Commit 951a729

Browse files
committed
feat(comment): real health-check warning hook + tighter legend/CTA copy
1 parent f5d3bba commit 951a729

1 file changed

Lines changed: 51 additions & 4 deletions

File tree

β€Žaction.ymlβ€Ž

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,46 @@ runs:
311311
echo "base_analysis=$BASE_DIR/analysis.json" >> $GITHUB_OUTPUT
312312
echo "head_analysis=$HEAD_DIR/analysis.json" >> $GITHUB_OUTPUT
313313
314+
- name: Architecture health check (best-effort)
315+
if: steps.guard.outputs.skip != 'true'
316+
id: health
317+
continue-on-error: true
318+
shell: bash
319+
working-directory: codeboarding-engine
320+
env:
321+
STATIC_ANALYSIS_CONFIG: ${{ github.workspace }}/codeboarding-engine/static_analysis_config.yml
322+
PROJECT_ROOT: ${{ github.workspace }}/codeboarding-engine
323+
run: |
324+
HEAD_DIR="${{ steps.base.outputs.head_dir }}"
325+
TARGET="${{ github.workspace }}/target-repo"
326+
# Count real WARNING/CRITICAL findings from the head analysis. Never fails
327+
# the run β€” a missing/old health module just yields 0 issues (no banner).
328+
uv run python -c "
329+
import json
330+
from pathlib import Path
331+
issues = 0
332+
try:
333+
from static_analyzer.analysis_cache import StaticAnalysisCache
334+
from health.runner import run_health_checks
335+
from health.models import Severity
336+
cache = StaticAnalysisCache(artifact_dir=Path('$HEAD_DIR'), repo_root=Path('$TARGET'))
337+
sa = cache.get()
338+
if sa is not None:
339+
report = run_health_checks(sa, repo_name='${{ github.event.repository.name }}', repo_path=Path('$TARGET'))
340+
if report is not None:
341+
for cs in report.check_summaries:
342+
for fg in getattr(cs, 'finding_groups', []):
343+
if getattr(fg, 'severity', None) in (Severity.WARNING, Severity.CRITICAL):
344+
issues += len(fg.entities)
345+
print(f'Architecture issues found: {issues}')
346+
except Exception as exc:
347+
print(f'Health check skipped ({exc}).')
348+
Path('/tmp/cb-issues.txt').write_text(str(issues))
349+
"
350+
N=$(cat /tmp/cb-issues.txt 2>/dev/null || echo 0)
351+
echo "issues=$N" >> $GITHUB_OUTPUT
352+
echo "Architecture issues: $N"
353+
314354
- name: Diff analyses β†’ Mermaid
315355
if: steps.guard.outputs.skip != 'true'
316356
id: diagram
@@ -348,6 +388,7 @@ runs:
348388
OWNER="${OWNER_REPO%%/*}"; REPO="${OWNER_REPO##*/}"
349389
PR="${{ steps.guard.outputs.pr_number }}"
350390
CTA_BASE="${{ inputs.cta_base_url }}"
391+
ISSUES="${{ steps.health.outputs.issues }}"
351392
352393
headline() {
353394
if [ "$1" = "0" ]; then echo "no architectural changes";
@@ -356,16 +397,22 @@ runs:
356397
}
357398
358399
# Call-to-action: links open the live workspace (github.dev-equivalent) and
359-
# the extension via the click proxy, with owner/repo/pr appended for tracking.
400+
# the VS Code extension via the click proxy, with owner/repo/pr for tracking.
401+
# The warning banner is shown only when real health findings exist.
360402
cta() {
361403
[ -z "$CTA_BASE" ] && return
362404
local ws="${CTA_BASE}/use-workspace?owner=${OWNER}&repo=${REPO}&pr=${PR}"
363405
local mp="${CTA_BASE}/use-marketplace?owner=${OWNER}&repo=${REPO}&pr=${PR}"
364406
echo ""
365407
echo "---"
366-
echo "πŸ” **This is the flattened map.** [**Explore this diff live in your browser β†’**](${ws}) β€” expand every component, follow each dependency, and click straight through to the changed code. Opens in your browser, no install."
408+
if [ -n "$ISSUES" ] && [ "$ISSUES" != "0" ]; then
409+
local noun="issue"; [ "$ISSUES" != "1" ] && noun="issues"
410+
echo "⚠️ **${ISSUES} architecture ${noun} found.** [**See live in your browser β†’**](${ws})"
411+
echo ""
412+
fi
413+
echo "πŸ” This is the flattened map. [**Explore this diff live in your browser β†’**](${ws})"
367414
echo ""
368-
echo "πŸ’‘ Prefer your editor? [**Get the CodeBoarding VS Code extension β†’**](${mp}) to explore these architecture diffs right inside VS Code."
415+
echo "πŸ’‘ Prefer your editor? [**Get the CodeBoarding VS Code extension β†’**](${mp})"
369416
}
370417
371418
{
@@ -377,7 +424,7 @@ runs:
377424
cat "${{ steps.diagram.outputs.diagram_md }}"
378425
echo ""
379426
echo ""
380-
echo "Components are tinted by the files that changed inside them β€” 🟩 added Β· 🟨 modified Β· πŸŸ₯ removed β€” versus \`${BASE_REF}\` (not whole subsystems being added or dropped)."
427+
echo "Colours indicate components that have been 🟩 added Β· 🟨 modified Β· πŸŸ₯ removed β€” versus \`${BASE_REF}\`."
381428
if [ "$TRUNC" = "true" ]; then
382429
echo ""
383430
echo "<sub>Showing changed components only β€” the full graph exceeds GitHub's inline Mermaid limit.</sub>"

0 commit comments

Comments
Β (0)