|
25 | 25 | - uses: getsentry/warden@v0 |
26 | 26 | with: |
27 | 27 | anthropic-api-key: ${{ secrets.WARDEN_ANTHROPIC_API_KEY }} |
| 28 | + |
| 29 | + - name: Summarize Warden results |
| 30 | + if: always() |
| 31 | + env: |
| 32 | + FINDINGS_PATH: ${{ runner.temp }}/warden-findings.json |
| 33 | + run: | |
| 34 | + { |
| 35 | + echo "## Warden Sweep" |
| 36 | + echo |
| 37 | + echo "- Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" |
| 38 | +
|
| 39 | + if [[ ! -f "${FINDINGS_PATH}" ]]; then |
| 40 | + echo "- Findings file: not found" |
| 41 | + exit 0 |
| 42 | + fi |
| 43 | +
|
| 44 | + echo "- Findings artifact: \`warden-findings\`" |
| 45 | + node --input-type=module <<'NODE' |
| 46 | + import fs from 'node:fs'; |
| 47 | +
|
| 48 | + const findingsPath = process.env.FINDINGS_PATH; |
| 49 | + const raw = fs.readFileSync(findingsPath, 'utf8'); |
| 50 | + const payload = JSON.parse(raw); |
| 51 | + const findings = Array.isArray(payload) |
| 52 | + ? payload |
| 53 | + : Array.isArray(payload.findings) |
| 54 | + ? payload.findings |
| 55 | + : []; |
| 56 | + const total = typeof payload.totalFindings === 'number' ? payload.totalFindings : findings.length; |
| 57 | +
|
| 58 | + console.log(`- Total findings: ${total}`); |
| 59 | +
|
| 60 | + if (findings.length > 0) { |
| 61 | + console.log(''); |
| 62 | + console.log('| Severity | Skill | File | Title |'); |
| 63 | + console.log('|---|---|---|---|'); |
| 64 | + for (const finding of findings.slice(0, 20)) { |
| 65 | + const severity = finding.severity ?? ''; |
| 66 | + const skill = finding.skill ?? ''; |
| 67 | + const file = finding.filePath ?? finding.file ?? ''; |
| 68 | + const title = String(finding.title ?? finding.message ?? '').replaceAll('|', '\\|'); |
| 69 | + console.log(`| ${severity} | ${skill} | \`${file}\` | ${title} |`); |
| 70 | + } |
| 71 | + if (findings.length > 20) { |
| 72 | + console.log(`\nShowing first 20 of ${findings.length} findings. Download the artifact for the full JSON.`); |
| 73 | + } |
| 74 | + } else { |
| 75 | + console.log('- Result: no findings'); |
| 76 | + } |
| 77 | + NODE |
| 78 | + } >> "${GITHUB_STEP_SUMMARY}" |
| 79 | +
|
| 80 | + - name: Upload Warden findings |
| 81 | + if: always() |
| 82 | + uses: actions/upload-artifact@v4 |
| 83 | + with: |
| 84 | + name: warden-findings |
| 85 | + path: ${{ runner.temp }}/warden-findings.json |
| 86 | + if-no-files-found: warn |
0 commit comments