|
| 1 | +# 🚀 CI/CD Pipeline Documentation |
| 2 | + |
| 3 | +This directory contains the automated CI/CD pipeline for the LeetCode Problem Solutions repository. The pipeline automatically updates all documentation files when new problems are added. |
| 4 | + |
| 5 | +## 📁 Structure |
| 6 | + |
| 7 | +``` |
| 8 | +.github/ |
| 9 | +├── workflows/ |
| 10 | +│ ├── auto-update-docs.yml # Main auto-update workflow |
| 11 | +│ ├── validate-docs.yml # Documentation validation |
| 12 | +│ └── manual-update.yml # Manual update trigger |
| 13 | +└── scripts/ |
| 14 | + ├── update_documentation.py # Main documentation updater |
| 15 | + ├── validate_documentation.py # Documentation validator |
| 16 | + ├── check_links.py # Link checker |
| 17 | + ├── validate_problems.py # Problem structure validator |
| 18 | + └── manual_update.py # Manual update script |
| 19 | +``` |
| 20 | + |
| 21 | +## 🔄 Workflows |
| 22 | + |
| 23 | +### 1. Auto-Update Documentation (`auto-update-docs.yml`) |
| 24 | + |
| 25 | +**Triggers:** |
| 26 | +- Push to `main`/`master` branch with changes in problem directories |
| 27 | +- Pull requests affecting problem directories |
| 28 | + |
| 29 | +**Actions:** |
| 30 | +- Detects new/modified problems |
| 31 | +- Scans problem metadata (title, difficulty, topics, languages) |
| 32 | +- Updates all documentation files: |
| 33 | + - `README.md` - Repository structure and problem tables |
| 34 | + - `INDEX.md` - Problem indices and categorization |
| 35 | + - `PERFORMANCE_ANALYSIS.md` - Performance metrics and analysis |
| 36 | + - `InterviewPreparation.md` - Interview references and examples |
| 37 | +- Commits changes automatically |
| 38 | + |
| 39 | +### 2. Documentation Validation (`validate-docs.yml`) |
| 40 | + |
| 41 | +**Triggers:** |
| 42 | +- All pushes and pull requests |
| 43 | + |
| 44 | +**Actions:** |
| 45 | +- Validates documentation structure |
| 46 | +- Checks for broken internal links |
| 47 | +- Validates problem directory structure |
| 48 | +- Ensures markdown syntax correctness |
| 49 | + |
| 50 | +### 3. Manual Update (`manual-update.yml`) |
| 51 | + |
| 52 | +**Triggers:** |
| 53 | +- Manual workflow dispatch |
| 54 | + |
| 55 | +**Options:** |
| 56 | +- Update type: `all`, `readme`, `index`, `performance`, `interview-prep` |
| 57 | +- Force update: Update even if no changes detected |
| 58 | + |
| 59 | +## 🛠️ Scripts |
| 60 | + |
| 61 | +### `update_documentation.py` |
| 62 | +Main documentation updater that: |
| 63 | +- Scans all problem directories |
| 64 | +- Extracts metadata from `Problem.md` files |
| 65 | +- Detects available solution languages |
| 66 | +- Updates all documentation files with new content |
| 67 | + |
| 68 | +### `validate_documentation.py` |
| 69 | +Validates documentation structure: |
| 70 | +- Checks for required sections |
| 71 | +- Validates markdown format |
| 72 | +- Ensures consistency across files |
| 73 | + |
| 74 | +### `check_links.py` |
| 75 | +Validates internal links: |
| 76 | +- Finds broken relative links |
| 77 | +- Skips external URLs |
| 78 | +- Reports missing referenced files |
| 79 | + |
| 80 | +### `validate_problems.py` |
| 81 | +Validates problem directory structure: |
| 82 | +- Ensures `Problem.md` exists |
| 83 | +- Checks for solution files |
| 84 | +- Validates problem metadata format |
| 85 | + |
| 86 | +## 🚀 How It Works |
| 87 | + |
| 88 | +### Automatic Updates |
| 89 | + |
| 90 | +1. **Detection**: When you push changes to problem directories, the workflow detects modified files |
| 91 | +2. **Scanning**: The script scans all problem directories and extracts metadata |
| 92 | +3. **Update**: All documentation files are updated with new problem information |
| 93 | +4. **Commit**: Changes are automatically committed with a descriptive message |
| 94 | + |
| 95 | +### Adding New Problems |
| 96 | + |
| 97 | +When you add a new problem: |
| 98 | + |
| 99 | +1. Create the problem directory (e.g., `Daily_Problems/DailyProblem7/`) |
| 100 | +2. Add `Problem.md` with proper format: |
| 101 | + ```markdown |
| 102 | + # 1234. Problem Title |
| 103 | + |
| 104 | + **Difficulty**: Medium |
| 105 | + **Topics**: Array, Dynamic Programming |
| 106 | + |
| 107 | + [Problem description...] |
| 108 | + ``` |
| 109 | +3. Add solution files (`InCPP.cpp`, `InJava.java`, etc.) |
| 110 | +4. Push to repository |
| 111 | +5. CI/CD automatically updates all documentation! 🎉 |
| 112 | + |
| 113 | +### Manual Updates |
| 114 | + |
| 115 | +If you need to manually trigger updates: |
| 116 | + |
| 117 | +1. Go to GitHub Actions tab |
| 118 | +2. Select "Manual Documentation Update" |
| 119 | +3. Click "Run workflow" |
| 120 | +4. Choose update type and options |
| 121 | +5. Click "Run workflow" button |
| 122 | + |
| 123 | +## 📊 Monitoring |
| 124 | + |
| 125 | +### GitHub Actions Dashboard |
| 126 | +- View workflow runs and status |
| 127 | +- Check validation results |
| 128 | +- Monitor automatic updates |
| 129 | + |
| 130 | +### Workflow Summaries |
| 131 | +Each workflow provides detailed summaries: |
| 132 | +- Files changed |
| 133 | +- Problems detected |
| 134 | +- Validation results |
| 135 | +- Performance reports |
| 136 | + |
| 137 | +## 🔧 Configuration |
| 138 | + |
| 139 | +### Environment Variables |
| 140 | +- `GITHUB_TOKEN`: Automatically provided by GitHub Actions |
| 141 | +- No additional secrets required |
| 142 | + |
| 143 | +### Permissions |
| 144 | +Workflows have: |
| 145 | +- `contents: write` - To commit documentation updates |
| 146 | +- `pull-requests: write` - To comment on PRs |
| 147 | + |
| 148 | +## 🛡️ Error Handling |
| 149 | + |
| 150 | +### Validation Failures |
| 151 | +- Broken links stop the workflow |
| 152 | +- Missing required files generate warnings |
| 153 | +- Structure violations are reported |
| 154 | + |
| 155 | +### Update Failures |
| 156 | +- Failed updates are logged |
| 157 | +- Manual intervention may be required |
| 158 | +- Rollback procedures available |
| 159 | + |
| 160 | +## 🎯 Best Practices |
| 161 | + |
| 162 | +### Problem Structure |
| 163 | +Ensure each problem directory has: |
| 164 | +- `Problem.md` with proper format |
| 165 | +- At least one solution file |
| 166 | +- Consistent naming conventions |
| 167 | + |
| 168 | +### Commit Messages |
| 169 | +Automatic commits include: |
| 170 | +- Changed files list |
| 171 | +- Problem numbers affected |
| 172 | +- Timestamp and workflow info |
| 173 | + |
| 174 | +### Review Process |
| 175 | +- Validate changes before pushing |
| 176 | +- Review auto-generated documentation |
| 177 | +- Monitor workflow results |
| 178 | + |
| 179 | +## 🚀 Benefits |
| 180 | + |
| 181 | +### Automation |
| 182 | +- ✅ Zero manual documentation maintenance |
| 183 | +- ✅ Consistent formatting across all files |
| 184 | +- ✅ Real-time updates when problems are added |
| 185 | + |
| 186 | +### Quality Assurance |
| 187 | +- ✅ Link validation prevents broken references |
| 188 | +- ✅ Structure validation ensures consistency |
| 189 | +- ✅ Automatic error detection and reporting |
| 190 | + |
| 191 | +### Developer Experience |
| 192 | +- ✅ Focus on problem-solving, not documentation |
| 193 | +- ✅ Immediate feedback on changes |
| 194 | +- ✅ Professional-quality repository maintenance |
| 195 | + |
| 196 | +## 🔮 Future Enhancements |
| 197 | + |
| 198 | +Planned improvements: |
| 199 | +- Performance benchmark automation |
| 200 | +- Test case validation |
| 201 | +- Solution correctness checking |
| 202 | +- Multi-language compilation testing |
| 203 | +- Advanced metrics and analytics |
| 204 | + |
| 205 | +--- |
| 206 | + |
| 207 | +**Happy Coding!** 🎉 The CI/CD pipeline ensures your repository stays perfectly organized and up-to-date automatically! |
0 commit comments