Skip to content

IvanVSyntio/cicd-optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ CI/CD Pipeline Optimizer

Maximize development team productivity through intelligent build and deployment optimization using AI to analyze pipelines, identify bottlenecks, and automatically implement optimizations for speed, cost, and reliability.

CI/CD Pipeline License: MIT

🎯 Value Proposition

  • 40-60% build time reduction through AI-powered analysis
  • 30% infrastructure cost savings via intelligent optimization
  • Replace $10K consulting with continuous automated optimization
  • Multi-platform support for GitHub Actions, GitLab CI, Jenkins

⚑ Quick Start

1. Clone and Setup

git clone https://github.com/yourusername/cicd-optimizer.git
cd cicd-optimizer

2. Environment Setup

# Copy environment template
cp .env.example .env

# Add your GitHub token
export GITHUB_TOKEN=your_github_token_here

3. Install Dependencies

cd src/optimizer
pip install -r requirements.txt

4. Run the Service

python main.py

5. Test with Demo

# Analyze a repository
python scripts/demo-pipeline-analysis.py https://github.com/microsoft/vscode

# Or test the API
curl http://localhost:5000/repositories/microsoft/vscode/analyze

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Pipeline Data  │───▢│   AI Analyzer    │───▢│  Optimization   │───▢│   Auto-Apply    β”‚
β”‚ (GitHub Actions β”‚    β”‚ (Bottleneck      β”‚    β”‚  Engine         β”‚    β”‚   Changes        β”‚
β”‚  GitLab, etc.)  β”‚    β”‚  Detection)      β”‚    β”‚ (Speed/Cost)    β”‚    β”‚ (Pull Requests)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‘ API Endpoints

Health Check

GET /health
# Response includes branch and LLM provider information
{
  "status": "healthy",
  "service": "cicd-optimizer", 
  "branch": "develop",
  "environment": "development",
  "llm_provider": "mistral",
  "github_service": "enabled"
}

Analyze Pipeline

POST /analyze
{
  "repo_url": "https://github.com/owner/repo",
  "workflow_name": "CI" # optional
}

Generate Optimizations

POST /optimize
{
  "repo_url": "https://github.com/owner/repo",
  "types": ["speed", "cost"] # optional
}

Quick Analysis

GET /repositories/{owner}/{repo}/analyze

πŸ”§ Configuration

Branch-Specific LLM Configuration

The CI/CD Optimizer uses different LLM providers based on the git branch:

  • main branch (Production): Uses Vertex AI (Google Cloud)
  • develop branch (Development): Uses Mistral AI

Environment Variables

Core Configuration

GITHUB_TOKEN=your_github_token_here     # Required for GitHub API access
DATABASE_URL=sqlite:///optimizer.db     # Database connection
FLASK_ENV=development                   # Flask environment
LOG_LEVEL=INFO                          # Logging level
PORT=5000                              # Application port

LLM Provider Configuration

For main/production branch (Vertex AI):

VERTEX_AI_API_KEY=your_vertex_ai_key
VERTEX_AI_MODEL=gemini-pro
VERTEX_AI_ENDPOINT=your_vertex_ai_endpoint

For develop branch (Mistral AI):

MISTRAL_API_KEY=your_mistral_api_key
MISTRAL_MODEL=mistral-large-latest
MISTRAL_ENDPOINT=https://api.mistral.ai/v1

Quick Setup

Development Environment (develop branch)

# Switch to develop branch
git checkout develop

# Copy development environment template
cp .env.develop .env

# Add your API keys
export GITHUB_TOKEN=your_github_token_here
export MISTRAL_API_KEY=your_mistral_api_key_here

Production Environment (main branch)

# Switch to main branch
git checkout main

# Copy production environment template
cp .env.main .env

# Add your API keys
export GITHUB_TOKEN=your_github_token_here
export VERTEX_AI_API_KEY=your_vertex_ai_key_here

