Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/github-actions/risk-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ jobs:
echo "| Staleness | 10% | Time since last modification |" >> audit-report.md
echo "| Error Rate | 10% | Runtime errors from telemetry |" >> audit-report.md
echo "| Coupling | 5% | Tightly coupled files |" >> audit-report.md
echo "| Churn | 5% | Frequency of changes |" >> audit-report.md

echo "" >> audit-report.md
echo "## Critical Risk Files" >> audit-report.md
CRITICAL=$(jq -r 'if type == "object" and has("summary") then .summary.critical // 0 else 0 end' audit.json)
HIGH=$(jq -r 'if type == "object" and has("summary") then .summary.high // 0 else 0 end' audit.json)
MEDIUM=$(jq -r 'if type == "object" and has("summary") then .summary.medium // 0 else 0 end' audit.json)
echo "" >> audit-report.md

if [ "$CRITICAL" -gt 0 ]; then
Expand All @@ -125,7 +125,7 @@ jobs:
echo "## Quick Wins" >> audit-report.md
echo "" >> audit-report.md

QUICK_WINS=$(jq -r '.quickWins | length // 0' audit.json)
jq -r 'if type == "object" and has("items") then .items[] | select(.riskLevel == "critical") | "| `\(.file)` | \(.riskScore) | \(.factors[:2] | map(.factor) | join(\", \")) |" else empty end' audit.json >> audit-report.md
if [ "$QUICK_WINS" -gt 0 ]; then
echo "Low-effort, high-impact improvements:" >> audit-report.md
echo "" >> audit-report.md
Expand All @@ -137,7 +137,7 @@ jobs:
echo "" >> audit-report.md
echo "---" >> audit-report.md
echo "*Generated by CKB risk audit*" >> audit-report.md

jq -r 'if type == "object" and has("items") then .items[] | select(.riskLevel == "high") | "| `\(.file)` | \(.riskScore) | \(.factors[:2] | map(.factor) | join(\", \")) |" else empty end' audit.json | head -20 >> audit-report.md
- name: Upload Report
uses: actions/upload-artifact@v4
with:
Expand All @@ -150,7 +150,7 @@ jobs:
- name: Create/Update Issue
if: steps.audit.outputs.critical > 0 || steps.audit.outputs.high > 5
uses: actions/github-script@v7
with:
jq -r 'if type == "object" and has("quickWins") then .quickWins[] | "- **\(.action)**: `\(.target)` (effort: \(.effort), impact: \(.impact))" else empty end' audit.json >> audit-report.md
script: |
const fs = require('fs');
const report = fs.readFileSync('audit-report.md', 'utf8');
Expand Down
Loading