From 54f240786aacef56457e6a1bdcd54159dc6ba578 Mon Sep 17 00:00:00 2001 From: Lucas Machado Date: Sun, 8 Mar 2026 17:42:12 +0100 Subject: [PATCH] improve PR comment to be more professional and informative MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Show config file path and pass/total ratio for context - Each violation category gets its own collapsible section - Show "…and N more" when examples are truncated - Clean success message without unnecessary table - Subtle footer with link to full run and StructLint repo Co-Authored-By: Claude Opus 4.6 --- action.yml | 68 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/action.yml b/action.yml index d7e3e1a..5822310 100644 --- a/action.yml +++ b/action.yml @@ -92,6 +92,9 @@ runs: - name: Generate Summary if: always() shell: bash + env: + CONFIG_PATH: ${{ inputs.config }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | REPORT="/tmp/structlint-report.json" if [ ! -f "$REPORT" ]; then @@ -101,40 +104,47 @@ runs: SUCCESSES=$(jq -r '.successes' "$REPORT") FAILURES=$(jq -r '.failures' "$REPORT") + TOTAL=$((SUCCESSES + FAILURES)) - if [ "$FAILURES" -eq 0 ]; then - STATUS_ICON="✅" - STATUS_TEXT="All checks passed" - else - STATUS_ICON="❌" - STATUS_TEXT="${FAILURES} violation(s) found" - fi - - # Build markdown { - echo "## ${STATUS_ICON} StructLint Validation" - echo "" - echo "| Metric | Count |" - echo "|--------|-------|" - echo "| Checks passed | ${SUCCESSES} |" - echo "| Violations | ${FAILURES} |" - } > /tmp/structlint-md.tmp - MD=$(cat /tmp/structlint-md.tmp) - - # Add violations detail if any - if [ "$FAILURES" -gt 0 ]; then - VIOLATIONS=$(jq -r '.summary.violations[]? | "### ⚠️ \(.description) (\(.count))\n" + ([.examples[]? | "- `\(.)`"] | join("\n")) + "\n"' "$REPORT") - { + if [ "$FAILURES" -eq 0 ]; then + echo "## StructLint — All checks passed" echo "" - echo "
" - echo "Violation Details" + echo "**${SUCCESSES}** rules validated against \`${CONFIG_PATH}\`. No violations found." + else + echo "## StructLint — ${FAILURES} violation(s) found" echo "" - echo "$VIOLATIONS" + echo "**${SUCCESSES}**/${TOTAL} rules passed · **${FAILURES}** violation(s) detected against \`${CONFIG_PATH}\`." echo "" - echo "
" - } >> /tmp/structlint-md.tmp - MD=$(cat /tmp/structlint-md.tmp) - fi + + # Render each violation category + jq -r '.summary.violations[]? | @json' "$REPORT" | while IFS= read -r v; do + DESC=$(echo "$v" | jq -r '.description') + COUNT=$(echo "$v" | jq -r '.count') + EXAMPLES=$(echo "$v" | jq -r '.examples[]?') + EXAMPLE_COUNT=$(echo "$v" | jq -r '.examples | length') + + echo "
" + echo "${DESC} (${COUNT})" + echo "" + echo "$EXAMPLES" | while IFS= read -r ex; do + echo "- \`${ex}\`" + done + if [ "$COUNT" -gt "$EXAMPLE_COUNT" ]; then + REMAINING=$((COUNT - EXAMPLE_COUNT)) + echo "- _…and ${REMAINING} more_" + fi + echo "" + echo "
" + echo "" + done + fi + + echo "---" + echo "View full run · Powered by StructLint" + } > /tmp/structlint-md.tmp + + MD=$(cat /tmp/structlint-md.tmp) # Write to job summary echo "$MD" >> "$GITHUB_STEP_SUMMARY"