# analyze-cicd

Analyze CI/CD effectiveness, performance, efficiency, and cost.

## Overview

The `analyze-cicd` command provides a comprehensive analysis of your CI/CD pipelines with a focus on:

- **Performance**: Caching strategies, job times, parallelization opportunities
- **Efficiency**: Job dependencies, critical path analysis, smart filtering opportunities
- **Cost**: Runner selection, artifact storage, token usage, annual cost projections

Perfect for any Roadcrew customer who needs to optimize their GitHub Actions workflows or other CI/CD platforms.

## Usage

```bash
# Analyze current repository
npm run analyze-cicd

# Analyze specific repository
npm run analyze-cicd -- /path/to/repo
```

## What You Get

### Comprehensive Report

A detailed markdown report including:

1. **Executive Summary** - Violation counts, recommendation count, health grade
2. **Health Score** - Performance/Efficiency/Cost ratings with visual indicators
3. **Platform Detection** - GitHub Actions, CircleCI, GitLab CI, Jenkins detection
4. **Workflows Overview** - Summary table of all detected workflows
5. **Configuration Analysis** - Package manager, caching strategy, test frameworks
6. **Violations** - Issues grouped by category (performance, efficiency, cost)
7. **Top Recommendations** - Priority-ranked actionable improvements
8. **Detailed Implementation** - Step-by-step guidance for each recommendation
9. **Performance Insights** - Deep analysis of bottlenecks and opportunities
10. **Next Steps** - Prioritized action plan

### Analysis Output

The report shows:

- Critical performance bottlenecks (slow jobs, missing caches)
- Efficiency opportunities (parallelization, job dependencies)
- Cost optimization (runner selection, artifact storage)
- Implementation effort and ROI for each recommendation
- Payback periods for cost-saving measures

## Example Output

```
🔍 CI/CD Analysis Report
Generated: [timestamp]
Repository: [path]

📊 Executive Summary
- Workflows: 5 detected
- Total Jobs: 23 jobs across workflows
- Issues Found: 2 critical, 4 high-severity
- Critical Recommendations: 3 require immediate attention
- Overall Health Grade: B

💚 Health Score
🟡 Grade: B - Good CI/CD practices - minor optimizations available

Score Breakdown:
| Dimension | Score | Status |
|-----------|-------|--------|
| Performance | 7/10 | ███████░░ |
| Efficiency | 6/10 | ██████░░░░ |
| Cost | 8/10 | ████████░░ |
| Overall | 7/10 | ███████░░ |

...and much more
```

## Phases

### Phase 1 (Current)

Focuses on the core optimization opportunities:

- Performance analysis (caching gaps, job profiling)
- Efficiency analysis (dependency chains, parallelization)
- Cost analysis (runner costs, artifact storage)

### Phase 2 (Planned)

Will add deeper analysis:

- Security violations in CI/CD configurations
- Reliability improvements and failure recovery
- Maintenance and sustainability metrics

## Implementation

This command leverages atomic analyzer utilities:

- `analyze-cicd-performance.ts` - Caching, job times, parallelization
- `analyze-cicd-efficiency.ts` - Dependency graphs, critical path
- `analyze-cicd-cost.ts` - Runner costs, storage, tokens

And integrates them through:

- `orchestrator.ts` - Coordinates all analyzers
- `report-generator.ts` - Generates comprehensive markdown report
- `violation-detector.ts` - Identifies performance/efficiency/cost issues

## Requirements

- Node.js 16+
- Repository with Git access
- GitHub Actions or other CI/CD platform configured

## Notes

- Analysis is read-only (no changes to your repository)
- No credentials needed (analyzes workflow YAML files)
- Works with mono-repo and multi-repo setups
- Can be integrated into your own CI/CD pipeline

## See Also

- `analyze-architecture-full` - Architecture analysis
- `audit-security` - Security audit utilities
- `minimize-tokens` - Token optimization

## Related Epic

GitHub Epic #1171 - CI/CD Analysis Command Implementation

