Skip to content

Commit 6a5e3c1

Browse files
machado144claude
andauthored
refactor: improve PR comment to be more professional and informative (#6)
## Summary - Replace bare metrics table with contextual pass/total ratio and config path reference - Each violation category rendered as its own collapsible `<details>` section instead of one monolithic block - Truncated examples now show "…and N more" count - Clean single-line success message (no table with zeros) - Subtle footer linking to the full workflow run and StructLint repo ### Before ``` ## ✅ StructLint Validation | Metric | Count | |--------|-------| | Checks passed | 12 | | Violations | 3 | <details> <summary>Violation Details</summary> ### ⚠️ Files not matching any allowed naming pattern (3) - `Disallowed file naming pattern found: ...` - `Disallowed file naming pattern found: ...` - `Disallowed file naming pattern found: ...` </details> ``` ### After (pass) ``` ## StructLint — All checks passed **12** rules validated against `.structlint.yaml`. No violations found. --- View full run · Powered by StructLint ``` ### After (fail) ``` ## StructLint — 3 violation(s) found **9**/12 rules passed · **3** violation(s) detected against `.structlint.yaml`. ▸ Files not matching any allowed naming pattern (3) - `Disallowed file naming pattern found: ...` - `Disallowed file naming pattern found: ...` - …and 1 more --- View full run · Powered by StructLint ``` ## Test plan - [ ] Trigger workflow on a clean repo — verify success comment renders correctly - [ ] Trigger workflow with intentional violations — verify collapsible categories and truncation - [ ] Verify "View full run" link points to the correct workflow run 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7405781 commit 6a5e3c1

1 file changed

Lines changed: 39 additions & 29 deletions

File tree

action.yml

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ runs:
9292
- name: Generate Summary
9393
if: always()
9494
shell: bash
95+
env:
96+
CONFIG_PATH: ${{ inputs.config }}
97+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
9598
run: |
9699
REPORT="/tmp/structlint-report.json"
97100
if [ ! -f "$REPORT" ]; then
@@ -101,40 +104,47 @@ runs:
101104
102105
SUCCESSES=$(jq -r '.successes' "$REPORT")
103106
FAILURES=$(jq -r '.failures' "$REPORT")
107+
TOTAL=$((SUCCESSES + FAILURES))
104108
105-
if [ "$FAILURES" -eq 0 ]; then
106-
STATUS_ICON="✅"
107-
STATUS_TEXT="All checks passed"
108-
else
109-
STATUS_ICON="❌"
110-
STATUS_TEXT="${FAILURES} violation(s) found"
111-
fi
112-
113-
# Build markdown
114109
{
115-
echo "## ${STATUS_ICON} StructLint Validation"
116-
echo ""
117-
echo "| Metric | Count |"
118-
echo "|--------|-------|"
119-
echo "| Checks passed | ${SUCCESSES} |"
120-
echo "| Violations | ${FAILURES} |"
121-
} > /tmp/structlint-md.tmp
122-
MD=$(cat /tmp/structlint-md.tmp)
123-
124-
# Add violations detail if any
125-
if [ "$FAILURES" -gt 0 ]; then
126-
VIOLATIONS=$(jq -r '.summary.violations[]? | "### ⚠️ \(.description) (\(.count))\n" + ([.examples[]? | "- `\(.)`"] | join("\n")) + "\n"' "$REPORT")
127-
{
110+
if [ "$FAILURES" -eq 0 ]; then
111+
echo "## StructLint — All checks passed"
128112
echo ""
129-
echo "<details>"
130-
echo "<summary><strong>Violation Details</strong></summary>"
113+
echo "**${SUCCESSES}** rules validated against \`${CONFIG_PATH}\`. No violations found."
114+
else
115+
echo "## StructLint — ${FAILURES} violation(s) found"
131116
echo ""
132-
echo "$VIOLATIONS"
117+
echo "**${SUCCESSES}**/${TOTAL} rules passed · **${FAILURES}** violation(s) detected against \`${CONFIG_PATH}\`."
133118
echo ""
134-
echo "</details>"
135-
} >> /tmp/structlint-md.tmp
136-
MD=$(cat /tmp/structlint-md.tmp)
137-
fi
119+
120+
# Render each violation category
121+
jq -r '.summary.violations[]? | @json' "$REPORT" | while IFS= read -r v; do
122+
DESC=$(echo "$v" | jq -r '.description')
123+
COUNT=$(echo "$v" | jq -r '.count')
124+
EXAMPLES=$(echo "$v" | jq -r '.examples[]?')
125+
EXAMPLE_COUNT=$(echo "$v" | jq -r '.examples | length')
126+
127+
echo "<details>"
128+
echo "<summary><strong>${DESC}</strong> (${COUNT})</summary>"
129+
echo ""
130+
echo "$EXAMPLES" | while IFS= read -r ex; do
131+
echo "- \`${ex}\`"
132+
done
133+
if [ "$COUNT" -gt "$EXAMPLE_COUNT" ]; then
134+
REMAINING=$((COUNT - EXAMPLE_COUNT))
135+
echo "- _…and ${REMAINING} more_"
136+
fi
137+
echo ""
138+
echo "</details>"
139+
echo ""
140+
done
141+
fi
142+
143+
echo "---"
144+
echo "<sub><a href=\"${RUN_URL}\">View full run</a> · Powered by <a href=\"https://github.com/AxeForging/structlint\">StructLint</a></sub>"
145+
} > /tmp/structlint-md.tmp
146+
147+
MD=$(cat /tmp/structlint-md.tmp)
138148
139149
# Write to job summary
140150
echo "$MD" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)