Skip to content

feat: Add release workflow, contributing guidelines, and enhance READ… #5

feat: Add release workflow, contributing guidelines, and enhance READ…

feat: Add release workflow, contributing guidelines, and enhance READ… #5

name: Publish Traceability Badge
on:
workflow_dispatch:
push:
branches: [ main, master ]
paths:
- 'docs/roadmap.ndjson'
- 'tests/**'
- 'traceability_check.py'
- '.github/workflows/traceability.yml'
- '.github/workflows/traceability-badge.yml'
workflow_run:
workflows: [ "Traceability Coverage" ]
types: [ completed ]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: 'pages-traceability-badge'
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Compute traceability coverage JSON
run: |
python -m pip install -U pip
# Run checker; do not fail build if roadmap/tests are absent
python traceability_check.py --json-out traceability_coverage.json || true
echo "Traceability JSON (if any):"
test -f traceability_coverage.json && cat traceability_coverage.json || echo '{}' > traceability_coverage.json
- name: Generate Shields.io badge JSON
run: |
python - << 'PY'
import json, os
# Default badge
badge = {
"schemaVersion": 1,
"label": "Traceability",
"message": "n/a",
"color": "lightgrey"
}
try:
with open('traceability_coverage.json', 'r') as f:
data = json.load(f)
pct = float(data.get('coverage_percent', 0.0))
badge['message'] = f"{pct:.1f}%"
# Simple color scale
if pct >= 90:
badge['color'] = 'brightgreen'
elif pct >= 75:
badge['color'] = 'green'
elif pct >= 60:
badge['color'] = 'yellowgreen'
elif pct >= 40:
badge['color'] = 'orange'
else:
badge['color'] = 'red'
except Exception as e:
# Keep defaults on error
badge['message'] = 'n/a'
badge['color'] = 'lightgrey'
os.makedirs('public', exist_ok=True)
with open('public/traceability_badge.json', 'w') as f:
json.dump(badge, f)
print('Badge JSON:')
print(json.dumps(badge, indent=2))
PY
- name: Upload artifact for GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: ./public
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4