|
| 1 | +# Local CI Runner |
| 2 | + |
| 3 | +Run GitHub Actions CI checks locally for **10-100x faster** development iteration! |
| 4 | + |
| 5 | +## Why Run Locally? |
| 6 | + |
| 7 | +### ✅ Speed |
| 8 | +- **No queue time** - GitHub Actions can take 1-5 minutes to start |
| 9 | +- **No download time** - Dependencies already installed |
| 10 | +- **No setup time** - Environment already configured |
| 11 | +- **Local speed** - Your computer is usually faster than GitHub runners |
| 12 | + |
| 13 | +### ✅ Debugging |
| 14 | +- **Instant feedback** - See errors immediately |
| 15 | +- **Interactive debugging** - Set breakpoints, inspect variables |
| 16 | +- **Quick iteration** - Fix and retest in seconds |
| 17 | +- **Detailed logs** - Add any debug output you want |
| 18 | + |
| 19 | +### ✅ Resource Savings |
| 20 | +- **Free** - Doesn't consume GitHub Actions minutes |
| 21 | +- **Unlimited runs** - Run as many times as you need |
| 22 | +- **Private repo friendly** - No quota limitations |
| 23 | + |
| 24 | +### ✅ Flexibility |
| 25 | +- **Selective runs** - Run only the checks you need |
| 26 | +- **Custom tests** - Add temporary test scripts |
| 27 | +- **Local environment** - Matches your development environment exactly |
| 28 | + |
| 29 | +## Usage |
| 30 | + |
| 31 | +### Run All Checks |
| 32 | +```bash |
| 33 | +python run_local_ci.py |
| 34 | +``` |
| 35 | + |
| 36 | +This runs all 6 CI checks sequentially: |
| 37 | +1. ✅ Syntax Check |
| 38 | +2. ✅ Linting Check |
| 39 | +3. ✅ Import Check |
| 40 | +4. ✅ Type Check |
| 41 | +5. ✅ Config Check |
| 42 | +6. ✅ Build Test |
| 43 | + |
| 44 | +### Run Individual Checks |
| 45 | +```bash |
| 46 | +python run_local_ci.py --syntax # Run only syntax check |
| 47 | +python run_local_ci.py --lint # Run only linting |
| 48 | +python run_local_ci.py --import # Run only import check |
| 49 | +python run_local_ci.py --type # Run only type check |
| 50 | +python run_local_ci.py --config # Run only config check |
| 51 | +python run_local_ci.py --build # Run only build test |
| 52 | +``` |
| 53 | + |
| 54 | +## Local vs GitHub Actions |
| 55 | + |
| 56 | +| Metric | GitHub Actions | Local CI | Speedup | |
| 57 | +|---------|---------------|-----------|---------| |
| 58 | +| Queue time | 1-5 minutes | 0 seconds | 60-300x | |
| 59 | +| Setup time | 30-60 seconds | 0 seconds | 30-60x | |
| 60 | +| Download time | 10-30 seconds | 0 seconds | ∞ | |
| 61 | +| Check time | 10-30 seconds | 5-15 seconds | 2x | |
| 62 | +| **Total** | **2-6 minutes** | **5-15 seconds** | **8-72x** | |
| 63 | + |
| 64 | +## Example Workflow |
| 65 | + |
| 66 | +### Before (GitHub Actions only) |
| 67 | +```bash |
| 68 | +# 1. Make changes |
| 69 | +git add . |
| 70 | +git commit -m "fix: Something" |
| 71 | + |
| 72 | +# 2. Push and wait 2-6 minutes |
| 73 | +git push |
| 74 | +# ... wait for CI ... |
| 75 | + |
| 76 | +# 3. See CI failed (e.g., syntax error) |
| 77 | +# 4. Fix error |
| 78 | +git add . |
| 79 | +git commit -m "fix: Correct syntax" |
| 80 | + |
| 81 | +# 5. Push and wait 2-6 minutes again |
| 82 | +git push |
| 83 | +# ... wait for CI again ... |
| 84 | + |
| 85 | +# 6. CI passes! |
| 86 | +``` |
| 87 | + |
| 88 | +**Total time: 5-15 minutes** |
| 89 | + |
| 90 | +### After (Local CI first) |
| 91 | +```bash |
| 92 | +# 1. Make changes |
| 93 | +git add . |
| 94 | +git commit -m "fix: Something" |
| 95 | + |
| 96 | +# 2. Run local CI (5-15 seconds) |
| 97 | +python run_local_ci.py |
| 98 | +# ... checks pass! |
| 99 | + |
| 100 | +# 3. Push once |
| 101 | +git push |
| 102 | +# ... GitHub Actions CI passes in 2-6 minutes ... |
| 103 | + |
| 104 | +# 4. Done! |
| 105 | +``` |
| 106 | + |
| 107 | +**Total time: 2-7 minutes** (3x faster iteration!) |
| 108 | + |
| 109 | +## Benefits Summary |
| 110 | + |
| 111 | +### For Individual Developers |
| 112 | +- ⚡ **Faster iteration** - Fix bugs in seconds, not minutes |
| 113 | +- 🐛 **Better debugging** - See errors with full stack traces |
| 114 | +- 🚀 **Quick validation** - Test before pushing |
| 115 | +- 💰 **Save quota** - Don't waste GitHub Actions minutes |
| 116 | + |
| 117 | +### For Teams |
| 118 | +- 🔄 **Faster PR reviews** - CI already passed when PR created |
| 119 | +- 📊 **Consistent checks** - Everyone uses same local scripts |
| 120 | +- 🎯 **Quality focused** - More time on code, less waiting |
| 121 | + |
| 122 | +### For Continuous Deployment |
| 123 | +- 🚀 **Quicker releases** - Don't wait for CI to deploy |
| 124 | +- 🛡️ **Lower latency** - Deploy immediately after push |
| 125 | +- 📈 **More frequent updates** - No CI bottleneck |
| 126 | + |
| 127 | +## Tips |
| 128 | + |
| 129 | +### 1. Run Before Each Push |
| 130 | +```bash |
| 131 | +# Make changes |
| 132 | +# ... edit code ... |
| 133 | + |
| 134 | +# Run local CI |
| 135 | +python run_local_ci.py |
| 136 | + |
| 137 | +# Only push if all checks pass |
| 138 | +git add . |
| 139 | +git commit -m "feat: New feature" |
| 140 | +git push |
| 141 | +``` |
| 142 | + |
| 143 | +### 2. Use Selective Checks |
| 144 | +```bash |
| 145 | +# Quick syntax check before committing |
| 146 | +python run_local_ci.py --syntax |
| 147 | + |
| 148 | +# Full check before pushing |
| 149 | +python run_local_ci.py |
| 150 | +``` |
| 151 | + |
| 152 | +### 3. Add Custom Checks |
| 153 | +Add your own checks to `run_local_ci.py`: |
| 154 | +```python |
| 155 | +def run_custom_check(): |
| 156 | + return run_command( |
| 157 | + "Custom Check", |
| 158 | + "python my_test.py", |
| 159 | + "Run my custom test" |
| 160 | + ) |
| 161 | +``` |
| 162 | + |
| 163 | +## Troubleshooting |
| 164 | + |
| 165 | +### Missing Dependencies |
| 166 | +If you see import errors: |
| 167 | +```bash |
| 168 | +# Install missing dependencies |
| 169 | +pip install -r requirements.txt |
| 170 | +``` |
| 171 | + |
| 172 | +### Path Issues |
| 173 | +If you see `ModuleNotFoundError: No module named 'core'`: |
| 174 | +```bash |
| 175 | +# Run from repository root |
| 176 | +cd path/to/RainingKeysPython |
| 177 | +python run_local_ci.py |
| 178 | +``` |
| 179 | + |
| 180 | +### Script Errors |
| 181 | +If a script fails with unexpected errors: |
| 182 | +```bash |
| 183 | +# Run the script directly to see full error |
| 184 | +python .github/scripts/syntax_check.py |
| 185 | +python .github/scripts/type_check.py |
| 186 | +python .github/scripts/config_validation.py |
| 187 | +``` |
| 188 | + |
| 189 | +## Integration with Git Hooks (Optional) |
| 190 | + |
| 191 | +### Pre-commit Hook |
| 192 | +Run local CI automatically before each commit: |
| 193 | +```bash |
| 194 | +# Create .git/hooks/pre-commit |
| 195 | +cat > .git/hooks/pre-commit << 'EOF' |
| 196 | +#!/bin/sh |
| 197 | +python run_local_ci.py --syntax |
| 198 | +EOF |
| 199 | + |
| 200 | +# Make executable |
| 201 | +chmod +x .git/hooks/pre-commit |
| 202 | +``` |
| 203 | + |
| 204 | +### Pre-push Hook |
| 205 | +Run all checks before each push: |
| 206 | +```bash |
| 207 | +# Create .git/hooks/pre-push |
| 208 | +cat > .git/hooks/pre-push << 'EOF' |
| 209 | +#!/bin/sh |
| 210 | +python run_local_ci.py |
| 211 | +EOF |
| 212 | + |
| 213 | +# Make executable |
| 214 | +chmod +x .git/hooks/pre-push |
| 215 | +``` |
| 216 | + |
| 217 | +## Monitoring GitHub Actions CI |
| 218 | + |
| 219 | +While using local CI, you can still monitor GitHub Actions: |
| 220 | +```bash |
| 221 | +# Watch latest CI run |
| 222 | +python .github/scripts/monitor_ci.py |
| 223 | + |
| 224 | +# Check CI status |
| 225 | +gh run list --workflow="Code Quality" --limit 1 |
| 226 | +``` |
| 227 | + |
| 228 | +## Conclusion |
| 229 | + |
| 230 | +Running CI locally is **highly recommended** for: |
| 231 | + |
| 232 | +- ✅ Faster development iteration |
| 233 | +- ✅ Better debugging experience |
| 234 | +- ✅ Resource and cost savings |
| 235 | +- ✅ Unlimited testing |
| 236 | +- ✅ Improved code quality |
| 237 | + |
| 238 | +**Best practice:** Run `python run_local_ci.py` before every push! |
| 239 | + |
| 240 | +--- |
| 241 | + |
| 242 | +## Quick Start |
| 243 | + |
| 244 | +```bash |
| 245 | +# 1. Run local CI |
| 246 | +python run_local_ci.py |
| 247 | + |
| 248 | +# 2. If all checks pass, push |
| 249 | +git push |
| 250 | + |
| 251 | +# 3. GitHub Actions will pass too! |
| 252 | +``` |
| 253 | + |
| 254 | +Happy fast coding! 🚀 |
0 commit comments