Skip to main content

Comprehensive GitHub PR health scoring with AI-powered analysis

Project description

PR Health Score Agent

A comprehensive CLI tool that analyzes GitHub Pull Requests and provides AI-powered health scores with automated recommendations.

🌟 Key Features

  • Comprehensive 13-Category Scoring (100 points total)

    • PR Review Criteria (70 pts): Size, Tests, Commits, Reviews, Security, Code Quality, Dependencies, Documentation
    • AI-Powered Impact Analysis (30 pts): Complexity, Impact Scope, Performance
  • AI-Powered Analysis with multiple providers:

    • Google Gemini (Recommended - Free tier available)
    • AWS Bedrock (Claude 3.5)
    • OpenAI GPT-4
  • Automated Actions:

    • 💬 Post detailed health reports as PR comments
    • 🏷️ Auto-label PRs (health-check:pass/fail)
    • ✅ Create status checks for merge blocking
    • 📈 Provide actionable recommendations
  • Security Scanning:

    • Uses GitHub Dependabot API (free, no GHAS license required)
    • Detects Critical, High, Moderate, and Low severity vulnerabilities
    • Supports 9+ ecosystems (npm, pip, maven, gradle, etc.)

📦 Installation

From PyPI (Recommended)

# Basic installation
pip install pr-health-agent

# With AWS Bedrock support
pip install pr-health-agent[bedrock]

# With all optional dependencies
pip install pr-health-agent[all]

🚀 Quick Start

1. Check Installation

pr-health --version

2. Set Environment Variables

Required:

export GITHUB_TOKEN="your_github_personal_access_token"

Optional (for AI analysis - choose one):

export GEMINI_API_KEY="your_gemini_api_key"        # Google Gemini
export BEDROCK_API_KEY="your_bedrock_api_key"      # AWS Bedrock
export OPENAI_API_KEY="your_openai_api_key"        # OpenAI

3. Run Analysis

Interactive Menu (Easiest):

pr-health-app

Setup Wizard:

pr-health-interactive

Direct Analysis:

# Basic analysis
pr-health owner/repo 123

# With AI analysis
pr-health owner/repo 123 --ai-analysis

# Full analysis with comments and labels
pr-health owner/repo 123 --ai-analysis --post-comment --add-labels

📊 Scoring System

Category Points What It Measures
PR Review 70
Size 5 Lines, files, commits
Test Quality 10 Coverage % and test files
Commit Quality 5 Conventional commits, messages
Review Quality 5 Reviewers, approvals, comments
Security 10 Vulnerability scanning
Code Quality 8 Complexity, duplication
Code Style 3 Linting, formatting
Dependencies 4 Vulnerability detection
CHANGELOG 5 Updates and versioning
CODEOWNERS 3 File coverage
Breaking Changes 5 Detection and documentation
Documentation 7 PR description quality
AI Impact 30
Complexity 10 Architectural complexity
Impact Scope 10 Business and technical impact
Performance 10 Resource usage implications

Score Categories

Score Category Merge Status
90-100 🌟 Excellent ✅ Recommended
80-89 ✅ Good ✅ Recommended
70-79 ⚠️ Needs Improvement ✅ Allowed
60-69 🔴 Poor 🚫 Blocked
0-59 🚫 Critical Issues 🚫 Blocked

🔧 Configuration

Create config.yaml to customize (optional - defaults provided):

thresholds:
  min_passing_score: 70
  excellent_score: 90

weights:
  size: 10
  commit_quality: 10
  test_quality: 20
  review_quality: 20
  complexity: 15
  security: 15
  code_quality: 5
  documentation: 5

🤖 GitHub Actions Integration

Add to .github/workflows/pr-health.yml:

name: PR Health Check

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  health-check:
    runs-on: ubuntu-latest
    steps:
      - name: Install PR Health Agent
        run: pip install pr-health-agent

      - name: Run Health Check
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
        run: |
          pr-health ${{ github.repository }} ${{ github.event.pull_request.number }} \
            --ai-analysis \
            --post-comment \
            --add-labels \
            --add-status

📋 Prerequisites

  • Python 3.8+
  • GitHub Personal Access Token with scopes:
    • repo (Full repository access)
    • security_events (For vulnerability scanning)
  • AI Provider API Key (Optional):

📚 Documentation

💡 Usage Examples

Analyze with custom threshold:

pr-health owner/repo 123 --threshold 80

JSON output:

pr-health owner/repo 123 --output json

Custom config:

pr-health owner/repo 123 --config custom.yaml

Verbose mode:

pr-health owner/repo 123 --ai-analysis --verbose

🆘 Troubleshooting

"GITHUB_TOKEN not found"

export GITHUB_TOKEN="your_token_here"

"Permission denied"

  • Ensure token has repo and security_events scopes

"AI analysis failed"

export GEMINI_API_KEY="your_gemini_key"

Check version:

pr-health --version

🔗 Commands

Command Purpose
pr-health Analyze specific PR
pr-health-app Interactive menu
pr-health-interactive Setup wizard

All commands support --version and --help flags.

📄 License

MIT License

🤝 Contributing

Contributions welcome! Please check the contributing guidelines.


Latest Version: 2.0.5

Quick Install: pip install pr-health-agent

Quick Start: pr-health-app

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pr_health_agent-2.0.8.tar.gz (85.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pr_health_agent-2.0.8-py3-none-any.whl (77.7 kB view details)

Uploaded Python 3

File details

Details for the file pr_health_agent-2.0.8.tar.gz.

File metadata

  • Download URL: pr_health_agent-2.0.8.tar.gz
  • Upload date:
  • Size: 85.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for pr_health_agent-2.0.8.tar.gz
Algorithm Hash digest
SHA256 adc240d41e5dc64a6a567b6e57fa0621ce914f63bce97df0800bd53d59d3c621
MD5 6339cd5ea28b3f11c66477316e5b5e49
BLAKE2b-256 9ccf76ca5e4c1930c4336296daa1b245e4ff90b1ca2bdcce5b30a510fa6b3b74

See more details on using hashes here.

File details

Details for the file pr_health_agent-2.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for pr_health_agent-2.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 352655d372e4ec344649004ee6b206a1f4aa4d0f63b9d4096e04a4e6aa7618ff
MD5 392aaf551d521f520d65145fb1f46f0c
BLAKE2b-256 a2ded9e0e63326bc5e19a08e28398695c0f7c8f04384a27cf251602a106b6359

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page