Observed since 21 Oct, 10:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
AI-powered code analysis tool for CI/CD pipelines with GitHub Actions integration
A comprehensive AI-powered code analysis package that integrates with CI/CD pipelines to analyze code commits, execute tests, perform load testing, and generate detailed release notes with risk assessments.
# Install from PyPI
pip install ai-code-analyzer
# Or install with all optional dependencies
pip install ai-code-analyzer[all]
Add this to your .github/workflows/ci.yml:
name: AI Code Analysis
on:
pull_request:
push:
branches: [main]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ai-code-analyzer/ai-code-analyzer@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
# Initialize configuration
ai-code-analyzer init
# Analyze a commit
ai-code-analyzer analyze --commit HEAD
# Analyze a pull request
ai-code-analyzer analyze --pr 123
# Validate configuration
ai-code-analyzer validate
pip install# Basic installation
pip install ai-code-analyzer
# With development tools
pip install ai-code-analyzer[dev]
# With all optional dependencies
pip install ai-code-analyzer[all]
Create .github/workflows/ai-analysis.yml:
name: AI Code Analysis
on: [push, pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ai-code-analyzer/ai-code-analyzer@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
git clone https://github.com/ai-code-analyzer/ai-code-analyzer.git
cd ai-code-analyzer
pip install -e .
# Basic configuration
ai-code-analyzer init
# Advanced configuration
ai-code-analyzer init --template advanced
# Enterprise configuration
ai-code-analyzer init --template enterprise
export GITHUB_TOKEN="your-github-token"
export OPENAI_API_KEY="your-openai-api-key"
# OR
export ANTHROPIC_API_KEY="your-anthropic-api-key"
| Input | Description | Required | Default |
|---|---|---|---|
github-token | GitHub token for API access | Yes | ${{ github.token }} |
openai-api-key | OpenAI API key for AI analysis | No | - |
anthropic-api-key | Anthropic API key for AI analysis | No | - |
commit-hash | Specific commit to analyze | No | Auto-detect |
pr-number | PR number to analyze | No | Auto-detect |
config-file | Configuration file path | No | .ai-code-analyzer.yml |
load-testing | Enable load testing | No | false |
fail-on-high-risk | Fail on high/critical risk | No | true |
| Output | Description |
|---|---|
risk-level | Overall risk level (low, medium, high, critical) |
risk-score | Risk score (0-100) |
code-quality-score | Code quality score (0-100) |
test-coverage | Test coverage percentage |
security-issues | Number of security issues |
performance-issues | Number of performance issues |
analysis-results | Path to detailed results file |
# Analyze current commit
ai-code-analyzer analyze --commit HEAD
# Analyze specific commit
ai-code-analyzer analyze --commit abc123
# Analyze pull request
ai-code-analyzer analyze --pr 123
# Custom output file
ai-code-analyzer analyze --commit HEAD --output my-results.json
# Verbose output
ai-code-analyzer analyze --commit HEAD --verbose
# Initialize configuration
ai-code-analyzer init
# Validate configuration
ai-code-analyzer validate
# Validate specific config file
ai-code-analyzer validate --config my-config.yml
# Show version
ai-code-analyzer version
# Show help
ai-code-analyzer --help
name: Code Analysis
on: [push, pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ai-code-analyzer/ai-code-analyzer@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
name: Advanced Code Analysis
on: [push, pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
services:
app:
image: my-app:latest
ports:
- 8000:8000
steps:
- uses: actions/checkout@v4
- uses: ai-code-analyzer/ai-code-analyzer@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
load-testing: true
load-testing-host: http://localhost:8000
config-file: .ai-code-analyzer.yml
from ai_code_analyzer import CodeAnalysisTool
# Initialize the tool
tool = CodeAnalysisTool('config.yaml')
# Analyze a commit
results = await tool.analyze_commit('abc123')
# Analyze a PR
pr_results = await tool.analyze_pr(123)
# Initialize configuration
ai-code-analyzer init --template advanced
# Analyze current commit
ai-code-analyzer analyze --commit HEAD
# Analyze with custom config
ai-code-analyzer analyze --commit HEAD --config my-config.yml
# Validate configuration
ai-code-analyzer validate
# .ai-code-analyzer.yml
repository:
path: "."
github:
token: "${GITHUB_TOKEN}"
owner: "${GITHUB_REPOSITORY_OWNER}"
repo: "${GITHUB_REPOSITORY_NAME}"
ai:
openai_api_key: "${OPENAI_API_KEY}"
risk_assessment:
thresholds:
low: 0
medium: 40
high: 60
critical: 80
# .ai-code-analyzer.yml
repository:
path: "."
github:
token: "${GITHUB_TOKEN}"
owner: "${GITHUB_REPOSITORY_OWNER}"
repo: "${GITHUB_REPOSITORY_NAME}"
ai:
openai_api_key: "${OPENAI_API_KEY}"
anthropic_api_key: "${ANTHROPIC_API_KEY}"
load_testing:
enabled: true
host: "http://localhost:8000"
basic:
users: 10
duration: 60
analysis:
languages:
- python
- javascript
- java
- go
security:
enable_bandit: true
enable_safety: true
enable_semgrep: true
testing:
frameworks:
python: ["pytest"]
javascript: ["jest"]
coverage:
min_coverage: 80
risk_assessment:
weights:
security: 0.3
performance: 0.2
reliability: 0.25
maintainability: 0.15
testing: 0.1
thresholds:
low: 0
medium: 40
high: 60
critical: 80
# .github/workflows/pr-analysis.yml
name: PR Analysis
on:
pull_request:
types: [opened, synchronize]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ai-code-analyzer/ai-code-analyzer@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
fail-on-high-risk: true
# .github/workflows/release-analysis.yml
name: Release Analysis
on:
push:
branches: [main]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ai-code-analyzer/ai-code-analyzer@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
load-testing: true
fail-on-high-risk: false
- name: Create Release Notes
if: success()
run: |
# Use the generated release notes for creating releases
echo "Release notes generated in analysis results"
{
"risk_assessment": {
"risk_level": "medium",
"risk_score": 45.7,
"confidence": 0.85,
"recommendations": [
"Address security vulnerabilities immediately",
"Increase test coverage to at least 80%",
"Optimize performance bottlenecks"
]
},
"analysis": {
"quality_score": 78.5,
"security_issues": 2,
"performance_issues": 1
},
"tests": {
"summary": {
"total_tests": 150,
"passed_tests": 145,
"coverage_percentage": 82.3
}
}
}
🎯 Risk Assessment
┌─────────────────────────────────────┐
│ Risk Level: MEDIUM │
│ Risk Score: 45.7/100 │
│ Confidence: 0.85 │
└─────────────────────────────────────┘
📊 Analysis Metrics
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Metric ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ Code Quality Score │ 78.5/100 │
│ Security Issues │ 2 │
│ Performance Issues │ 1 │
│ Test Coverage │ 82.3% │
│ Tests Passed │ 145/150 │
└─────────────────────┴─────────────────────┘
💡 Top Recommendations:
1. Address security vulnerabilities immediately
2. Increase test coverage to at least 80%
3. Optimize performance bottlenecks
# Clone the repository
git clone https://github.com/ai-code-analyzer/ai-code-analyzer.git
cd ai-code-analyzer
# Install in development mode
pip install -e .[dev]
# Run tests
pytest
# Run linting
black src/ tests/
isort src/ tests/
flake8 src/ tests/
# Build the package
python -m build
# Check the package
twine check dist/*
# Upload to Test PyPI
twine upload --repository testpypi dist/*
from ai_code_analyzer import CodeAnalysisTool
tool = CodeAnalysisTool(config_path="config.yaml")
# Analyze a commit
results = await tool.analyze_commit("abc123")
# Analyze a PR
pr_results = await tool.analyze_pr(123)
from ai_code_analyzer import Config
config = Config("config.yaml")
value = config.get("github.token")
config.set("load_testing.enabled", True)
The tool generates comprehensive results in JSON format:
{
"commit_hash": "abc123",
"risk_assessment": {
"risk_level": "medium",
"risk_score": 45.7,
"confidence": 0.85,
"recommendations": [
"Address security vulnerabilities immediately",
"Increase test coverage to at least 80%"
]
},
"analysis": {
"quality_score": 78.5,
"security_issues": ["Potential SQL injection in auth.py"],
"performance_issues": ["Inefficient database query in search.py"]
},
"tests": {
"summary": {
"total_tests": 150,
"passed_tests": 145,
"failed_tests": 5,
"coverage_percentage": 82.3
}
},
"release_notes": "# Release Notes\n\n## Features\n- Added user authentication..."
}
Add custom rules to config.yaml:
risk_assessment:
custom_rules:
- pattern: "eval\\s*\\("
severity: "critical"
message: "Use of eval() is dangerous"
- pattern: "TODO|FIXME"
severity: "medium"
message: "Unresolved TODO items"
testing:
custom_commands:
python: ["python -m pytest --cov=src"]
javascript: ["npm test", "npm run test:integration"]
CodeAnalyzerPerforms static code analysis and quality checks.
TestExecutorExecutes tests and collects results.
LoadTesterPerforms load testing using Locust and Artillery.
AIRiskAssessmentAI-powered risk assessment using OpenAI or Anthropic.
ReleaseNotesGeneratorGenerates comprehensive release notes.
GitHubIntegrationHandles GitHub API integration.
Enable debug logging:
python src/main.py --verbose --commit HEAD
# Install in development mode
pip install -e .[dev]
# Run tests
pytest
# Format code
black src/ tests/
isort src/ tests/
# Type checking
mypy src/
# Linting
flake8 src/ tests/
The package is automatically published to PyPI when a new release is created on GitHub.
# Build the package
python -m build
# Upload to PyPI
twine upload dist/*
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
Made with ❤️ by the AI Code Analysis Team
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.1 | 12 Jul 2025 | 25 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 21 Oct, 10:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:7cd51b28f4c8a83a34318bd3ae46516755e2decf39985726c72e0d60d51f5f41