GitHub Token Setup

  1. Go to GitHub Settings β†’ Developer settings β†’ Personal access tokens
  2. Generate token with repo and workflow scopes
  3. Add to .env file or export as environment variable

πŸš€ Features

Speed Optimization

  • Dependency Caching: Automatic cache configuration for npm, pip, Maven
  • Parallel Execution: Convert sequential jobs to parallel workflows
  • Build Optimization: Optimize Docker builds, test execution, asset compilation

Cost Optimization

  • Runner Right-sizing: Match runner specs to workload requirements
  • Trigger Optimization: Reduce unnecessary workflow runs
  • Resource Efficiency: Optimize compute usage and eliminate waste

Intelligence

  • Bottleneck Detection: Identify slow steps and failure patterns
  • Trend Analysis: Track performance metrics over time
  • Confidence Scoring: Rate optimization recommendations by reliability

πŸ“Š Demo Output Example

πŸš€ CI/CD Pipeline Optimizer - Live Demo
════════════════════════════════════════════════════════════

πŸ“Š Current Pipeline Metrics
────────────────────────────
πŸ“ˆ Repository: vscode
πŸ“ˆ Workflow: CI
πŸ“ˆ Total Runs Analyzed: 50
πŸ“ˆ Average Duration: 12.4 minutes
πŸ“ˆ Success Rate: 94.0%
πŸ“ˆ Estimated Monthly Cost: $187.20

πŸ† Top Recommendations:
   1. πŸ”₯ Add caching for npm install
      πŸ“ Cache dependencies for 'npm install' step to reduce execution time  
      ⏱️  Saves: 4.2 min | πŸ’° $67.50/month
      🎯 Confidence: 85% | πŸ› οΈ  Effort: Low - Add cache action to workflow

   2. ⚑ Parallelize independent jobs  
      πŸ“ Run 3 independent steps in parallel
      ⏱️  Saves: 6.1 min | πŸ’° $89.30/month
      🎯 Confidence: 75% | πŸ› οΈ  Effort: Medium - Restructure workflow jobs

πŸ’° Total Monthly Savings: $2,340.00
πŸ“… Annual Savings: $28,080.00

🐳 Docker Deployment

Build Image

cd src/optimizer
docker build -t cicd-optimizer .

Run Container

docker run -d \
  -p 5000:5000 \
  -e GITHUB_TOKEN=your_token \
  --name cicd-optimizer \
  cicd-optimizer

Docker Compose

version: '3.8'
services:
  optimizer:
    build: ./src/optimizer
    ports:
      - "5000:5000"
    environment:
      - GITHUB_TOKEN=${GITHUB_TOKEN}
      - FLASK_ENV=production
    restart: unless-stopped

πŸ§ͺ Testing

Run Tests

cd src/optimizer
python -m pytest tests/ -v --cov=.

Integration Testing

# Test with real repository (requires GITHUB_TOKEN)
python scripts/demo-pipeline-analysis.py https://github.com/your-org/your-repo

API Testing

# Start service
python main.py &

# Test endpoints
curl http://localhost:5000/health
curl -X POST http://localhost:5000/analyze -H "Content-Type: application/json" -d '{"repo_url":"https://github.com/microsoft/vscode"}'

πŸ“ˆ Supported Platforms

Current Support

  • βœ… GitHub Actions: Full analysis and optimization
  • ⏳ GitLab CI: Coming soon
  • ⏳ Jenkins: Coming soon
  • ⏳ Azure DevOps: Coming soon

Optimization Types

  • πŸš€ Speed: Caching, parallelization, dependency optimization
  • πŸ’° Cost: Runner optimization, resource right-sizing
  • πŸ”’ Security: Coming soon
  • πŸ“Š Reliability: Coming soon

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Links

πŸ†˜ Support


Built with ❀️ for DevOps teams who want faster, cheaper, more reliable CI/CD pipelines.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors