Skip to content

danoliva713/CI-Insight

Repository files navigation

CI Insight

AI-Driven CI/CD Failure Analyzer - Reduce CI pain, shorten MTTR

CI Insight is a production-quality web application that ingests CI/CD pipeline failures from GitHub Actions and Jenkins, automatically classifies them, detects flaky tests, and provides intelligent fix suggestions.

Features

  • Automated Failure Analysis: Rule-based classification with optional AI-powered insights
  • Flaky Test Detection: Identifies intermittent test failures with scoring and explanations
  • Fix Suggestions: Rule-based suggestions always available, AI-enhanced when configured
  • Recurrence Tracking: Spot patterns, track top failures, and identify new issues
  • Multiple CI Platforms: GitHub Actions and Jenkins support out of the box
  • Privacy-First: Log redaction, optional raw log storage, offline AI mode available
  • Production-Ready: Docker Compose deployment, comprehensive tests, structured logging

Quick Start

One-Command Startup

docker compose up --build

That's it! The application will be available at:

Demo Mode (with sample data)

# Start the application
docker compose up --build -d

# Import sample data
docker exec ci-insight-backend python /app/../scripts/import-demo-data.py

# Or send sample webhooks
./scripts/send-sample-webhook.sh

Visit http://localhost to see the dashboard populated with demo failures.

Requirements

  • Docker and Docker Compose
  • (Optional) OpenAI API key for AI-powered suggestions

That's all! No other dependencies required.

Configuration

The application works out of the box with sensible defaults. Configure via environment variables:

Core Settings

# AI Provider (none, openai, local)
AI_PROVIDER=local                # Default: local (TF-IDF based, offline)

# OpenAI Configuration (optional)
OPENAI_API_KEY=sk-...           # Only needed if AI_PROVIDER=openai
OPENAI_MODEL=gpt-3.5-turbo      # Default model

# Privacy Settings
ENABLE_LOG_REDACTION=true       # Redact secrets from logs (recommended)
STORE_RAW_LOGS=false            # Store unredacted logs (privacy risk)

# Security
ENABLE_WEBHOOK_VALIDATION=false # Dev mode: accept unsigned webhooks
GITHUB_WEBHOOK_SECRET=...       # For production webhook validation
JENKINS_WEBHOOK_SECRET=...      # For production webhook validation

# Database
DATABASE_URL=sqlite:////data/ci_insight.db  # Default: SQLite
# For Postgres: postgresql://user:pass@db:5432/ci_insight

Using OpenAI (Optional)

Create a .env file in the project root:

AI_PROVIDER=openai
OPENAI_API_KEY=sk-your-key-here

Then restart:

docker compose down
docker compose up --build

The app gracefully degrades to rule-based suggestions if OpenAI is unavailable.

Webhook Setup

GitHub Actions

  1. Go to your repository Settings → Webhooks → Add webhook
  2. Payload URL: http://your-server/api/ingest/github/webhook
  3. Content type: application/json
  4. Events: Select "Workflow runs"
  5. Secret (optional): Set in GITHUB_WEBHOOK_SECRET env var
  6. Click "Add webhook"

Jenkins

  1. Install the "Notification Plugin" in Jenkins
  2. In your job, Configure → Post-build Actions → Notification Endpoint
  3. URL: http://your-server/api/ingest/jenkins/webhook
  4. Format: JSON
  5. Event: Job Finalized
  6. Token (optional): Set in JENKINS_WEBHOOK_SECRET env var

Architecture

