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
236 changes: 236 additions & 0 deletions .github/workflows/version-dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
name: Version Dashboard

on:
schedule:
- cron: '*/30 * * * *' # every 30 minutes
workflow_dispatch: # allow manual trigger

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: false

jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Fetch latest GitHub releases
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api "/repos/$GITHUB_REPOSITORY/releases?per_page=100" > releases.json
echo "Fetched $(jq length releases.json) releases"

- name: Check health endpoints
run: |
mkdir -p health_results

check_health() {
local name=$1 env=$2 url=$3
local outfile="health_results/${name}__${env}.json"

http_code=$(curl -sf -o "/tmp/body_${name}_${env}.json" \
-w "%{http_code}" --max-time 10 "$url" 2>/dev/null || echo "000")

version=$(jq -r '.version // "unknown"' "/tmp/body_${name}_${env}.json" 2>/dev/null || echo "unknown")

if [ "$http_code" = "200" ]; then
status="ok"
elif [ "$http_code" = "000" ]; then
status="unreachable"
else
status="fail"
fi

jq -n \
--arg status "$status" \
--arg version "$version" \
--arg code "$http_code" \
'{status: $status, version: $version, http_code: $code}' \
> "$outfile"
}

export -f check_health

while IFS= read -r row; do
name=$(echo "$row" | jq -r '.name')
for env in ci uat test prod; do
url=$(echo "$row" | jq -r ".envs.$env")
[ "$url" != "null" ] && check_health "$name" "$env" "$url" &
done
done < <(jq -c '.[]' dashboard/services.json)

wait
echo "All health checks complete"

- name: Generate dashboard HTML
run: |
mkdir -p dist
python3 << 'EOF'
import json, os
from datetime import datetime, timezone

with open('dashboard/services.json') as f:
services = json.load(f)

with open('releases.json') as f:
all_releases = json.load(f)

ENVS = ['ci', 'uat', 'test', 'prod']

def get_latest_release(service_name):
prefix = f"{service_name}/"
for r in all_releases:
if (r['tag_name'].startswith(prefix)
and not r['draft']
and not r['prerelease']):
return {
'version': r['tag_name'].removeprefix(prefix),
'url': r['html_url'],
}
return {'version': 'N/A', 'url': None}

def get_health(service_name, env):
path = f"health_results/{service_name}__{env}.json"
if os.path.exists(path):
with open(path) as f:
return json.load(f)
return {'status': 'unknown', 'version': 'N/A', 'http_code': 'N/A'}

rows = []
for svc in services:
name = svc['name']
latest = get_latest_release(name)
envs = {}
for env in ENVS:
h = get_health(name, env)
behind = (
env != 'ci'
and h['version'] not in ('N/A', 'unknown')
and h['version'] != latest['version']
)
envs[env] = {**h, 'behind': behind}
rows.append({'name': name, 'latest': latest, 'envs': envs})

def cell_class(health, is_ci=False):
if health['status'] == 'ok':
return 'behind' if health['behind'] else 'ok'
if health['status'] == 'unreachable':
return 'unreachable'
if health['status'] == 'fail':
return 'fail'
return 'unknown'

def badge(health, is_ci=False):
s = health['status']
icons = {'ok': 'βœ“', 'fail': 'βœ—', 'unreachable': '!', 'unknown': '?'}
return icons.get(s, '?')

now = datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M UTC')

header_cells = ''.join(
f'<th>{e.upper()}</th>' for e in ENVS
)

service_rows = ''
for row in rows:
latest = row['latest']
latest_link = (
f'<a href="{latest["url"]}" target="_blank">{latest["version"]}</a>'
if latest['url'] else latest['version']
)
cells = ''
for env in ENVS:
h = row['envs'][env]
cls = cell_class(h, is_ci=(env == 'ci'))
icon = badge(h, is_ci=(env == 'ci'))
behind_label = ' <span class="behind-label">behind</span>' if h['behind'] else ''
cells += f'<td class="{cls}"><span class="badge">{icon}</span> {h["version"]}{behind_label}</td>'
service_rows += f'<tr><td class="service-name">{row["name"]}</td><td class="latest-col">{latest_link}</td>{cells}</tr>'

html = f"""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Service Version Dashboard</title>
<style>
* {{ box-sizing: border-box; margin: 0; padding: 0; }}
body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: #0d1117; color: #e6edf3; padding: 2rem; }}
h1 {{ font-size: 1.4rem; font-weight: 600; margin-bottom: 0.25rem; }}
.updated {{ font-size: 0.8rem; color: #8b949e; margin-bottom: 1.5rem; }}
table {{ width: 100%; border-collapse: collapse; font-size: 0.875rem; }}
th, td {{ padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid #21262d; }}
th {{ background: #161b22; color: #8b949e; font-weight: 500; text-transform: uppercase;
font-size: 0.75rem; letter-spacing: 0.05em; }}
tr:hover td {{ background: #161b22; }}
.service-name {{ font-weight: 600; color: #58a6ff; }}
.latest-col a {{ color: #58a6ff; text-decoration: none; }}
.latest-col a:hover {{ text-decoration: underline; }}
.badge {{ display: inline-block; width: 1rem; text-align: center; font-weight: 700; }}
td.ok {{ color: #3fb950; }}
td.behind {{ color: #d29922; }}
td.fail {{ color: #f85149; }}
td.unreachable {{ color: #8b949e; font-style: italic; }}
td.unknown {{ color: #8b949e; }}
.behind-label {{ font-size: 0.7rem; background: #3d2b00; color: #d29922;
border-radius: 3px; padding: 1px 5px; margin-left: 4px; }}
.legend {{ display: flex; gap: 1.5rem; margin-top: 1rem; font-size: 0.75rem; color: #8b949e; }}
.legend span {{ display: flex; align-items: center; gap: 0.3rem; }}
.dot {{ width: 8px; height: 8px; border-radius: 50%; }}
.dot-ok {{ background: #3fb950; }} .dot-behind {{ background: #d29922; }}
.dot-fail {{ background: #f85149; }} .dot-unknown {{ background: #8b949e; }}
</style>
</head>
<body>
<h1>Service Version Dashboard</h1>
<p class="updated">Last updated: {now}</p>
<table>
<thead>
<tr>
<th>Service</th>
<th>Latest Release</th>
{header_cells}
</tr>
</thead>
<tbody>
{service_rows}
</tbody>
</table>
<div class="legend">
<span><span class="dot dot-ok"></span> Up to date</span>
<span><span class="dot dot-behind"></span> Behind latest</span>
<span><span class="dot dot-fail"></span> Health fail</span>
<span><span class="dot dot-unknown"></span> Unreachable</span>
</div>
</body>
</html>"""

with open('dist/index.html', 'w') as f:
f.write(html)

print(f"Dashboard generated with {len(rows)} services")
EOF

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist

deploy:
needs: generate
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
104 changes: 104 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Git & Pull Requests

- Always open PRs against **Bandwidth/github-pulse** (`origin`). Never use `ViktorBilokin/github-pulse` (`upstream`).
- Push feature branches to `origin` and use `gh pr create --repo Bandwidth/github-pulse --base main --head <branch>`.

## Commands

### Development

```bash
make start-dev # Full dev mode: PostgreSQL + backend (port 8080) + frontend HMR (port 3000)
make dev # Start PostgreSQL only (then run backend/frontend manually)
make start # Production mode: single JAR serving frontend at port 8080
```

### Backend (Maven)

```bash
cd backend
./mvnw spring-boot:run # Run backend
./mvnw test # Run Cucumber BDD integration tests
./mvnw package -DskipTests # Build production JAR
```

### Frontend (npm)

```bash
cd frontend
npm run dev # Vite dev server on port 3000
npm run build # TypeScript compile + Vite build β†’ dist/
npm run lint # ESLint
```

### Docker

```bash
make up # Start full stack via Docker Compose
make down # Stop stack
make logs # View logs
```

### Cleanup

```bash
make clean # Clean Maven build, node_modules/.vite, and static resources
make stop # Stop all services and kill ports 8080, 3000, 5432
```

## Architecture

**GitHub Pulse** is a GitHub activity analytics dashboard. The stack is Spring Boot 3.3.5 (Java 21) backend with a React + TypeScript + Vite frontend.

### Request Flow

```
Browser (port 3000 dev / 80 prod)
β†’ /api/* proxied to Spring Boot (port 8080)
β†’ Services β†’ PostgreSQL + GitHub API + Jira API + Anthropic API
```

In production, the frontend is built and embedded into the Spring Boot JAR as static resources (served at `/`).

### Backend Structure (`backend/src/main/java/com/githubpulse/`)

- **`controller/`** β€” REST controllers: `DashboardController`, `AdminController`, `FiltersController`, `JiraController`
- **`service/github/`** β€” GitHub sync via GraphQL (`GitHubGraphQlSyncClient`) and REST (`GitHubPatClient`)
- **`service/dashboard/`** β€” Aggregates metrics (top contributors, reviewers, PR details)
- **`service/jira/`** β€” Jira REST API client + Claude-powered ticket quality scoring via `TicketQualityService`
- **`scheduler/GitHubSyncScheduler.java`** β€” Hourly cron sync with ShedLock distributed locking
- **`repository/`** β€” Spring Data JPA repositories for all entities

### Frontend Structure (`frontend/src/`)

- **`pages/`** β€” `DashboardPage`, `AdminPage`, `ConfigPage`, `SyncPage`, `JiraPage`
- **`components/`** β€” Reusable UI components
- Vite proxies `/api` β†’ `http://localhost:8080` in dev

### Database

PostgreSQL 16 with Flyway migrations in `operations/database/`:
- `V1__initial_schema.sql` β€” Core tables: `repositories`, `teams`, `contributors`, `team_members`, `pull_requests`, `reviews`, `comments`, `sync_state`, `shedlock`
- `V2__create_app_settings_table.sql` β€” `app_settings` key-value store

Hibernate is set to `validate` mode β€” schema changes must go through Flyway migrations.

### Key Configuration (`backend/src/main/resources/application.yml`)

All values are environment-driven:

| Variable | Purpose |
|---|---|
| `GITHUB_TOKEN` | GitHub PAT (required; scopes: `repo`, `read:org`) |
| `ANTHROPIC_API_KEY` | Claude API key for Jira quality scoring |
| `DB_HOST/PORT/NAME/USERNAME/PASSWORD` | PostgreSQL connection |
| `SYNC_CRON` | Sync schedule (default: `0 0 * * * *` β€” hourly) |
| `SPRING_FLYWAY_LOCATIONS` | Path to migration SQL files |

### Backend Tests

Cucumber BDD integration tests with H2 (PostgreSQL compatibility mode). Feature files live in `backend/src/test/resources/features/`. Run with `./mvnw test`.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ stop:
-@pkill -f "spring-boot:run" 2>/dev/null || true
-@pkill -f "vite" 2>/dev/null || true
docker compose down
@echo "Clearing any remaining processes on target ports..."
-@lsof -ti :8080 | xargs kill -9 2>/dev/null || true
-@lsof -ti :3000 | xargs kill -9 2>/dev/null || true
-@lsof -ti :5432 | xargs kill -9 2>/dev/null || true
@echo "All services stopped."

# Restart
Expand Down
Loading