Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/skylos-badge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vndv/pi-codegraph": patch
---

Add an automatically updated Skylos grade badge to the README.
6 changes: 6 additions & 0 deletions .github/badges/skylos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"schemaVersion": 1,
"label": "Skylos",
"message": "A+ (99)",
"color": "brightgreen"
}
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,33 @@ jobs:
- run: npm ci --ignore-scripts
- run: npm run ci
- run: pip install skylos
- run: skylos . -a --format json --output skylos-results.json
- run: skylos . --gate
- run: node scripts/update-skylos-badge.mjs skylos-results.json

skylos-badge:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.11"
- run: pip install skylos
- run: skylos . -a --format json --output skylos-results.json
- run: node scripts/update-skylos-badge.mjs skylos-results.json
- run: |
if git diff --quiet -- .github/badges/skylos.json; then
echo "Skylos badge already up to date."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .github/badges/skylos.json
git commit -m "docs: update Skylos badge"
git push
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# pi-codegraph
### CodeGraph tools for pi

[![Skylos Grade](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/vndv/pi-codegraph/main/.github/badges/skylos.json)](https://github.com/duriantaco/skylos)

[Install](#install) · [Usage](#usage) · [How it works](#how-it-works)

Ask pi structural questions about your codebase without falling back to slow grep/read loops.
Expand Down
27 changes: 27 additions & 0 deletions scripts/update-skylos-badge.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { readFile, writeFile } from 'node:fs/promises';

const inputPath = process.argv[2];

if (!inputPath) {
console.error('Usage: node scripts/update-skylos-badge.mjs <skylos-results.json>');
process.exit(1);
}

const results = JSON.parse(await readFile(inputPath, 'utf8'));
const overall = results.grade?.overall;

if (!overall || typeof overall.score !== 'number' || typeof overall.letter !== 'string') {
console.error('Skylos results are missing grade.overall.score or grade.overall.letter.');
process.exit(1);
}

const score = Math.round(overall.score);
const color = score >= 90 ? 'brightgreen' : score >= 80 ? 'green' : score >= 70 ? 'yellow' : score >= 60 ? 'orange' : 'red';
const badge = {
schemaVersion: 1,
label: 'Skylos',
message: `${overall.letter} (${score})`,
color,
};

await writeFile(new URL('../.github/badges/skylos.json', import.meta.url), `${JSON.stringify(badge, null, 2)}\n`);
Loading