┌─────────────┐       ┌──────────────┐       ┌─────────────┐
│   GitHub    │──────▶│  CI Insight  │◀──────│   Jenkins   │
│   Actions   │webhook│              │webhook│             │
└─────────────┘       └──────────────┘       └─────────────┘
                            │
                            ├─ Ingestion Layer
                            │    ├─ GitHub Service
                            │    ├─ Jenkins Service
                            │    └─ Log Parser
                            │
                            ├─ Analysis Layer
                            │    ├─ Classifier (rule-based)
                            │    ├─ Flaky Detector
                            │    ├─ Log Redactor
                            │    └─ Similarity Analyzer
                            │
                            ├─ AI Layer (optional)
                            │    ├─ OpenAI Provider
                            │    └─ Local Provider (TF-IDF)
                            │
                            ├─ Storage
                            │    └─ SQLite / PostgreSQL
                            │
                            └─ Frontend
                                 └─ React Dashboard

See architecture.md for detailed design documentation.

API Endpoints

Ingestion

  • POST /api/ingest/github/webhook - GitHub webhook receiver
  • POST /api/ingest/jenkins/webhook - Jenkins webhook receiver

Data Access

  • GET /api/repos - List repositories
  • GET /api/runs?repo_id=&status=&branch= - List CI runs with filters
  • GET /api/runs/{run_id} - Get run details
  • GET /api/failures?category=&q= - List failures with filters
  • GET /api/failures/{failure_id} - Get failure details
  • POST /api/failures/{failure_id}/reanalyze - Re-run analysis

Analytics

  • GET /api/analytics/overview - Dashboard metrics
  • GET /api/analytics/flaky - Flaky test analysis

Full API documentation: http://localhost:8000/docs

Development

Run Locally (without Docker)

Backend:

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload

Frontend:

cd frontend
npm install
npm run dev

Run Tests

# Backend tests
cd backend
pytest

# With coverage
pytest --cov=app --cov-report=html

# Frontend tests
cd frontend
npm test

Linting & Formatting

# Backend
make lint
make format

# Or manually
cd backend
black app
flake8 app

Project Structure

CI-Insight/
├── backend/
│   ├── app/
│   │   ├── api/              # API routes
│   │   ├── core/             # Config, database, logging
│   │   ├── models/           # SQLAlchemy models
│   │   ├── schemas/          # Pydantic schemas
│   │   ├── services/         # Business logic
│   │   │   ├── analysis/     # Classifiers, detectors
│   │   │   ├── ai/           # AI providers
│   │   │   └── ingestion/    # GitHub, Jenkins
│   │   └── tests/            # Unit & integration tests
│   ├── alembic/              # Database migrations
│   ├── Dockerfile
│   └── requirements.txt
├── frontend/
│   ├── src/
│   │   ├── components/       # React components
│   │   ├── pages/            # Page components
│   │   ├── services/         # API client
│   │   └── types/            # TypeScript types
│   ├── Dockerfile
│   └── package.json
├── sample-data/              # Demo webhooks & seed data
├── scripts/                  # Utility scripts
├── docker-compose.yml
└── README.md

Troubleshooting

Application won't start

# Check logs
docker compose logs

# Rebuild from scratch
docker compose down -v
docker compose up --build

Database issues

# Reset database
docker compose down -v
docker volume rm ci-insight_backend-data
docker compose up --build

Frontend can't reach backend

Check CORS settings in backend/app/core/config.py. Default allows localhost.

Webhooks not working

  1. Check webhook validation is disabled for dev: ENABLE_WEBHOOK_VALIDATION=false
  2. Check backend logs: docker compose logs backend
  3. Test manually: ./scripts/test-ingestion.sh

AI features not working

  1. Check AI_PROVIDER setting
  2. If using OpenAI, verify OPENAI_API_KEY is set
  3. Check backend logs for API errors
  4. App will gracefully fall back to rule-based suggestions

Security

See security.md for:

  • Threat model
  • Log redaction details
  • Webhook signature verification
  • Production deployment recommendations

Contributing

This is a demonstration project. For production use:

  1. Enable webhook signature validation
  2. Use PostgreSQL instead of SQLite
  3. Set up proper CORS origins
  4. Review and enhance log redaction patterns
  5. Implement authentication if exposing publicly

License

MIT License - See LICENSE file for details

Support

For issues and questions:


Built with ❤️ to reduce CI pain and shorten MTTR

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors