Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Task Manager with Claude Code CI/CD Integration

A Flask-based task management application that demonstrates integration with Claude Code for automated build failure analysis and fix suggestions.

Features

Task Management

  • βœ… Create, edit, complete, and delete tasks
  • 🏷️ Categorize tasks (Work, Personal, Urgent, General)
  • ⭐ Set priority levels (High, Medium, Low)
  • πŸ” Filter and search tasks
  • πŸ“Š Task statistics and visualizations
  • πŸ’Ύ Session-based storage (no database required)

CI/CD Integration

  • πŸš€ GitHub Actions pipeline with automated testing and deployment
  • πŸ€– Claude Code integration for AI-powered build failure analysis
  • πŸ“‘ Webhook endpoint for receiving build failure notifications
  • πŸ”§ Automated fix suggestions for common issues
  • πŸ“ Pull request comments with AI-generated solutions
  • πŸ“Š Admin dashboard for monitoring build failures

Quick Start

Prerequisites

  • Python 3.11+
  • Flask and dependencies (see requirements.txt)
  • GitHub repository for CI/CD
  • Render account for deployment (optional)
  • Anthropic API key for Claude integration (optional)

Local Development

  1. Clone the repository

    git clone <your-repo-url>
    cd DemoClaudeCICD
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set environment variables (optional)

    export FLASK_ENV=development
    export SECRET_KEY=your-secret-key
    export ANTHROPIC_API_KEY=your-anthropic-api-key
  5. Run the application

    python app.py
  6. Access the application

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=. --cov-report=html

# Run specific test file
pytest test_app.py -v

Code Quality

# Format code
black .

# Sort imports
isort .

# Lint code
flake8 .

# Security scan
bandit -r . -x test_*.py

Deployment

Render Deployment

  1. Fork this repository

  2. Create a new Web Service on Render

    • Connect your GitHub repository
    • Use the following settings:
      • Environment: Python 3
      • Build Command: pip install -r requirements.txt
      • Start Command: gunicorn --bind 0.0.0.0:$PORT app:app
  3. Set environment variables

    • SECRET_KEY: Generate a secure random key
    • ANTHROPIC_API_KEY: Your Claude API key (optional)
    • FLASK_ENV: production
  4. Configure GitHub Secrets

    • RENDER_SERVICE_ID: Your Render service ID
    • RENDER_API_KEY: Your Render API key
    • RENDER_SERVICE_URL: Your deployed app URL
    • WEBHOOK_URL: Your app URL + /webhook/build-failure
    • ANTHROPIC_API_KEY: Your Claude API key

CI/CD Pipeline

The project includes two GitHub Actions workflows:

Main CI/CD Pipeline (.github/workflows/ci-cd.yml)

  • Triggered on: Push to main/develop, Pull requests
  • Steps:
    1. Code linting and formatting checks
    2. Unit tests with coverage reporting
    3. Security scanning
    4. Application startup test
    5. Deployment to Render (main branch only)

Failure Handler (.github/workflows/failure-notification.yml)

  • Triggered on: CI/CD pipeline failure
  • Steps:
    1. Captures workflow logs and error details
    2. Sends data to Claude Code for analysis
    3. Posts AI-generated fix suggestions
    4. Creates GitHub issues or PR comments
    5. Optional Slack notifications

Claude Code Integration

How It Works

  1. Build Failure Detection: GitHub Actions detects pipeline failures
  2. Log Collection: Failure handler script collects error logs and context
  3. AI Analysis: Logs are sent to Claude Code API for analysis
  4. Fix Suggestions: AI generates specific, actionable fix recommendations
  5. Notification: Results are posted to webhook endpoint and stored in session
  6. Dashboard: Admin dashboard displays failures and suggestions

API Integration

The claude_integration.py module provides:

  • Error Analysis: Intelligent parsing of build logs
  • Context Awareness: Considers repository and build environment
  • Fallback Handling: Mock suggestions when API is unavailable
  • Pattern Recognition: Common error pattern detection

Webhook Endpoint

POST /webhook/build-failure

Expected payload:

{
  "error_logs": "string",
  "build_context": {},
  "repository": "string",
  "branch": "string", 
  "commit_sha": "string"
}

Response:

{
  "status": "success",
  "suggestions": "AI-generated fix suggestions",
  "message": "Build failure processed"
}

Project Structure

DemoClaudeCICD/
β”œβ”€β”€ app.py                          # Main Flask application
β”œβ”€β”€ claude_integration.py           # Claude Code API integration
β”œβ”€β”€ requirements.txt                # Python dependencies
β”œβ”€β”€ Procfile                        # Render deployment config
β”œβ”€β”€ render.yaml                     # Render service configuration
β”œβ”€β”€ test_app.py                     # Unit tests
β”œβ”€β”€ .gitignore                      # Git ignore rules
β”œβ”€β”€ README.md                       # Project documentation
β”œβ”€β”€ templates/                      # HTML templates
β”‚   β”œβ”€β”€ base.html                   # Base template
β”‚   β”œβ”€β”€ index.html                  # Main task interface
β”‚   β”œβ”€β”€ edit_task.html             # Task editing form
β”‚   └── admin.html                 # Admin dashboard
β”œβ”€β”€ static/                         # Static assets
β”‚   β”œβ”€β”€ style.css                  # Custom styles
β”‚   └── script.js                  # Frontend JavaScript
β”œβ”€β”€ scripts/                        # Utility scripts
β”‚   └── failure_handler.py         # GitHub Actions failure processor
└── .github/workflows/              # GitHub Actions
    β”œβ”€β”€ ci-cd.yml                  # Main CI/CD pipeline
    └── failure-notification.yml   # Build failure handler

Configuration

Environment Variables

Variable Description Required
SECRET_KEY Flask session secret key Yes
ANTHROPIC_API_KEY Claude API key for AI features No
FLASK_ENV Flask environment (development/production) No
PORT Application port (set by Render) No

GitHub Secrets

Secret Description
RENDER_SERVICE_ID Render service identifier
RENDER_API_KEY Render API key for deployments
RENDER_SERVICE_URL Deployed application URL
WEBHOOK_URL Webhook endpoint URL
ANTHROPIC_API_KEY Claude API key
SLACK_WEBHOOK_URL Optional Slack notifications

API Endpoints

Endpoint Method Description
/ GET Main task management interface
/add_task POST Create new task
/complete_task/<id> POST Mark task as complete
/delete_task/<id> POST Delete task
/edit_task/<id> GET/POST Edit task form
/api/stats GET Task statistics JSON
/webhook/build-failure POST Build failure webhook
/admin GET Admin dashboard
/health GET Health check endpoint

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

License

This project is open source and available under the MIT License.

Support

For issues and questions:

  • Check the Issues page
  • Review the admin dashboard for build failures
  • Check GitHub Actions logs for CI/CD issues

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages